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,
}

TrackerRole

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

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)

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)

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)