Skip to main content
Version: 2.2.0

Haply::Inverse::Unity::DeviceMapper

The DeviceMapper class manages the discovery, mapping, and state management of Haply devices within the Unity environment. More...

Inherits from Haply.Inverse.Unity.Utilities.Singleton< DeviceMapper >, MonoBehaviour

Public Types

Name
enum classDeviceInfoPollingMode { Manual, Once, Continuous}

Public Events

Name
StateDelegateStateChanged()
Event triggered when the state changes.
Action< DeviceMapperState, DeviceMapperState >StateChangedAsync()
Unity event triggered after state changes have been processed.

Public Functions

Name
delegate voidStateDelegate(DeviceMapperState state, DeviceMapperState previous)
Delegate for handling state changes.
IEnumerable< Inverse3 >GetInverse3Devices(HandednessType handedness =HandednessType.Nil)
Retrieves a collection of Inverse3 devices filtered by the specified handedness.
IEnumerable< VerseGrip >GetVerseGripDevices(HandednessType handedness =HandednessType.Nil)
Retrieves a collection of VerseGrip devices associated with Inverse3 devices that match the specified handedness.
Inverse3GetInverse3(uint id)
Retrieves the Inverse3 device that matches the given unique device ID.
Inverse3GetInverse3(HandednessType handedness =HandednessType.Nil)
Retrieves the first Inverse3 device that matches the specified handedness.
Inverse3GetInverse3(VerseGrip verseGrip)
Retrieves the Inverse3 device associated with a given VerseGrip device.
VerseGripGetVerseGrip(uint id)
Retrieves the VerseGrip device that matches the given unique device ID.
VerseGripGetVerseGrip(HandednessType handedness =HandednessType.Nil)
Retrieves the first VerseGrip device that matches the specified handedness.
VerseGripGetVerseGrip(Inverse3 inverse3)
Retrieves the VerseGrip device associated with a specified Inverse3 device.
GameObjectGetDeviceGameObject(uint id)
Retrieves the GameObject associated with a mapped device, either Inverse3 or VerseGrip, using the specified device ID.
override stringToString()

Protected Functions

Name
virtual override voidAwake()
virtual override voidOnEnable()
virtual override voidOnDisable()
virtual override voidUpdate()
virtual override voidOnDestroy()

Public Properties

Name
boolIsReady
Checks if the device mapper is in the 'Ready' state.
DeviceMapperStateState
Gets or sets the current state of the device mapper.
ClientConnectionClientConnection

Public Attributes

Name
UnityEventReady
Unity event triggered when the device mapper is ready.
DeviceInfoPollingModedevicesInfoPollingMode
Specifies the mode for polling device information.
floatdevicesInfoPollDelay
The frequency, in seconds, at which device information is automatically polled.

Additional inherited members

Public Functions inherited from Haply.Inverse.Unity.Utilities.Singleton< DeviceMapper >

Name
boolExists()

Protected Functions inherited from Haply.Inverse.Unity.Utilities.Singleton< DeviceMapper >

Name
virtual voidOnApplicationQuit()

Public Properties inherited from Haply.Inverse.Unity.Utilities.Singleton< DeviceMapper >

Name
TInstance
Gets the instance of the singleton class.

Protected Properties inherited from Haply.Inverse.Unity.Utilities.Singleton< DeviceMapper >

Name
boolApplicationIsQuitting

Detailed Description

class Haply::Inverse::Unity::DeviceMapper;

The DeviceMapper class manages the discovery, mapping, and state management of Haply devices within the Unity environment.

It coordinates the interaction between software and physical devices, allowing dynamic control and configuration based on runtime conditions. This class automatically initializes devices mapping when the component is enabled, based on pre-configured filters such as SelectedId and SelectedHandedness.

The initialization process can be delayed by disabling the component at start, allowing for runtime configuration changes before enabling the component to initialize devices mapping.

Public Types Documentation

enum DeviceInfoPollingMode

EnumeratorValueDescription
ManualDisables automatic device information polling.
OncePolls device information once immediately after the device is opened.
ContinuousContinuously polls device information at a frequency defined by devicesInfoPollDelay.

Public Events Documentation

event StateChanged

StateDelegate StateChanged()

Event triggered when the state changes.

event StateChangedAsync

Action< DeviceMapperState, DeviceMapperState > StateChangedAsync()

Unity event triggered after state changes have been processed.

Public Functions Documentation

function StateDelegate

delegate void StateDelegate(
DeviceMapperState state,
DeviceMapperState previous
)

Delegate for handling state changes.

function GetInverse3Devices

IEnumerable< Inverse3 > GetInverse3Devices(
HandednessType handedness =HandednessType.Nil
)

