Package com.jme3.input.vr.lwjgl_openvr
Class LWJGLOpenVRInput
java.lang.Object
com.jme3.input.vr.lwjgl_openvr.LWJGLOpenVRInput
- All Implemented Interfaces:
VRInputAPI
A class that wraps an
OpenVR
input.
null
values will be returned if no valid pose exists, or that
input device isn't available user code should check for null
values.-
Constructor Summary
ConstructorDescriptionLWJGLOpenVRInput
(VREnvironment environment) Create a new OpenVR input attached to the given VR environment. -
Method Summary
Modifier and TypeMethodDescriptiongetAnalogActionState
(String actionName, String restrictToInput) Gets the current state of the action (abstract version of a button press).getAngularVelocity
(int controllerIndex) Get the controller angular velocity on all axes.getAxis
(int controllerIndex, VRInputType forAxis) Get the axis value for the given input on the given controller.getAxisDeltaSinceLastCall
(int controllerIndex, VRInputType forAxis) Get the controller axis delta from the last value.float
Get the controller axis multiplier.getAxisRaw
(int controllerIndex, VRInputType forAxis) Get the axis value for the given input on the given controller.getDigitalActionState
(String actionName, String restrictToInput) Gets the current state of the action (abstract version of a button press).getFinalObserverPosition
(int index) Get the position of the input after all positional tracking is complete.getFinalObserverRotation
(int index) Get where is the controller pointing, after all rotations are combined.long
getOrFetchInputHandle
(String inputName) Given an input name returns the handle to address it.getOrientation
(int index) Get the orientation of the input.getPosition
(int index) Get the position of the input.org.lwjgl.openvr.VRControllerState
getRawControllerState
(int index) Get the native wrapping of a controller state.getTrackedController
(int index) Get a tracked controller (for example, a hand controller) that is attached to the VR system.int
Get the number of tracked controllers (for example, hand controllers) attached to the VR system.getVelocity
(int controllerIndex) Get the controller velocity on all axes.boolean
init()
Initialize the input.boolean
isButtonDown
(int controllerIndex, VRInputType checkButton) Check if the given button is down (more generally if the given input type is activated).boolean
isInputDeviceTracking
(int index) Check if the input device is actually tracked (i-e if we can obtain a pose from the input).boolean
Check if the VR system has the focus and if it's not used by other process.void
registerActionManifest
(String actionManifestAbsolutePath, String startingActiveActionSets) Registers an action manifest.void
Reset the current activation of the inputs.void
setActiveActionSet
(String actionSet) Updates the active action set (the action group that will have their states available to be polled).void
setAxisMultiplier
(float set) Set the controller axis multiplier.void
Swap the two hands (exchange the hands' controller 1 and 2 indices).void
triggerHapticAction
(String actionName, float duration, float frequency, float amplitude, String restrictToInput) Triggers a haptic action (aka a vibration) restricted to just one input (e.g.void
triggerHapticPulse
(int controllerIndex, float seconds) Trigger a haptic pulse on the selected controller for the duration given in parameters (in seconds).void
Update the connected controllers.void
Update the controller states.boolean
wasButtonPressedSinceLastCall
(int controllerIndex, VRInputType checkButton) Check if the given button / input from the given controller has been just pressed / activated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.jme3.input.vr.VRInputAPI
getAnalogActionState, getDigitalActionState, triggerHapticAction
-
Constructor Details
-
LWJGLOpenVRInput
Create a new OpenVR input attached to the given VR environment.- Parameters:
environment
- the VR environment to which the input is attached.
-
-
Method Details
-
registerActionManifest
public void registerActionManifest(String actionManifestAbsolutePath, String startingActiveActionSets) Description copied from interface:VRInputAPI
Registers an action manifest. An actions manifest is a file that defines "actions" a player can make. (An action is an abstract version of a button press). The action manifest may then also include references to further files that define default mappings between those actions and physical buttons on the VR controllers. Note that registering an actions manifest will deactivate legacy inputs (i.e. methods such asVRInputAPI.isButtonDown(int, com.jme3.input.vr.VRInputType)
will no longer work See https://github.com/ValveSoftware/openvr/wiki/Action-manifest for documentation on how to create an action manifest This option is only relevant to OpenVR- Specified by:
registerActionManifest
in interfaceVRInputAPI
- Parameters:
actionManifestAbsolutePath
- the absolute file path to an actions manifeststartingActiveActionSets
- the actions in the manifest are divided into action sets (groups) by their prefix (e.g. "/actions/main"). These action sets can be turned off and on per frame. This argument sets the action set that will be active now. The active action sets can be later be changed by callingVRInputAPI.setActiveActionSet(java.lang.String)
. Note that at present only a single set at a time is supported
-
setActiveActionSet
Description copied from interface:VRInputAPI
Updates the active action set (the action group that will have their states available to be polled). Note that this update will not take effect until the next loop Note that at present only a single set at a time is supported- Specified by:
setActiveActionSet
in interfaceVRInputAPI
- Parameters:
actionSet
- the actions in the manifest are divided into action sets (groups) by their prefix (e.g. "/actions/main"). These action sets can be turned off and on per frame. This argument sets the action set that will be active now.
-
getDigitalActionState
Description copied from interface:VRInputAPI
Gets the current state of the action (abstract version of a button press). This is called for digital style actions (a button is pressed, or not) This method is commonly called when it is important which hand the action is found on. For example while holding a weapon a button may be bound to "eject magazine" to allow you to load a new one, but that would only want to take effect on the hand that is holding the weapon Note that restrictToInput only restricts, it must still be bound to the input you want to receive the input from in the action manifest default bindings.VRInputAPI.registerActionManifest(java.lang.String, java.lang.String)
must have been called before using this method.- Specified by:
getDigitalActionState
in interfaceVRInputAPI
- Parameters:
actionName
- The name of the action. E.g. /actions/main/in/openInventoryrestrictToInput
- the input to restrict the action to. E.g. /user/hand/right. Or null, which means "any input"- Returns:
- the DigitalActionState that has details on if the state has changed, what the state is etc.
-
getAnalogActionState
Description copied from interface:VRInputAPI
Gets the current state of the action (abstract version of a button press). This is called for analog style actions (most commonly joysticks, but button pressure can also be mapped in analog). This method is commonly called when it is important which hand the action is found on. For example an "in universe" joystick that has a hat control might (while you are holding it) bind to the on-controller hat, but only on the hand holding it Note that restrictToInput only restricts, it must still be bound to the input you want to receive the input from in the action manifest default bindings.VRInputAPI.registerActionManifest(java.lang.String, java.lang.String)
must have been called before using this method.- Specified by:
getAnalogActionState
in interfaceVRInputAPI
- Parameters:
actionName
- The name of the action. E.g. /actions/main/in/openInventoryrestrictToInput
- the input to restrict the action to. E.g. /user/hand/right. Or null, which means "any input"- Returns:
- the DigitalActionState that has details on if the state has changed, what the state is etc.
-
getAxisMultiplier
public float getAxisMultiplier()Description copied from interface:VRInputAPI
Get the controller axis multiplier. The controller axis raw data (trackpad, trigger, ...) value is multiplied by the one given in parameter.- Specified by:
getAxisMultiplier
in interfaceVRInputAPI
- Returns:
- the controller axis multiplier.
- See Also:
-
setAxisMultiplier
public void setAxisMultiplier(float set) Description copied from interface:VRInputAPI
Set the controller axis multiplier. The controller axis raw data (trackpad, trigger, ...) value is multiplied by the one given in parameter.- Specified by:
setAxisMultiplier
in interfaceVRInputAPI
- Parameters:
set
- the controller axis multiplier.- See Also:
-
swapHands
public void swapHands()Description copied from interface:VRInputAPI
Swap the two hands (exchange the hands' controller 1 and 2 indices).- Specified by:
swapHands
in interfaceVRInputAPI
-
isButtonDown
Description copied from interface:VRInputAPI
Check if the given button is down (more generally if the given input type is activated). Deprecated as should use an actions manifest approach. SeeVRInputAPI.registerActionManifest(java.lang.String, java.lang.String)
. Note; action based will only work with the OpenVR api- Specified by:
isButtonDown
in interfaceVRInputAPI
- Parameters:
controllerIndex
- the index of the controller to check.checkButton
- the button / input to check.- Returns:
true
if the button / input is down / activated andfalse
otherwise.
-
wasButtonPressedSinceLastCall
Description copied from interface:VRInputAPI
Check if the given button / input from the given controller has been just pressed / activated. Deprecated as should use an actions manifest approach. SeeVRInputAPI.registerActionManifest(java.lang.String, java.lang.String)
. Note; action based will only work with the OpenVR api- Specified by:
wasButtonPressedSinceLastCall
in interfaceVRInputAPI
- Parameters:
controllerIndex
- the index of the controller.checkButton
- the button / input to check.- Returns:
true
if the given button / input from the given controller has been just pressed / activated andfalse
otherwise.
-
resetInputSinceLastCall
public void resetInputSinceLastCall()Description copied from interface:VRInputAPI
Reset the current activation of the inputs. After a call to this method, all input activation is considered as new activation. -
getAxisDeltaSinceLastCall
Description copied from interface:VRInputAPI
Get the controller axis delta from the last value. Deprecated as should use an actions manifest approach. SeeVRInputAPI.registerActionManifest(java.lang.String, java.lang.String)
. Note; action based will only work with the OpenVR api- Specified by:
getAxisDeltaSinceLastCall
in interfaceVRInputAPI
- Parameters:
controllerIndex
- the index of the controller.forAxis
- the axis.- Returns:
- the controller axis delta from the last call.
-
getVelocity
Description copied from interface:VRInputAPI
Get the controller velocity on all axes.- Specified by:
getVelocity
in interfaceVRInputAPI
- Parameters:
controllerIndex
- the index of the controller.- Returns:
- the controller velocity on all axes.
- See Also:
-
getAngularVelocity
Description copied from interface:VRInputAPI
Get the controller angular velocity on all axes.- Specified by:
getAngularVelocity
in interfaceVRInputAPI
- Parameters:
controllerIndex
- the index of the controller.- Returns:
- the controller angular velocity on all axes.
- See Also:
-
getAxisRaw
Description copied from interface:VRInputAPI
Get the axis value for the given input on the given controller. Deprecated as should use an actions manifest approach. SeeVRInputAPI.registerActionManifest(java.lang.String, java.lang.String)
Note; action based will only work with the OpenVR api- Specified by:
getAxisRaw
in interfaceVRInputAPI
- Parameters:
controllerIndex
- the index of the controller.forAxis
- the axis.- Returns:
- the axis value for the given input on the given controller.
- See Also:
-
getAxis
Description copied from interface:VRInputAPI
Get the axis value for the given input on the given controller. This value is theraw value
multiplied by theaxis multiplier
. Deprecated as should use an actions manifest approach. SeeVRInputAPI.registerActionManifest(java.lang.String, java.lang.String)
. Note; action based will only work with the OpenVR api- Specified by:
getAxis
in interfaceVRInputAPI
- Parameters:
controllerIndex
- the index of the controller.forAxis
- the axis.- Returns:
- the axis value for the given input on the given controller.
- See Also:
-
init
public boolean init()Description copied from interface:VRInputAPI
Initialize the input.- Specified by:
init
in interfaceVRInputAPI
- Returns:
true
if the initialization is successful andfalse
otherwise.
-
getTrackedController
Description copied from interface:VRInputAPI
Get a tracked controller (for example, a hand controller) that is attached to the VR system.- Specified by:
getTrackedController
in interfaceVRInputAPI
- Parameters:
index
- the index of the controller.- Returns:
- the tracked controller (for example, a hand controller) that is attached to the VR system.
- See Also:
-
getTrackedControllerCount
public int getTrackedControllerCount()Description copied from interface:VRInputAPI
Get the number of tracked controllers (for example, hand controllers) attached to the VR system.- Specified by:
getTrackedControllerCount
in interfaceVRInputAPI
- Returns:
- the number of controllers attached to the VR system.
- See Also:
-
getRawControllerState
public org.lwjgl.openvr.VRControllerState getRawControllerState(int index) Description copied from interface:VRInputAPI
Get the native wrapping of a controller state.- Specified by:
getRawControllerState
in interfaceVRInputAPI
- Parameters:
index
- the index of the controller.- Returns:
- the native wrapping of a controller state.
-
isInputFocused
public boolean isInputFocused()Description copied from interface:VRInputAPI
Check if the VR system has the focus and if it's not used by other process.- Specified by:
isInputFocused
in interfaceVRInputAPI
- Returns:
true
if the VR system has the focus andfalse
otherwise.
-
isInputDeviceTracking
public boolean isInputDeviceTracking(int index) Description copied from interface:VRInputAPI
Check if the input device is actually tracked (i-e if we can obtain a pose from the input).- Specified by:
isInputDeviceTracking
in interfaceVRInputAPI
- Parameters:
index
- the index of the controller.- Returns:
true
if the input device is actually tracked andfalse
otherwise.
-
getOrientation
Description copied from interface:VRInputAPI
Get the orientation of the input.- Specified by:
getOrientation
in interfaceVRInputAPI
- Parameters:
index
- the index of the controller.- Returns:
- the orientation of the input.
-
getPosition
Description copied from interface:VRInputAPI
Get the position of the input.- Specified by:
getPosition
in interfaceVRInputAPI
- Parameters:
index
- the index of the controller.- Returns:
- the position of the input.
-
getFinalObserverRotation
Description copied from interface:VRInputAPI
Get where is the controller pointing, after all rotations are combined. This position should include observer rotation from the VR application.- Specified by:
getFinalObserverRotation
in interfaceVRInputAPI
- Parameters:
index
- the index of the controller.- Returns:
- the rotation of the input after all positional tracking is complete.
-
getFinalObserverPosition
Description copied from interface:VRInputAPI
Get the position of the input after all positional tracking is complete. This position should include observer position from the VR application.- Specified by:
getFinalObserverPosition
in interfaceVRInputAPI
- Parameters:
index
- the index of the controller.- Returns:
- the position of the input after all positional tracking is complete.
-
triggerHapticPulse
public void triggerHapticPulse(int controllerIndex, float seconds) Description copied from interface:VRInputAPI
Trigger a haptic pulse on the selected controller for the duration given in parameters (in seconds). Deprecated, use triggerHapticAction instead (as it has more options and doesn't use deprecated methods)- Specified by:
triggerHapticPulse
in interfaceVRInputAPI
- Parameters:
controllerIndex
- the index of the controller.seconds
- the duration of the pulse in seconds.
-
triggerHapticAction
public void triggerHapticAction(String actionName, float duration, float frequency, float amplitude, String restrictToInput) Description copied from interface:VRInputAPI
Triggers a haptic action (aka a vibration) restricted to just one input (e.g. left or right hand). Note that restrictToInput only restricts, it must still be bound to the input you want to send the haptic to in the action manifest default bindings. This method is typically used to bind the haptic to both hands then decide at run time which hand to sent to *- Specified by:
triggerHapticAction
in interfaceVRInputAPI
- Parameters:
actionName
- The name of the action. Will be something like /actions/main/out/vibrateduration
- how long in seconds thefrequency
- in cycles per secondamplitude
- between 0 and 1restrictToInput
- the input to restrict the action to. E.g. /user/hand/right, /user/hand/left. Or null, which means "any input"
-
updateConnectedControllers
public void updateConnectedControllers()Description copied from interface:VRInputAPI
Update the connected controllers. This method should be used just after the initialization of the input.- Specified by:
updateConnectedControllers
in interfaceVRInputAPI
-
updateControllerStates
public void updateControllerStates()Description copied from interface:VRInputAPI
Update the controller states. This method should be called before accessing any controller data.- Specified by:
updateControllerStates
in interfaceVRInputAPI
-
getOrFetchInputHandle
Given an input name returns the handle to address it. If a cached handle is available it is returned, if not it is fetched from openVr- Parameters:
inputName
- the input name, e.g. /user/hand/right. Or null, which means "any input"- Returns:
- the input handle
-