tangled
alpha
login
or
join now
matrixfurry.com
/
monado
0
fork
atom
The open source OpenXR runtime
0
fork
atom
overview
issues
pulls
pipelines
d/opengloves: Refactor creation
Jakob Bornecrantz
2 years ago
e805209f
8b30819b
+41
-41
3 changed files
expand all
collapse all
unified
split
src
xrt
drivers
opengloves
opengloves_interface.h
opengloves_prober.c
targets
common
target_builder_lighthouse.c
+5
-2
src/xrt/drivers/opengloves/opengloves_interface.h
···
22
* @brief Driver for OpenGloves VR Gloves Devices
23
*/
24
25
-
int
26
-
opengloves_create_devices(struct xrt_device **out_xdevs, const struct xrt_system_devices *sysdevs);
0
0
0
27
28
/*!
29
* @dir drivers/opengloves
···
22
* @brief Driver for OpenGloves VR Gloves Devices
23
*/
24
25
+
void
26
+
opengloves_create_devices(struct xrt_device *old_left,
27
+
struct xrt_device *old_right,
28
+
struct xrt_device **out_left,
29
+
struct xrt_device **out_right);
30
31
/*!
32
* @dir drivers/opengloves
+22
-16
src/xrt/drivers/opengloves/opengloves_prober.c
···
49
return out_config_json;
50
}
51
52
-
int
53
-
opengloves_create_devices(struct xrt_device **out_xdevs, const struct xrt_system_devices *sysdevs)
0
0
0
54
{
55
struct xrt_device *dev_left = NULL;
56
struct xrt_device *dev_right = NULL;
···
81
const cJSON *opengloves_config_json = opengloves_load_config_file(&config_json);
82
if (opengloves_config_json == NULL) {
83
cJSON_Delete(config_json.root);
84
-
return 0;
85
}
86
87
// set up tracking overrides
88
-
int cur_dev = 0;
89
-
if (dev_left != NULL && sysdevs->roles.left != NULL) {
90
struct xrt_quat rot = XRT_QUAT_IDENTITY;
91
struct xrt_vec3 pos = XRT_VEC3_ZERO;
92
JSON_QUAT(opengloves_config_json, "offset_rot_left", &rot);
···
94
95
struct xrt_pose offset_pose = {.orientation = rot, .position = pos};
96
97
-
struct xrt_device *dev_wrap =
98
-
multi_create_tracking_override(XRT_TRACKING_OVERRIDE_DIRECT, dev_left, sysdevs->roles.left,
99
-
XRT_INPUT_GENERIC_TRACKER_POSE, &offset_pose);
0
0
0
100
101
-
out_xdevs[cur_dev++] = dev_wrap;
102
}
103
104
-
if (dev_right != NULL && sysdevs->roles.right != NULL) {
105
struct xrt_quat rot = XRT_QUAT_IDENTITY;
106
struct xrt_vec3 pos = XRT_VEC3_ZERO;
107
JSON_QUAT(opengloves_config_json, "offset_rot_right", &rot);
···
109
110
struct xrt_pose offset_pose = {.orientation = rot, .position = pos};
111
112
-
struct xrt_device *dev_wrap =
113
-
multi_create_tracking_override(XRT_TRACKING_OVERRIDE_DIRECT, dev_right, sysdevs->roles.right,
114
-
XRT_INPUT_GENERIC_TRACKER_POSE, &offset_pose);
0
0
0
115
116
-
out_xdevs[cur_dev++] = dev_wrap;
117
}
118
119
cJSON_Delete(config_json.root);
120
-
121
-
return cur_dev;
122
}
···
49
return out_config_json;
50
}
51
52
+
void
53
+
opengloves_create_devices(struct xrt_device *old_left,
54
+
struct xrt_device *old_right,
55
+
struct xrt_device **out_left,
56
+
struct xrt_device **out_right)
57
{
58
struct xrt_device *dev_left = NULL;
59
struct xrt_device *dev_right = NULL;
···
84
const cJSON *opengloves_config_json = opengloves_load_config_file(&config_json);
85
if (opengloves_config_json == NULL) {
86
cJSON_Delete(config_json.root);
87
+
return;
88
}
89
90
// set up tracking overrides
91
+
if (dev_left != NULL && old_left != NULL) {
0
92
struct xrt_quat rot = XRT_QUAT_IDENTITY;
93
struct xrt_vec3 pos = XRT_VEC3_ZERO;
94
JSON_QUAT(opengloves_config_json, "offset_rot_left", &rot);
···
96
97
struct xrt_pose offset_pose = {.orientation = rot, .position = pos};
98
99
+
struct xrt_device *dev_wrap = multi_create_tracking_override( //
100
+
XRT_TRACKING_OVERRIDE_DIRECT, //
101
+
dev_left, //
102
+
old_left, //
103
+
XRT_INPUT_GENERIC_TRACKER_POSE, //
104
+
&offset_pose); //
105
106
+
*out_left = dev_wrap;
107
}
108
109
+
if (dev_right != NULL && old_right != NULL) {
110
struct xrt_quat rot = XRT_QUAT_IDENTITY;
111
struct xrt_vec3 pos = XRT_VEC3_ZERO;
112
JSON_QUAT(opengloves_config_json, "offset_rot_right", &rot);
···
114
115
struct xrt_pose offset_pose = {.orientation = rot, .position = pos};
116
117
+
struct xrt_device *dev_wrap = multi_create_tracking_override( //
118
+
XRT_TRACKING_OVERRIDE_DIRECT, //
119
+
dev_right, //
120
+
old_right, //
121
+
XRT_INPUT_GENERIC_TRACKER_POSE, //
122
+
&offset_pose); //
123
124
+
*out_right = dev_wrap;
125
}
126
127
cJSON_Delete(config_json.root);
0
0
128
}
+14
-23
src/xrt/targets/common/target_builder_lighthouse.c
···
545
}
546
547
static void
548
-
try_add_opengloves(struct u_system_devices *usysd)
0
0
0
549
{
550
#ifdef XRT_BUILD_DRIVER_OPENGLOVES
551
-
size_t openglove_device_count =
552
-
opengloves_create_devices(&usysd->base.xdevs[usysd->base.xdev_count], &usysd->base);
553
-
for (size_t i = usysd->base.xdev_count; i < usysd->base.xdev_count + openglove_device_count; i++) {
554
-
struct xrt_device *xdev = usysd->base.xdevs[i];
555
-
556
-
for (uint32_t j = 0; j < xdev->input_count; j++) {
557
-
struct xrt_input *input = &xdev->inputs[j];
558
-
559
-
if (input->name == XRT_INPUT_GENERIC_HAND_TRACKING_LEFT) {
560
-
usysd->base.roles.hand_tracking.left = xdev;
561
-
562
-
break;
563
-
}
564
-
if (input->name == XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT) {
565
-
usysd->base.roles.hand_tracking.right = xdev;
566
567
-
break;
568
-
}
569
-
}
0
0
0
570
}
571
-
572
-
usysd->base.xdev_count += openglove_device_count;
573
-
574
#endif
575
}
576
···
802
goto end_err;
803
}
804
0
805
if (!lhs->vive_tstatus.hand_enabled) {
806
// We only want to try to add opengloves if we aren't optically tracking hands
807
-
try_add_opengloves(lhs->devices);
808
}
809
810
// Assign to role(s).
···
545
}
546
547
static void
548
+
try_add_opengloves(struct xrt_device *left,
549
+
struct xrt_device *right,
550
+
struct xrt_device **out_left_ht,
551
+
struct xrt_device **out_right_ht)
552
{
553
#ifdef XRT_BUILD_DRIVER_OPENGLOVES
554
+
struct xrt_device *og_left = NULL, *og_right = NULL;
555
+
opengloves_create_devices(left, right, &og_left, &og_right);
0
0
0
0
0
0
0
0
0
0
0
0
0
556
557
+
// Overwrite the hand tracking roles with openglove ones.
558
+
if (og_left != NULL) {
559
+
*out_left_ht = og_left;
560
+
}
561
+
if (og_right != NULL) {
562
+
*out_right_ht = og_right;
563
}
0
0
0
564
#endif
565
}
566
···
792
goto end_err;
793
}
794
795
+
// Should we use OpenGloves.
796
if (!lhs->vive_tstatus.hand_enabled) {
797
// We only want to try to add opengloves if we aren't optically tracking hands
798
+
try_add_opengloves(left, right, &left_ht, &right_ht);
799
}
800
801
// Assign to role(s).