Skip to main content

Controller Mapping using OpenXR

Buttons and Triggers:

Return bool values.

CommonUsages.primaryButton: Typically the primary button (e.g., the "A" or "X" button on many VR controllers).

CommonUsages.secondaryButton: Typically the secondary button (e.g., the "B" or "Y" button on many VR controllers).

CommonUsages.gripButton: The grip button (used for gripping an object in VR).

CommonUsages.primaryTouch: Touch state of the primary button (e.g., a touchpad or button).

CommonUsages.secondaryTouch: Touch state of the secondary button.

CommonUsages.menuButton: The menu button on the controller, typically used to open the VR menu.

Thumbsticks and Joysticks:

Return Vector2 axis value.

CommonUsages.primary2DAxis: The 2D axis of the primary thumbstick (typically a joystick).

CommonUsages.secondary2DAxis: The 2D axis of the secondary thumbstick.

CommonUsages.primary2DAxisClick: The click state of the primary thumbstick (usually a press of the thumbstick).

CommonUsages.secondary2DAxisClick: The click state of the secondary thumbstick.

Haptic Feedback:

CommonUsages.haptic: General haptic feedback capability.

CommonUsages.hapticCapabilities: Information about the haptic feedback capabilities of a device.

Motion Sensors:

CommonUsages.devicePosition: The position of the input device in 3D space.

CommonUsages.deviceRotation: The rotation of the input device in 3D space.

CommonUsages.deviceVelocity: The velocity of the input device in 3D space.

CommonUsages.deviceAngularVelocity: The angular velocity of the input device.

Accelerometer and Gyroscope:

CommonUsages.acceleration: The accelerometer reading (x, y, z values of acceleration).

CommonUsages.angularAcceleration: The angular acceleration reading from the device's accelerometer.

CommonUsages.gyroscope: The gyroscope reading (rotation around the x, y, and z axes).

Hand and Finger Tracking (if supported by the device):

CommonUsages.leftHand: Information related to the left hand (for hand-tracking-enabled devices).

CommonUsages.rightHand: Information related to the right hand.

CommonUsages.indexFinger: Information about the index finger.

CommonUsages.thumb: Information about the thumb.

Additional Usages:

CommonUsages.trigger: The trigger value (could be a 1D axis, usually for trigger buttons).

CommonUsages.secondaryTrigger: The secondary trigger value (another button, typically used in some controllers).

CommonUsages.button1 to CommonUsages.button16: Additional generic button states (often useful for custom controllers or more complex devices).

Example Usage

  1. Initialize InputDevice variable:
using UnityEngine.XR;

private InputDevice rightHandDevice;
  1. Get the right device and value:
functionA()
// ensure it's valid
if (!rightHandDevice.isValid) {
rightHandDevice = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
}

// get the index trigger value
if (rightHandDevice.TryGetFeatureValue(CommonUsages.triggerButton, out bool triggerValue))
{
Debug.Log("Right hand trigger value: " + triggerValue);
}