Version: 2018.4
Input for Windows Mixed Reality
Input for Oculus

Input for OpenVR controllers

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:

  • HTC Vive
  • OculusA VR platform for making applications for Rift and mobile VR devices. More info
    See in Glossary
    Touch
  • Valve Index

Note: Unity doesn’t support individual finger tracking information for Valve Index controllers.

Naming convention and detection

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.

Steam VR status menu
Steam VR status menu

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.

Unity input system mappings

This section provides mapping information for each type of controller that OpenVR devices supports.

HTC Vive controllers

The diagram below displays the different inputs available on HTC Vive controllers for use in VR applications.

HTC Vive controller inputs mapping (Image courtesy of developer.viveport.com)
HTC Vive controller inputs mapping (Image courtesy of developer.viveport.com)
1 Menu Button
2 Trackpad
3 System button
4 Status light
5 Micro-USB port
6 Tracking sensor
7 Trigger
8 Grip button

Oculus Touch controllers

The diagram below displays the different inputs available on Oculus Touch controllers for use in VR applications.

Oculus Touch controller input mapping (Image courtesy of developer.oculus.com)
Oculus Touch controller input mapping (Image courtesy of developer.oculus.com)

Valve Index controllers

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

Important controller differences

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 Event SystemA way of sending events to objects in the application based on input, be it keyboard, mouse, touch, or custom input. The Event System consists of a few components that work together to send events. More info
    See in Glossary
    generates Input Touch events for the triggers on HTC Vive controllers when the user begins squeezing the trigger.
  • The Event System generates Input Touch events for the triggers on Oculus Touch and Valve Index controllers when Unity Input detects a touch - no trigger squeeze is necessary.

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).

Input for Windows Mixed Reality
Input for Oculus
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961