mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-21 06:01:43 +00:00
u/system_helpers: Refactor hand-tracker helper getters
This commit is contained in:
parent
464a95abed
commit
08ec4e0259
|
@ -95,10 +95,10 @@ u_system_devices_create_from_prober(struct xrt_instance *xinst,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct xrt_device *
|
struct xrt_device *
|
||||||
u_system_devices_get_ht_device(struct u_system_devices *usysd, enum xrt_input_name name)
|
u_system_devices_get_ht_device(struct xrt_system_devices *xsysd, enum xrt_input_name name)
|
||||||
{
|
{
|
||||||
for (uint32_t i = 0; i < usysd->base.xdev_count; i++) {
|
for (uint32_t i = 0; i < xsysd->xdev_count; i++) {
|
||||||
struct xrt_device *xdev = usysd->base.xdevs[i];
|
struct xrt_device *xdev = xsysd->xdevs[i];
|
||||||
|
|
||||||
if (xdev == NULL || !xdev->hand_tracking_supported) {
|
if (xdev == NULL || !xdev->hand_tracking_supported) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -113,15 +113,40 @@ u_system_devices_create_from_prober(struct xrt_instance *xinst,
|
||||||
/*!
|
/*!
|
||||||
* Helper function.
|
* Helper function.
|
||||||
*
|
*
|
||||||
* Looks through @ref u_system_devices's devices and returns the first device that supports hand tracking and the
|
* Looks through @ref xrt_system_devices's devices and returns the first device
|
||||||
* supplied input name.
|
* that supports hand tracking and the supplied input name.
|
||||||
*
|
*
|
||||||
* Used by target_builder_lighthouse to find Knuckles controllers in the list of devices returned.
|
* Used by target_builder_lighthouse to find Knuckles controllers in the list of
|
||||||
|
* devices returned, the legacy builder to find hand tracking devices, etc.
|
||||||
*
|
*
|
||||||
* @ingroup aux_util
|
* @ingroup aux_util
|
||||||
*/
|
*/
|
||||||
struct xrt_device *
|
struct xrt_device *
|
||||||
u_system_devices_get_ht_device(struct u_system_devices *usysd, enum xrt_input_name name);
|
u_system_devices_get_ht_device(struct xrt_system_devices *xsysd, enum xrt_input_name name);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Helper to get the first left hand-tracking device,
|
||||||
|
* uses @ref u_system_devices_get_ht_device.
|
||||||
|
*
|
||||||
|
* @ingroup aux_util
|
||||||
|
*/
|
||||||
|
static inline struct xrt_device *
|
||||||
|
u_system_devices_get_ht_device_left(struct xrt_system_devices *xsysd)
|
||||||
|
{
|
||||||
|
return u_system_devices_get_ht_device(xsysd, XRT_INPUT_GENERIC_HAND_TRACKING_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Helper to get the first right hand-tracking device,
|
||||||
|
* uses @ref u_system_devices_get_ht_device.
|
||||||
|
*
|
||||||
|
* @ingroup aux_util
|
||||||
|
*/
|
||||||
|
static inline struct xrt_device *
|
||||||
|
u_system_devices_get_ht_device_right(struct xrt_system_devices *xsysd)
|
||||||
|
{
|
||||||
|
return u_system_devices_get_ht_device(xsysd, XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -164,10 +164,8 @@ legacy_open_system(struct xrt_builder *xb,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find hand tracking devices.
|
// Find hand tracking devices.
|
||||||
usysd->base.roles.hand_tracking.left =
|
usysd->base.roles.hand_tracking.left = u_system_devices_get_ht_device_left(&usysd->base);
|
||||||
u_system_devices_get_ht_device(usysd, XRT_INPUT_GENERIC_HAND_TRACKING_LEFT);
|
usysd->base.roles.hand_tracking.right = u_system_devices_get_ht_device_right(&usysd->base);
|
||||||
usysd->base.roles.hand_tracking.right =
|
|
||||||
u_system_devices_get_ht_device(usysd, XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -677,15 +677,13 @@ lighthouse_open_system(struct xrt_builder *xb,
|
||||||
if (left_idx >= 0) {
|
if (left_idx >= 0) {
|
||||||
lhs->vive_tstatus.controllers_found = true;
|
lhs->vive_tstatus.controllers_found = true;
|
||||||
usysd->base.roles.left = usysd->base.xdevs[left_idx];
|
usysd->base.roles.left = usysd->base.xdevs[left_idx];
|
||||||
usysd->base.roles.hand_tracking.left =
|
usysd->base.roles.hand_tracking.left = u_system_devices_get_ht_device_left(&usysd->base);
|
||||||
u_system_devices_get_ht_device(usysd, XRT_INPUT_GENERIC_HAND_TRACKING_LEFT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (right_idx >= 0) {
|
if (right_idx >= 0) {
|
||||||
lhs->vive_tstatus.controllers_found = true;
|
lhs->vive_tstatus.controllers_found = true;
|
||||||
usysd->base.roles.right = usysd->base.xdevs[right_idx];
|
usysd->base.roles.right = usysd->base.xdevs[right_idx];
|
||||||
usysd->base.roles.hand_tracking.right =
|
usysd->base.roles.hand_tracking.right = u_system_devices_get_ht_device_right(&usysd->base);
|
||||||
u_system_devices_get_ht_device(usysd, XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lhs->is_valve_index) {
|
if (lhs->is_valve_index) {
|
||||||
|
|
|
@ -300,10 +300,8 @@ wmr_open_system(struct xrt_builder *xb,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find hand tracking devices.
|
// Find hand tracking devices.
|
||||||
usysd->base.roles.hand_tracking.left =
|
usysd->base.roles.hand_tracking.left = u_system_devices_get_ht_device_left(&usysd->base);
|
||||||
u_system_devices_get_ht_device(usysd, XRT_INPUT_GENERIC_HAND_TRACKING_LEFT);
|
usysd->base.roles.hand_tracking.right = u_system_devices_get_ht_device_right(&usysd->base);
|
||||||
usysd->base.roles.hand_tracking.right =
|
|
||||||
u_system_devices_get_ht_device(usysd, XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT);
|
|
||||||
|
|
||||||
// Create space overseer last once all devices set.
|
// Create space overseer last once all devices set.
|
||||||
struct xrt_space_overseer *xso = NULL;
|
struct xrt_space_overseer *xso = NULL;
|
||||||
|
|
Loading…
Reference in a new issue