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