OSDN Git Service

13547061f9ab55f9b2dc92c248c3a9e756e37b37
[mikumikustudio/MikuMikuStudio.git] / src / com / jme / input / action / InputActionEvent.java
1 /*
2  * Copyright (c) 2003-2009 jMonkeyEngine
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  *   notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  *   notice, this list of conditions and the following disclaimer in the
14  *   documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of 'jMonkeyEngine' nor the names of its contributors 
17  *   may be used to endorse or promote products derived from this software 
18  *   without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 package com.jme.input.action;
34
35 /**
36  * <code>InputActionEvent</code> defines an event that generates the
37  * processing of a given InputAction. This event contains information about the
38  * triggers that caused the event to take places as well as the list of names of
39  * the other Actions that were to be processed at the same time.
40  * 
41  * @author Mark Powell
42  * @version $Id: InputActionEvent.java,v 1.10 2006/11/25 11:45:19 irrisor Exp $
43  */
44 public class InputActionEvent {
45
46     //the time of the event.
47     private float time;
48
49     /**
50      * instantiates a default InputActionEvent object. The keys, eventList and
51      * time are set to null or 0.
52      *  
53      */
54     public InputActionEvent() {
55     }
56
57     /**
58      * returns the time the event occured.
59      * 
60      * @return Returns the time.
61      */
62     public float getTime() {
63         return time;
64     }
65
66     /**
67      * sets the time the event occured.
68      * 
69      * @param time
70      *            The time to set.
71      */
72     public void setTime(float time) {
73         this.time = time;
74     }
75
76
77     /**
78      * Usually triggerName is set to a button/axis name or command.
79      *
80      * @return current value of field triggerName
81      */
82     public String getTriggerName() {
83         return this.triggerName;
84     }
85
86     /**
87      * @see #getTriggerName
88      */
89     private String triggerName;
90
91     /**
92      * @param value new value
93      */
94     public void setTriggerName( final String value ) {
95         this.triggerName = value;
96     }
97
98     /**
99      * @return some character data associated with the event / button name, '\0' if not applicable.
100      *         <br>example: typed keyboard character
101      */
102     public char getTriggerCharacter() {
103         return this.triggerCharacter;
104     }
105
106     /**
107      * @see #getTriggerCharacter
108      */
109     private char triggerCharacter;
110
111     /**
112      * @see #getTriggerCharacter
113      *
114      * @param value new value
115      */
116     public void setTriggerCharacter( final char value ) {
117         this.triggerCharacter = value;
118     }
119
120
121     /**
122      * name of the device that triggered this event, null if not applicable
123      *
124      * @return current value of field axisName
125      */
126     public String getTriggerDevice() {
127         return this.triggerDevice;
128     }
129
130     /**
131      * @see #getTriggerDevice()
132      */
133     private String triggerDevice;
134
135     /**
136      * @see #getTriggerDevice()
137      *
138      * @param value new value
139      */
140     public void setTriggerDevice( final String value ) {
141         this.triggerDevice = value;
142     }
143
144     /**
145      * @return index of the device part that caused the event, -1 if not applicable
146      *         <br>example: mouse button index, joystick axis index
147      */
148     public int getTriggerIndex() {
149         return this.triggerIndex;
150     }
151
152     /**
153      * @see #getTriggerIndex
154      */
155     private int triggerIndex;
156
157     /**
158      * @see #getTriggerIndex
159      *
160      * @param value new value
161      */
162     public void setTriggerIndex( final int value ) {
163         this.triggerIndex = value;
164     }
165
166
167     /**
168      * @return new position of the device part that caused the event, default 0, range [-1;1]
169      *         <br>example: joystick axis position
170      */
171     public float getTriggerPosition() {
172         return this.triggerPosition;
173     }
174
175     /**
176      * @see #getTriggerPosition
177      */
178     private float triggerPosition;
179
180     /**
181      * @see #getTriggerPosition
182      *
183      * @param value new value
184      */
185     public void setTriggerPosition( final float value ) {
186         this.triggerPosition = value;
187     }
188
189
190     /**
191      * @return position delta of the device part that caused the event, default 0, range [-1;1]
192      *         <br>example: joystick axis delta
193      */
194     public float getTriggerDelta() {
195         return this.triggerDelta;
196     }
197
198     /**
199      * @see #getTriggerDelta
200      */
201     private float triggerDelta;
202
203     /**
204      * @see #getTriggerDelta
205      *
206      * @param value new value
207      */
208     public void setTriggerDelta( final float value ) {
209         this.triggerDelta = value;
210     }
211
212
213     /**
214      * @return true if a button was pressed, false if released, default: false
215      *         <br>example: true if joystick button is pressed, false if joystick button is released
216      */
217     public boolean getTriggerPressed() {
218         return this.triggerPressed;
219     }
220
221     /**
222      * @see #getTriggerPressed
223      */
224     private boolean triggerPressed;
225
226     /**
227      * @see #getTriggerPressed
228      *
229      * @param value new value
230      */
231     public void setTriggerPressed( final boolean value ) {
232         this.triggerPressed = value;
233     }
234
235
236     /**
237      * @return true if the trigger that caused the event allows repeats
238      * @see com.jme.input.InputHandler#addAction(InputActionInterface,String,int,int,boolean)
239      */
240     public boolean getTriggerAllowsRepeats() {
241         return this.triggerAllowsRepeats;
242     }
243
244     /**
245      * @see #getTriggerAllowsRepeats()
246      */
247     private boolean triggerAllowsRepeats;
248
249     /**
250      * @see #getTriggerAllowsRepeats()
251      *
252      * @param value new value
253      */
254     public void setTriggerAllowsRepeats( final boolean value ) {
255             this.triggerAllowsRepeats = value;
256     }
257
258     /**
259      * @return some data data associated with the event, null if not applicable.
260      */
261     public Object getTriggerData() {
262         return this.triggerData;
263     }
264
265     /**
266      * @see #getTriggerData
267      */
268     private Object triggerData;
269
270     /**
271      * @see #getTriggerData
272      *
273      * @param value new value
274      */
275     public void setTriggerData( final Object value ) {
276         this.triggerData = value;
277     }
278 }