Version: 5.5
Oculus の入力
モバイル端末の入力

Input for OpenVR controllers

To facilitate Unity Editor native support for tracked controllers supported by OpenVR, the Unity VR subsystem presents VR controller inputs as separate joysticks. You can access their axis and button values with the UnityEngine.Input class.

By using OpenVR’s controller abstraction, the Unity Editor presents axis and button states in a hardware-agnostic approach (that is, it doesn’t refer to any specific hardware, but uses generic terms). However, for the sake of clarity, the axis and button mappings given below are for the two supported controller types: the HTC Vive controllers, and the Oculus Touch Controllers.

名前のきまりと検出

When properly configured and connected, a pair of Oculus Touch Controllers or a pair of HTC Vive controllers appear in the list returned by UnityEngine.Input.GetJoystickNames() as OpenVR Controller - Left and OpenVR Controller - Right. When available, these controllers appear highlighted in green in the SteamVR status window.

Unity script code can test for the availability of these controllers by periodically checking for their presence in the list of joystick names. When the controllers are turned off or have their batteries removed, an empty string replaces their name in the list returned by UnityEngine.Input.GetJoystickNames(). When the controllers are turned on again, their name appears in the list of returned joysticks.

Unity Input system mappings

Diagram of Vive controllers

(Image courtesy of developer.viveport.com)
(Image courtesy of developer.viveport.com)

Diagram of Oculus Touch Controllers

(Image courtesy of developer.oculus.com)
(Image courtesy of developer.oculus.com)
Vive Controller Hardware Feature Touch Controller Hardware Feature 操作 Unity Button ID Unity Axis ID Unity Axis 値の範囲
Left Controller Menu Button (1) Button.Three 押す 2
Right Controller Menu Button (1) Button.One 押す 0
Left Controller Trackpad (2) Button.PrimaryThumbstick 押す 8
Right Controller Trackpad (2) Button.SecondaryThumbstick 押す 9
Left Controller Trackpad (2) Button.PrimaryThumbstick 接触 16
Right Controller Trackpad (2) Button.SecondaryThumbstick 接触 17
Left Controller Trackpad (2) Axis2D.PrimaryThumbstick 水平移動 1 –1.0 から 1.0
Left Controller Trackpad (2) Axis2D.PrimaryThumbstick 垂直移動 2 –1.0 から 1.0
Right Controller Trackpad (2) Axis2D.SecondaryThumbstick 水平移動 4 –1.0 から 1.0
Right Controller Trackpad (2) Axis2D.SecondaryThumbstick 垂直移動 5 –1.0 から 1.0
Left Controller Trigger (7) Axis1D.PrimaryIndexTrigger 接触 14
Right Controller Trigger (7) Axis1D.SecondaryIndexTrigger 接触 15
Left Controller Trigger (7) Axis1D.PrimaryIndexTrigger 握る 9 0.0 から 1.0
Right Controller Trigger (7) Axis1D.SecondaryIndexTrigger 握る 10 0.0 から 1.0
Left Controller Grip Button (8) Axis1D.PrimaryHandTrigger 握る 11 0.0 から 1.0
Right Controller Grip Button (8) Axis1D.SecondaryHandTrigger 握る 12 0.0 から 1.0

注意

  • Touch events differ between platforms:
    • Touch events related to the HTC Vive controller’s trigger are only generated once the user begins squeezing the trigger.
    • Touch events on the Oculus Touch’s trigger occur when a touch is detected - no squeeze is necessary.
  • The grip trigger differs between platforms:
    • The HTC Vive controller has grip buttons on either side but both map to the same axis. The value is 0.0 when not pressed and 1.0 when pressed with no intermediate values possible.
    • The grip on the Oculus Touch Controller is an analog trigger with a range from 0.0 to 1.0.
  • Any hardware features not listed in the table above are not exposed through the OpenVR API and are therefore not exposed through Unity’s input system.
Oculus の入力
モバイル端末の入力