4
4
import com .jme3 .math .Vector2f ;
5
5
import com .jme3 .math .Vector3f ;
6
6
7
+ import java .util .Collection ;
8
+
7
9
/**
8
10
* An interface that represents a VR input (typically a VR device such as a controller).
9
11
* @author reden - phr00t - https://github.com/phr00t
10
12
* @author Julien Seinturier - COMEX SA - <a href="http://www.seinturier.fr">http://www.seinturier.fr</a>
11
13
*/
12
14
public interface VRInputAPI {
15
+
16
+ /**
17
+ * Registers an action manifest. An actions manifest is a file that defines "actions" a player can make.
18
+ * (An action is an abstract version of a button press). The action manifest may then also include references to
19
+ * further files that define default mappings between those actions and physical buttons on the VR controllers.
20
+ *
21
+ * Note that registering an actions manifest will deactivate legacy inputs (i.e. methods such as {@link #isButtonDown}
22
+ * will no longer work
23
+ *
24
+ * This option is only relevant to OpenVR
25
+ * @param actionManifestAbsolutePath
26
+ * the absolute file path to an actions manifest
27
+ * @param startingActiveActionSet
28
+ * the actions in the manifest are divided into action sets (groups) by their prefix (e.g. "/actions/main").
29
+ * These action sets can be turned off and on per frame. This argument sets the action set that will be
30
+ * active now. The active action sets can be later be changed by calling {@link #setActiveActionSet}.
31
+ * Note that at present only a single set at a time is supported
32
+ *
33
+ */
34
+ default void registerActionManifest ( String actionManifestAbsolutePath , String startingActiveActionSet ){
35
+ throw new UnsupportedOperationException ("Action manifests are not supported for the currently used VR API" );
36
+ }
37
+
38
+ /**
39
+ * Updates the active action set (the action group that will have their states available to be polled).
40
+ *
41
+ * Note that this update will not take effect until the next loop
42
+ * Note that at present only a single set at a time is supported
43
+ *
44
+ * @param activeActionSet
45
+ * the actions in the manifest are divided into action sets (groups) by their prefix (e.g. "/actions/main").
46
+ * These action sets can be turned off and on per frame. This argument sets the action set that will be
47
+ * active now.
48
+ */
49
+ default void setActiveActionSet ( String activeActionSet ){
50
+ throw new UnsupportedOperationException ("Action manifests are not supported for the currently used VR API" );
51
+ }
52
+
53
+ /**
54
+ * Gets the current state of the action (abstract version of a button press).
55
+ *
56
+ * This is called for digital style actions (a button is pressed, or not)
57
+ *
58
+ * This method is commonly called when it's not important which hand the action is bound to (e.g. if a button press
59
+ * is opening your inventory that could be bound to either left or right hand and that would not matter).
60
+ *
61
+ * If the handedness matters use {@link #getDigitalActionState(String, String)}
62
+ *
63
+ * {@link #registerActionManifest} must have been called before using this method.
64
+ *
65
+ * @param actionName The name of the action. Will be something like /actions/main/in/openInventory
66
+ * @return the DigitalActionState that has details on if the state has changed, what the state is etc.
67
+ */
68
+ default DigitalActionState getDigitalActionState ( String actionName ){
69
+ return getDigitalActionState (actionName , null );
70
+ }
71
+
72
+ /**
73
+ * Gets the current state of the action (abstract version of a button press).
74
+ *
75
+ * This is called for digital style actions (a button is pressed, or not)
76
+ *
77
+ * This method is commonly called when it is important which hand the action is found on. For example while
78
+ * holding a weapon a button may be bound to "eject magazine" to allow you to load a new one, but that would only
79
+ * want to take effect on the hand that is holding the weapon
80
+ *
81
+ * Note that restrictToInput only restricts, it must still be bound to the input you want to receive the input from in
82
+ * the action manifest default bindings.
83
+ *
84
+ * {@link #registerActionManifest} must have been called before using this method.
85
+ *
86
+ * @param actionName The name of the action. E.g. /actions/main/in/openInventory
87
+ * @param restrictToInput the input to restrict the action to. E.g. /user/hand/right. Or null, which means "any input"
88
+ * @return the DigitalActionState that has details on if the state has changed, what the state is etc.
89
+ */
90
+ default DigitalActionState getDigitalActionState ( String actionName , String restrictToInput ){
91
+ throw new UnsupportedOperationException ("Action manifests are not supported for the currently used VR API" );
92
+ }
93
+
94
+ /**
95
+ * Gets the current state of the action (abstract version of a button press).
96
+ *
97
+ * This is called for analog style actions (most commonly joysticks, but button pressure can also be mapped in analog).
98
+ *
99
+ * This method is commonly called when it's not important which hand the action is bound to (e.g. if the thumb stick
100
+ * is controlling a third-person character in-game that could be bound to either left or right hand and that would
101
+ * not matter).
102
+ *
103
+ * If the handedness matters use {@link #getAnalogActionState(String, String)}
104
+ *
105
+ * {@link #registerActionManifest} must have been called before using this method.
106
+ *
107
+ * @param actionName The name of the action. E.g. /actions/main/in/openInventory
108
+ * @return the DigitalActionState that has details on if the state has changed, what the state is etc.
109
+ */
110
+ default AnalogActionState getAnalogActionState ( String actionName ){
111
+ return getAnalogActionState (actionName , null );
112
+ }
113
+
114
+ /**
115
+ * Gets the current state of the action (abstract version of a button press).
116
+ *
117
+ * This is called for analog style actions (most commonly joysticks, but button pressure can also be mapped in analog).
118
+ *
119
+ * This method is commonly called when it is important which hand the action is found on. For example an "in universe"
120
+ * joystick that has a hat control might (while you are holding it) bind to the on-controller hat, but only on the hand
121
+ * holding it
122
+ *
123
+ * Note that restrictToInput only restricts, it must still be bound to the input you want to receive the input from in
124
+ * the action manifest default bindings.
125
+ *
126
+ * {@link #registerActionManifest} must have been called before using this method.
127
+ *
128
+ * @param actionName The name of the action. E.g. /actions/main/in/openInventory
129
+ * @param restrictToInput the input to restrict the action to. E.g. /user/hand/right. Or null, which means "any input"
130
+ * @return the DigitalActionState that has details on if the state has changed, what the state is etc.
131
+ */
132
+ default AnalogActionState getAnalogActionState ( String actionName , String restrictToInput ){
133
+ throw new UnsupportedOperationException ("Action manifests are not supported for the currently used VR API" );
134
+ }
135
+
13
136
/**
14
137
* Check if the given button is down (more generally if the given input type is activated).
138
+ *
139
+ * Deprecated as should use an actions manifest approach. See {@link #registerActionManifest}
140
+ *
15
141
* @param controllerIndex the index of the controller to check.
16
142
* @param checkButton the button / input to check.
17
143
* @return <code>true</code> if the button / input is down / activated and <code>false</code> otherwise.
18
144
*/
145
+ @ Deprecated
19
146
public boolean isButtonDown (int controllerIndex , VRInputType checkButton );
20
147
21
148
/**
22
149
* Check if the given button / input from the given controller has been just pressed / activated.
150
+ *
151
+ * Deprecated as should use an actions manifest approach. See {@link #registerActionManifest}
152
+ *
23
153
* @param controllerIndex the index of the controller.
24
154
* @param checkButton the button / input to check.
25
155
* @return <code>true</code> if the given button / input from the given controller has been just pressed / activated and <code>false</code> otherwise.
26
156
*/
157
+ @ Deprecated
27
158
public boolean wasButtonPressedSinceLastCall (int controllerIndex , VRInputType checkButton );
28
159
29
160
/**
30
161
* Reset the current activation of the inputs. After a call to this method, all input activation is considered as new activation.
31
162
* @see #wasButtonPressedSinceLastCall(int, VRInputType)
163
+ *
164
+ * Deprecated as should use an actions manifest approach. See {@link #registerActionManifest}
32
165
*/
166
+ @ Deprecated
33
167
public void resetInputSinceLastCall ();
34
168
35
169
/**
36
170
* Get the controller axis delta from the last value.
171
+ *
172
+ * Deprecated as should use an actions manifest approach. See {@link #registerActionManifest}
173
+ *
37
174
* @param controllerIndex the index of the controller.
38
175
* @param forAxis the axis.
39
176
* @return the controller axis delta from the last call.
40
177
*/
178
+ @ Deprecated
41
179
public Vector2f getAxisDeltaSinceLastCall (int controllerIndex , VRInputType forAxis );
42
180
43
181
/**
@@ -59,21 +197,29 @@ public interface VRInputAPI {
59
197
/**
60
198
* Get the axis value for the given input on the given controller.
61
199
* This value is the {@link #getAxisRaw(int, VRInputType) raw value} multiplied by the {@link #getAxisMultiplier() axis multiplier}.
200
+ *
201
+ * Deprecated as should use an actions manifest approach. See {@link #registerActionManifest}
202
+ *
62
203
* @param controllerIndex the index of the controller.
63
204
* @param forAxis the axis.
64
205
* @return the axis value for the given input on the given controller.
65
206
* @see #getAxisRaw(int, VRInputType)
66
207
* @see #getAxisMultiplier()
67
208
*/
209
+ @ Deprecated
68
210
public Vector2f getAxis (int controllerIndex , VRInputType forAxis );
69
211
70
212
/**
71
213
* Get the axis value for the given input on the given controller.
214
+ *
215
+ * Deprecated as should use an actions manifest approach. See {@link #registerActionManifest}
216
+ *
72
217
* @param controllerIndex the index of the controller.
73
218
* @param forAxis the axis.
74
219
* @return the axis value for the given input on the given controller.
75
220
* @see #getAxis(int, VRInputType)
76
221
*/
222
+ @ Deprecated
77
223
public Vector2f getAxisRaw (int controllerIndex , VRInputType forAxis );
78
224
79
225
/**
@@ -184,8 +330,46 @@ public interface VRInputAPI {
184
330
185
331
/**
186
332
* Trigger a haptic pulse on the selected controller for the duration given in parameters (in seconds).
333
+ *
334
+ * Deprecated, use triggerHapticAction instead (as it has more options and doesn't use deprecated methods)
335
+ *
187
336
* @param controllerIndex the index of the controller.
188
337
* @param seconds the duration of the pulse in seconds.
189
338
*/
339
+ @ Deprecated
190
340
public void triggerHapticPulse (int controllerIndex , float seconds );
341
+
342
+ /**
343
+ * Triggers a haptic action (aka a vibration).
344
+ *
345
+ * Note if you want a haptic action in only one hand that is done either by only binding the action to one hand in
346
+ * the action manifest's standard bindings or by binding to both and using {@link #triggerHapticAction(String, float, float, float, String)}
347
+ * to control which input it gets set to at run time
348
+ *
349
+ * @param actionName The name of the action. Will be something like /actions/main/out/vibrate
350
+ * @param duration how long in seconds the
351
+ * @param frequency in cycles per second
352
+ * @param amplitude between 0 and 1
353
+ */
354
+ default void triggerHapticAction ( String actionName , float duration , float frequency , float amplitude ){
355
+ triggerHapticAction ( actionName , duration , frequency , amplitude , null );
356
+ }
357
+
358
+ /**
359
+ * Triggers a haptic action (aka a vibration) restricted to just one input (e.g. left or right hand).
360
+ *
361
+ * Note that restrictToInput only restricts, it must still be bound to the input you want to send the haptic to in
362
+ * the action manifest default bindings.
363
+ *
364
+ * This method is typically used to bind the haptic to both hands then decide at run time which hand to sent to *
365
+ *
366
+ * @param actionName The name of the action. Will be something like /actions/main/out/vibrate
367
+ * @param duration how long in seconds the
368
+ * @param frequency in cycles per second
369
+ * @param amplitude between 0 and 1
370
+ * @param restrictToInput the input to restrict the action to. E.g. /user/hand/right. Or null, which means "any input"
371
+ */
372
+ default void triggerHapticAction ( String actionName , float duration , float frequency , float amplitude , String restrictToInput ){
373
+ throw new UnsupportedOperationException ("Action manifests are not supported for the currently used VR API" );
374
+ }
191
375
}
0 commit comments