Unity represents VR controller inputs as separate joysticks. Use the UnityEngine.Input class to access button and axis values. The OpenVR Unity integration doesn’t refer to any specific hardware when presenting axis and button states.
This page provides the axis and button mappings for the three types of controllers supported by OpenVR:
Note: Unity doesn’t support individual finger tracking information for Valve Index controllers.
When properly configured and connected, any OpenVR-compatible controllers are internally named as either OpenVR Controller - Left or OpenVR Controller - Right. Access this name through the list returned by UnityEngine.Input.GetJoystickNames(). When available, these controllers appear highlighted in green in the SteamVR status menu when tested with Steam. To access this menu you must have both Steam and SteamVR installed and running on your machine.
You can test the availability of these controllers by periodically checking for their presence in the list of joystick names through script. When the controllers turn off, or when you remove their batteries, an empty string replaces their name in the list returned by UnityEngine.Input.GetJoystickNames(). When the controllers turn on again, their name reappears in the list of returned joysticks.
This section provides mapping information for each type of controller that OpenVR devices supports.
The diagram below displays the different inputs available on HTC Vive controllers for use in VR applications.
The diagram below displays the different inputs available on Oculus Touch controllers for use in VR applications.
The table below lists controller inputs for each OpenVR-supported controller, their interaction types, Unity axis and button IDs, along with the value range for each axis.
|HTC Vive Controller||Oculus Touch Controller||Valve Index Controller||Interaction Type||Unity Button ID||Unity Axis ID||Unity Axis Value Range|
|Left Controller Menu Button (1)||Button.Three||Left Controller Inner Face Button||Press||2|
|Right Controller Menu Button (1)||Button.One||Right Controller Inner Face Button||Press||0|
|Left Controller Outer Face Button||Press||3|
|Right Controller Outer Face Button||Press||1|
|Left Controller Trackpad (2)||Button.PrimaryThumbstick||Left Controller Trackpad||Press||8|
|Right Controller Trackpad (2)||Button.SecondaryThumbstick||Right Controller Trackpad||Press||9|
|Left Controller Trackpad (2)||Button.PrimaryThumbstick||Left Controller Trackpad||Touch||16|
|Right Controller Trackpad (2)||Button.SecondaryThumbstick||Right Controller Trackpad||Touch||17|
|Left Controller Trackpad (2)||Axis2D.PrimaryThumbstick||Left Controller Trackpad||Horizontal Movement||1||–1.0 to 1.0|
|Left Controller Trackpad (2)||Axis2D.PrimaryThumbstick||Left Controller Trackpad||Vertical Movement||2||–1.0 to 1.0|
|Right Controller Trackpad (2)||Axis2D.SecondaryThumbstick||Right Controller Trackpad||Horizontal Movement||4||–1.0 to 1.0|
|Right Controller Trackpad (2)||Axis2D.SecondaryThumbstick||Right Controller Trackpad||Vertical Movement||5||–1.0 to 1.0|
|Left Controller Trigger (7)||Axis1D.PrimaryIndexTrigger||Left Controller Trigger||Touch||14|
|Right Controller Trigger (7)||Axis1D.SecondaryIndexTrigger||Right Controller Trigger||Touch||15|
|Left Controller Trigger (7)||Axis1D.PrimaryIndexTrigger||Left Controller Trigger||Squeeze||9||0.0 to 1.0|
|Right Controller Trigger (7)||Axis1D.SecondaryIndexTrigger||Right Controller Trigger||Squeeze||10||0.0 to 1.0|
|Left Controller Grip Button (8)||Axis1D.PrimaryHandTrigger||Left Controller Grip Average||Squeeze||11||0.0 to 1.0|
|Right Controller Grip Button (8)||Axis1D.SecondaryHandTrigger||Right Controller Grip Average||Squeeze||12||0.0 to 1.0|
When developing applications to support OpenVR devices, it is important to note certain differences in input event triggers and response rates for buttons on all three controllers.
Unity Touch Input events differ for each platform controller:
The grip trigger differs between HTC Vive and Oculus Touch controllers as follows:
The HTC Vive controllers each have two grip buttons but both map to the same axis. The value for these buttons is 0.0 when not pressed and 1.0 when pressed (intermediate values between 0.0 and 1.0 are not possible).
The grip on the Oculus Touch Controller is an analog trigger with a range from 0.0 to 1.0 (intermediate values are possible).
Did you find this page useful? Please give it a rating: