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 class | DeviceInfoPollingMode { Manual, Once, Continuous} |
Public Events
Name | |
---|---|
StateDelegate | StateChanged() Event triggered when the state changes. |
Action< DeviceMapperState, DeviceMapperState > | StateChangedAsync() Unity event triggered after state changes have been processed. |
Public Functions
Name | |
---|---|
delegate void | StateDelegate(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. |
Inverse3 | GetInverse3(uint id) Retrieves the Inverse3 device that matches the given unique device ID. |
Inverse3 | GetInverse3(HandednessType handedness =HandednessType.Nil) Retrieves the first Inverse3 device that matches the specified handedness. |
Inverse3 | GetInverse3(VerseGrip verseGrip) Retrieves the Inverse3 device associated with a given VerseGrip device. |
VerseGrip | GetVerseGrip(uint id) Retrieves the VerseGrip device that matches the given unique device ID. |
VerseGrip | GetVerseGrip(HandednessType handedness =HandednessType.Nil) Retrieves the first VerseGrip device that matches the specified handedness. |
VerseGrip | GetVerseGrip(Inverse3 inverse3) Retrieves the VerseGrip device associated with a specified Inverse3 device. |
GameObject | GetDeviceGameObject(uint id) Retrieves the GameObject associated with a mapped device, either Inverse3 or VerseGrip, using the specified device ID. |
override string | ToString() |
Protected Functions
Name | |
---|---|
virtual override void | Awake() |
virtual override void | OnEnable() |
virtual override void | OnDisable() |
virtual override void | Update() |
virtual override void | OnDestroy() |
Public Properties
Name | |
---|---|
bool | IsReady Checks if the device mapper is in the 'Ready' state. |
DeviceMapperState | State Gets or sets the current state of the device mapper. |
ClientConnection | ClientConnection |
Public Attributes
Name | |
---|---|
UnityEvent | Ready Unity event triggered when the device mapper is ready. |
DeviceInfoPollingMode | devicesInfoPollingMode Specifies the mode for polling device information. |
float | devicesInfoPollDelay 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 | |
---|---|
bool | Exists() |
Protected Functions inherited from Haply.Inverse.Unity.Utilities.Singleton< DeviceMapper >
Name | |
---|---|
virtual void | OnApplicationQuit() |
Public Properties inherited from Haply.Inverse.Unity.Utilities.Singleton< DeviceMapper >
Name | |
---|---|
T | Instance Gets the instance of the singleton class. |
Protected Properties inherited from Haply.Inverse.Unity.Utilities.Singleton< DeviceMapper >
Name | |
---|---|
bool | ApplicationIsQuitting |
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
Enumerator | Value | Description |
---|---|---|
Manual | Disables automatic device information polling. | |
Once | Polls device information once immediately after the device is opened. | |
Continuous | Continuously 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:
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.