Unity XR InputDevice - Tracker

Refer to Wave XR Plugin Packages about VIVE Wave™ XR plugin packages.

The XRSDK package provides the Wave.OpenXR.InputDeviceTracker interface to access the Tracker Unity XR InputDevice.

InputDeviceTracker Public Types

To access InputDeviceTracker, you have to import the XRSDK package and use the Wave.OpenXR namespace.

The InputDeviceTracker class provides API to access the Tracker InputDevice data.

TrackerId

public enum TrackerId
{
    Tracker0 = 0,
    Tracker1 = 1,
    Tracker2 = 2,
    Tracker3 = 3,
    Tracker4 = 4,
    Tracker5 = 5,
    Tracker6 = 6,
    Tracker7 = 7,
    Tracker8 = 8,
    Tracker9 = 9,
    Tracker10 = 10,
    Tracker11 = 11,
    Tracker12 = 12,
    Tracker13 = 13,
    Tracker14 = 14,
    Tracker15 = 15,
}

TrackerRole

public enum TrackerRole
{
    Undefined = 0,
    Standalone = 1,
    Pair1_Right = 2,
    Pair1_Left = 3,

    Shoulder_Right  = 32,
    Upper_Arm_Right = 33,
    Elbow_Right     = 34,
    Forearm_Right   = 35,
    Wrist_Right     = 36,
    Hand_Right      = 37,
    Thigh_Right     = 38,
    Knee_Right      = 39,
    Calf_Right      = 40,
    Ankle_Right     = 41,
    Foot_Right      = 42,

    Shoulder_Left   = 47,
    Upper_Arm_Left  = 48,
    Elbow_Left      = 49,
    Forearm_Left    = 50,
    Wrist_Left      = 51,
    Hand_Left       = 52,
    Thigh_Left      = 53,
    Knee_Left       = 54,
    Calf_Left       = 55,
    Ankle_Left      = 56,
    Foot_Left       = 57,

    Chest = 62,
    Waist = 63,

    Camera = 71,
    Keyboard = 72,
}

Note

The TrackerId is unique and different trackers must have different IDs. The TrackerRole is NOT unique and different trackers may have the same role.

InputDeviceTracker Public Memeber Functions

ActivateTracker

Activates/deactivates the Tracker.

void ActivateTracker(bool active)

IsTrackerDevice

Checks if an InputDevice is a Wave Tracker component.

bool IsTrackerDevice(InputDevice input, TrackerId trackerId)

IsAvailable

Checks if a Tracker is connected.

bool IsAvailable(TrackerId trackerId)

IsTracked

Checks if a Tracker is tracked. Only a tracked Tracker has valid poses.

bool IsTracked(TrackerId trackerId)

GetTrackingState

Retrieves the InputTrackingState of a tracker’s pose.

bool GetTrackingState(TrackerId trackerId, out InputTrackingState state)

GetPosition

Retrieves a Tracker’s position.

bool GetPosition(TrackerId trackerId, out Vector3 position)

GetRotation

Retrieves a Tracker’s rotation.

bool GetRotation(TrackerId trackerId, out Quaternion rotation)

GetVelocity

Retrieves a Tracker’s velocity.

bool GetVelocity(TrackerId`_ trackerId, out Vector3 velocity)

GetAngularVelocity

Retrieves a Tracker’s angular velocity in Vector3 which represents the degree per second of (pitch, yaw, roll).

bool GetAngularVelocity(TrackerId`_ trackerId, out Vector3 angularVelocity)

GetAcceleration

Retrieves a Tracker’s acceleration.

bool GetAcceleration(TrackerId`_ trackerId, out Vector3 acceleration)

GetAngularAcceleration

Retrieves a Tracker’s angular acceleration in Vector3 which represents the degree per square second of (pitch, yaw, roll).

bool GetAngularAcceleration(TrackerId`_ trackerId, out Vector3 angularAcceleration)

GetRole

Retrieves a Tracker’s role.

TrackerRole GetRole(TrackerId trackerId)

ButtonDown

Checks if a Tracker’s button is pressed.

bool ButtonDown(TrackerId trackerId, InputFeatureUsage <bool> button, out bool down)

// Sample code: checks if the primary button of Tracker0 is pressed.
if (InputDeviceTracker.ButtonDown(InputDeviceTracker.TrackerId.Tracker0, CommonUsages.primaryButton, out bool value))
{
    bool primaryPressed = value;
}

ButtonAxis (Axis1D)

Retrieves a Tracker’s Axis1D button’s axis.

bool ButtonAxis(TrackerId trackerId, InputFeatureUsage <float> button, out float axis)

ButtonAxis (Axis2D)

Retrieves a Tracker’s Axis2D button’s axis.

bool ButtonAxis(TrackerId trackerId, InputFeatureUsage <Vector2> button, out Vector2 axis)

BatteryLevel

Retrieves a Tracker’s battery life in float (0~1).

bool BatteryLevel(TrackerId trackerId, out float level)

HapticPulse

Triggers a haptic pulse (vibration) in microsecond.

bool HapticPulse(TrackerId trackerId, UInt32 durationMicroSec = 500000, UInt32 frequency = 0, float amplitude = 0.5f)

GetTrackerDeviceName

Retrieves a tracker’s device name.

For Wrist Tracker: the device name will be “Vive_Tracker_Wrist” or “Vive_Wrist_Tracker”.

For Ultimate Tracker: the device name will be “Vive_Tracker_OT”, “Vive_Self_Tracker” or “Vive_Ultimate_Tracker”.

bool GetTrackerDeviceName(TrackerId trackerId, out string trackerName)