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