t/common: Add support for new dynamic device roles

This commit is contained in:
Jakob Bornecrantz authored and korejan committed 2023-10-24 09:24:49 +00:00
1 parent 2c49c0f9a7
commit 9331c8bb0a
10 files changed
+109 -91

No files matched your search

+11 -10
View File
@@ -133,11 +133,9 @@ legacy_open_system(struct xrt_builder *xb,
return xret;
}
struct xrt_system_devices *xsysd = NULL;
{
struct u_system_devices *usysd = u_system_devices_allocate();
xsysd = &usysd->base;
}
// Use the static system devices helper, no dynamic roles.
struct u_system_devices_static *usysds = u_system_devices_static_allocate();
struct xrt_system_devices *xsysd = &usysds->base.base;
ret = xrt_prober_select(xp, xsysd->xdevs, ARRAY_SIZE(xsysd->xdevs));
if (ret < 0) {
@@ -181,11 +179,14 @@ legacy_open_system(struct xrt_builder *xb,
right_ht = u_system_devices_get_ht_device_right(xsysd);
// Assign to role(s).
xsysd->roles.head = head;
xsysd->roles.left = left;
xsysd->roles.right = right;
xsysd->roles.hand_tracking.left = left_ht;
xsysd->roles.hand_tracking.right = right_ht;
xsysd->static_roles.head = head;
xsysd->static_roles.hand_tracking.left = left_ht;
xsysd->static_roles.hand_tracking.right = right_ht;
u_system_devices_static_finalize( //
usysds, // usysds
left, // left
right); // right
/*
@@ -118,7 +118,7 @@ enum lighthouse_driver
struct lighthouse_system
{
struct xrt_builder base;
struct u_system_devices *devices;
struct u_system_devices_static *devices;
enum lighthouse_driver driver; //!< Which lighthouse implementation we are using
bool is_valve_index; //!< Is our HMD a Valve Index? If so, try to set up hand-tracking and SLAM as needed
struct vive_tracking_status vive_tstatus; //!< Visual tracking status for Index under Vive driver
@@ -164,11 +164,12 @@ on_video_device(struct xrt_prober *xp,
void *ptr)
{
struct lighthouse_system *lhs = (struct lighthouse_system *)ptr;
struct u_system_devices *usysd = &lhs->devices->base;
// Hardcoded for the Index.
if (product != NULL && manufacturer != NULL) {
if ((strcmp(product, "3D Camera") == 0) && (strcmp(manufacturer, "Etron Technology, Inc.") == 0)) {
xrt_prober_open_video_device(xp, pdev, &lhs->devices->xfctx, &lhs->xfs);
xrt_prober_open_video_device(xp, pdev, &usysd->xfctx, &lhs->xfs);
return;
}
}
@@ -572,9 +573,12 @@ lighthouse_open_system(struct xrt_builder *xb,
struct xrt_space_overseer **out_xso)
{
struct lighthouse_system *lhs = (struct lighthouse_system *)xb;
lhs->devices = u_system_devices_allocate();
struct xrt_system_devices *xsysd = &lhs->devices->base;
struct xrt_frame_context *xfctx = &lhs->devices->xfctx;
// Use the static system devices helper, no dynamic roles.
lhs->devices = u_system_devices_static_allocate();
struct xrt_system_devices *xsysd = &lhs->devices->base.base;
struct xrt_frame_context *xfctx = &lhs->devices->base.xfctx;
xrt_result_t result = XRT_SUCCESS;
@@ -799,11 +803,14 @@ end_valve_index:
}
// Assign to role(s).
xsysd->roles.head = head;
xsysd->roles.left = left;
xsysd->roles.hand_tracking.left = left_ht;
xsysd->roles.right = right;
xsysd->roles.hand_tracking.right = right_ht;
xsysd->static_roles.head = head;
xsysd->static_roles.hand_tracking.left = left_ht;
xsysd->static_roles.hand_tracking.right = right_ht;
u_system_devices_static_finalize( //
lhs->devices, // usysds
left, // left
right); // right
*out_xsysd = xsysd;
u_builder_create_space_overseer_legacy( //
@@ -442,11 +442,9 @@ ns_open_system(struct xrt_builder *xb,
struct ns_builder *nsb = (struct ns_builder *)xb;
xrt_result_t result = XRT_SUCCESS;
struct xrt_system_devices *xsysd = NULL;
{
struct u_system_devices *usysds = u_system_devices_allocate();
xsysd = &usysds->base;
}
// Use the static system devices helper, no dynamic roles.
struct u_system_devices_static *usysds = u_system_devices_static_allocate();
struct xrt_system_devices *xsysd = &usysds->base.base;
if (out_xsysd == NULL || *out_xsysd != NULL) {
NS_ERROR("Invalid output system pointer");
@@ -579,11 +577,15 @@ ns_open_system(struct xrt_builder *xb,
}
// Assign to role(s).
xsysd->roles.head = head_wrap;
xsysd->roles.left = left;
xsysd->roles.right = right;
xsysd->roles.hand_tracking.left = left_ht;
xsysd->roles.hand_tracking.right = right_ht;
xsysd->static_roles.head = head_wrap;
xsysd->static_roles.hand_tracking.left = left_ht;
xsysd->static_roles.hand_tracking.right = right_ht;
u_system_devices_static_finalize( //
usysds, // usysds
left, // left
right); // right
end:
if (result == XRT_SUCCESS) {
@@ -86,11 +86,10 @@ nreal_air_open_system(struct xrt_builder *xb,
DRV_TRACE_MARKER();
nreal_air_log_level = debug_get_log_option_nreal_air_log();
struct xrt_system_devices *xsysd = NULL;
{
struct u_system_devices *usysd = u_system_devices_allocate();
xsysd = &usysd->base;
}
// Use the static system devices helper, no dynamic roles.
struct u_system_devices_static *usysds = u_system_devices_static_allocate();
struct xrt_system_devices *xsysd = &usysds->base.base;
xret = xrt_prober_lock_list(xp, &xpdevs, &xpdev_count);
if (xret != XRT_SUCCESS) {
@@ -141,7 +140,12 @@ nreal_air_open_system(struct xrt_builder *xb,
xsysd->xdevs[xsysd->xdev_count++] = na_device;
// Assign to role(s).
xsysd->roles.head = na_device;
xsysd->static_roles.head = na_device;
u_system_devices_static_finalize( //
usysds, // usysds
NULL, // left
NULL); // right
/*
@@ -87,11 +87,9 @@ qwerty_open_system(struct xrt_builder *xb,
return xret;
}
struct xrt_system_devices *xsysd = NULL;
{
struct u_system_devices *usysds = u_system_devices_allocate();
xsysd = &usysds->base;
}
// Use the static system devices helper, no dynamic roles.
struct u_system_devices_static *usysds = u_system_devices_static_allocate();
struct xrt_system_devices *xsysd = &usysds->base.base;
// Add to device list.
xsysd->xdevs[xsysd->xdev_count++] = head;
@@ -103,9 +101,12 @@ qwerty_open_system(struct xrt_builder *xb,
}
// Assign to role(s).
xsysd->roles.head = head;
xsysd->roles.left = left;
xsysd->roles.right = right;
xsysd->static_roles.head = head;
u_system_devices_static_finalize( //
usysds, // usysds
left, // left
right); // right
/*
@@ -290,16 +290,11 @@ rgb_open_system(struct xrt_builder *xb,
assert(out_xsysd != NULL);
assert(*out_xsysd == NULL);
struct xrt_tracking_origin *origin = NULL;
struct xrt_system_devices *xsysd = NULL;
struct xrt_frame_context *xfctx = NULL;
{
struct u_system_devices *usysd = u_system_devices_allocate();
xsysd = &usysd->base;
xfctx = &usysd->xfctx;
origin = &usysd->origin;
}
// Use the static system devices helper, no dynamic roles.
struct u_system_devices_static *usysds = u_system_devices_static_allocate();
struct xrt_tracking_origin *origin = &usysds->base.origin;
struct xrt_system_devices *xsysd = &usysds->base.base;
struct xrt_frame_context *xfctx = &usysds->base.xfctx;
/*
@@ -411,9 +406,12 @@ rgb_open_system(struct xrt_builder *xb,
}
// Assign to role(s).
xsysd->roles.head = head;
xsysd->roles.left = left;
xsysd->roles.right = right;
xsysd->static_roles.head = head;
u_system_devices_static_finalize( //
usysds, // usysds
left, // left
right); // right
/*
+12 -10
View File
@@ -98,11 +98,10 @@ rift_s_open_system(struct xrt_builder *xb,
DRV_TRACE_MARKER();
rift_s_log_level = debug_get_log_option_rift_s_log();
struct xrt_system_devices *xsysd = NULL;
{
struct u_system_devices *usysd = u_system_devices_allocate();
xsysd = &usysd->base;
}
// Use the static system devices helper, no dynamic roles.
struct u_system_devices_static *usysds = u_system_devices_static_allocate();
struct xrt_system_devices *xsysd = &usysds->base.base;
xret = xrt_prober_lock_list(xp, &xpdevs, &xpdev_count);
if (xret != XRT_SUCCESS) {
@@ -179,8 +178,8 @@ rift_s_open_system(struct xrt_builder *xb,
struct xrt_device *two_hands[2];
cemu_devices_create(hmd_xdev, ht_xdev, two_hands);
xsysd->roles.hand_tracking.left = two_hands[0];
xsysd->roles.hand_tracking.right = two_hands[1];
xsysd->static_roles.hand_tracking.left = two_hands[0];
xsysd->static_roles.hand_tracking.right = two_hands[1];
xsysd->xdevs[xsysd->xdev_count++] = two_hands[0];
xsysd->xdevs[xsysd->xdev_count++] = two_hands[1];
@@ -193,9 +192,12 @@ rift_s_open_system(struct xrt_builder *xb,
#endif
// Assign to role(s).
xsysd->roles.head = hmd_xdev;
xsysd->roles.left = left_xdev;
xsysd->roles.right = right_xdev;
xsysd->static_roles.head = hmd_xdev;
u_system_devices_static_finalize( //
usysds, // usysds
left_xdev, // left
right_xdev); // right
/*
@@ -119,11 +119,9 @@ simulated_open_system(struct xrt_builder *xb,
//! @todo Create a shared tracking origin on the system devices struct instead.
head->tracking_origin->type = XRT_TRACKING_TYPE_OTHER; // Just anything other then none.
struct xrt_system_devices *xsysd = NULL;
{
struct u_system_devices *usysd = u_system_devices_allocate();
xsysd = &usysd->base;
}
// Use the static system devices helper, no dynamic roles.
struct u_system_devices_static *usysds = u_system_devices_static_allocate();
struct xrt_system_devices *xsysd = &usysds->base.base;
// Add to device list.
xsysd->xdevs[xsysd->xdev_count++] = head;
@@ -135,9 +133,12 @@ simulated_open_system(struct xrt_builder *xb,
}
// Assign to role(s).
xsysd->roles.head = head;
xsysd->roles.left = left;
xsysd->roles.right = right;
xsysd->static_roles.head = head;
u_system_devices_static_finalize( //
usysds, // usysds
left, // left
right); // right
/*
@@ -210,21 +210,24 @@ svr_open_system(struct xrt_builder *xb,
struct xrt_device *head_device = multi_create_tracking_override(
XRT_TRACKING_OVERRIDE_ATTACHED, svr_dev, t265_dev, XRT_INPUT_GENERIC_TRACKER_POSE, &ident);
struct xrt_system_devices *xsysd = NULL;
{
struct u_system_devices *usysd = u_system_devices_allocate();
xsysd = &usysd->base;
}
// Use the static system devices helper, no dynamic roles.
struct u_system_devices_static *usysds = u_system_devices_static_allocate();
struct xrt_system_devices *xsysd = &usysds->base.base;
// Add to device list.
xsysd->xdevs[xsysd->xdev_count++] = head_device;
// Assign to role(s).
xsysd->roles.head = head_device;
xsysd->static_roles.head = head_device;
end:
if (result == XRT_SUCCESS) {
u_system_devices_static_finalize( //
usysds, // usysds
NULL, // left
NULL); // right
*out_xsysd = xsysd;
u_builder_create_space_overseer_legacy( //
head_device, // head
+9 -10
View File
@@ -271,11 +271,8 @@ wmr_open_system(struct xrt_builder *xb,
assert(xret_unlock == XRT_SUCCESS);
(void)xret_unlock;
struct xrt_system_devices *xsysd = NULL;
{
struct u_system_devices *usysd = u_system_devices_allocate();
xsysd = &usysd->base;
}
struct u_system_devices_static *usysds = u_system_devices_static_allocate();
struct xrt_system_devices *xsysd = &usysds->base.base;
xsysd->xdevs[xsysd->xdev_count++] = head;
if (left != NULL) {
@@ -301,12 +298,14 @@ wmr_open_system(struct xrt_builder *xb,
// Assign to role(s).
xsysd->roles.head = head;
xsysd->roles.left = left;
xsysd->roles.right = right;
xsysd->roles.hand_tracking.left = ht_left;
xsysd->roles.hand_tracking.right = ht_right;
xsysd->static_roles.head = head;
xsysd->static_roles.hand_tracking.left = ht_left;
xsysd->static_roles.hand_tracking.right = ht_right;
u_system_devices_static_finalize( //
usysds, // usysds
left, // left
right); // right
// Create space overseer last once all devices set.
struct xrt_space_overseer *xso = NULL;