Retrieves a collection of Inverse3 devices filtered by the specified handedness.

Parameters:

  • handedness The handedness to filter the devices by, or Nil to return all devices.

Return: An enumerable collection of Inverse3 devices matching the handedness criteria, ordered first by whether they are ready, and then by their connection state (descending order).

function GetVerseGripDevices

IEnumerable< VerseGrip > GetVerseGripDevices(
HandednessType handedness =HandednessType.Nil
)

Retrieves a collection of VerseGrip devices associated with Inverse3 devices that match the specified handedness.

Parameters:

  • handedness The handedness to filter the devices by, or Nil to include all devices.

Return: An enumerable collection of VerseGrip devices whose corresponding Inverse3 devices match the handedness criteria, ordered first by whether they are ready, and then by their connection state (descending order).

function GetInverse3

Inverse3 GetInverse3(
uint id
)

Retrieves the Inverse3 device that matches the given unique device ID.

Parameters:

  • id The unique identifier for the Inverse3 device.

Return: The Inverse3 device if found; otherwise, null.

function GetInverse3

Inverse3 GetInverse3(
HandednessType handedness =HandednessType.Nil
)

Retrieves the first Inverse3 device that matches the specified handedness.

Parameters:

  • handedness The handedness type to match against the devices. If not specified, defaults to HandednessType.Nil, which means no specific handedness filter is applied.

Return: The first matching Inverse3 device if found; otherwise, null.

The devices are prioritized and ordered first by their readiness and then by their connection state (descending order).

function GetInverse3

Inverse3 GetInverse3(
VerseGrip verseGrip
)

Retrieves the Inverse3 device associated with a given VerseGrip device.

Parameters:

  • verseGrip The VerseGrip device whose associated Inverse3 device is to be retrieved.

Return: The Inverse3 device linked to the specified VerseGrip; otherwise, null if no link exists.

function GetVerseGrip

VerseGrip GetVerseGrip(
uint id
)

Retrieves the VerseGrip device that matches the given unique device ID.

Parameters:

  • id The unique identifier for the VerseGrip device.

Return: The VerseGrip device if found; otherwise, null.

function GetVerseGrip

VerseGrip GetVerseGrip(
HandednessType handedness =HandednessType.Nil
)

Retrieves the first VerseGrip device that matches the specified handedness.

Parameters:

  • handedness The handedness type to match against the devices. If not specified, defaults to HandednessType.Nil, which means no specific handedness filter is applied.

Return: The first matching Inverse3 device if found; otherwise, null.

The devices are prioritized and ordered first by their readiness and then by their connection state (descending order).

function GetVerseGrip

VerseGrip GetVerseGrip(
Inverse3 inverse3
)

Retrieves the VerseGrip device associated with a specified Inverse3 device.

Parameters:

Return: The VerseGrip device linked to the specified Inverse3; otherwise, null if no link exists.

function GetDeviceGameObject

GameObject GetDeviceGameObject(
uint id
)

Retrieves the GameObject associated with a mapped device, either Inverse3 or VerseGrip, using the specified device ID.

Parameters:

  • id The unique identifier for the device.

Return: The GameObject associated with the mapped device if found; otherwise, null.

function ToString

override string ToString()

Protected Functions Documentation

function Awake

virtual override void Awake()

Reimplements: Haply::Inverse::Unity::Utilities::Singleton::Awake

function OnEnable

virtual override void OnEnable()

Reimplements: Haply::Inverse::Unity::Utilities::Singleton::OnEnable

function OnDisable

virtual override void OnDisable()

Reimplements: Haply::Inverse::Unity::Utilities::Singleton::OnDisable

function Update

virtual override void Update()

Reimplements: Haply::Inverse::Unity::Utilities::Singleton::Update

function OnDestroy

virtual override void OnDestroy()

Reimplements: Haply::Inverse::Unity::Utilities::Singleton::OnDestroy

Public Property Documentation

property IsReady

bool IsReady;

Checks if the device mapper is in the 'Ready' state.

property State

DeviceMapperState State;

Gets or sets the current state of the device mapper.

property ClientConnection

ClientConnection ClientConnection;

Public Attributes Documentation

variable Ready

UnityEvent Ready;

Unity event triggered when the device mapper is ready.

variable devicesInfoPollingMode

DeviceInfoPollingMode devicesInfoPollingMode = DeviceInfoPollingMode.Once;

Specifies the mode for polling device information.

variable devicesInfoPollDelay

float devicesInfoPollDelay = DEFAULT_INFO_POLL_DELAY;

The frequency, in seconds, at which device information is automatically polled.

Lower values may cause haptic jitter and performance degradation.