tangled
alpha
login
or
join now
matrixfurry.com
/
monado
0
fork
atom
The open source OpenXR runtime
0
fork
atom
overview
issues
pulls
pipelines
t/common: Use new u_builder helper
Jakob Bornecrantz
2 years ago
0ee84ea4
dbcf753b
+268
-442
10 changed files
expand all
collapse all
unified
split
src
xrt
targets
common
target_builder_legacy.c
target_builder_lighthouse.c
target_builder_north_star.c
target_builder_nreal_air.c
target_builder_qwerty.c
target_builder_rgb_tracking.c
target_builder_rift_s.c
target_builder_simulated.c
target_builder_simulavr.c
target_builder_wmr.c
+26
-44
src/xrt/targets/common/target_builder_legacy.c
···
111
111
}
112
112
113
113
static xrt_result_t
114
114
-
legacy_open_system(struct xrt_builder *xb,
115
115
-
cJSON *config,
116
116
-
struct xrt_prober *xp,
117
117
-
struct xrt_system_devices **out_xsysd,
118
118
-
struct xrt_space_overseer **out_xso)
114
114
+
legacy_open_system_impl(struct xrt_builder *xb,
115
115
+
cJSON *config,
116
116
+
struct xrt_prober *xp,
117
117
+
struct xrt_tracking_origin *origin,
118
118
+
struct xrt_system_devices *xsysd,
119
119
+
struct xrt_frame_context *xfctx,
120
120
+
struct u_builder_roles_helper *ubrh)
119
121
{
120
122
xrt_result_t xret;
121
123
int ret;
122
122
-
123
123
-
assert(out_xsysd != NULL);
124
124
-
assert(*out_xsysd == NULL);
125
124
126
125
127
126
/*
···
133
132
return xret;
134
133
}
135
134
136
136
-
// Use the static system devices helper, no dynamic roles.
137
137
-
struct u_system_devices_static *usysds = u_system_devices_static_allocate();
138
138
-
struct xrt_system_devices *xsysd = &usysds->base.base;
139
139
-
140
135
ret = xrt_prober_select(xp, xsysd->xdevs, ARRAY_SIZE(xsysd->xdevs));
141
136
if (ret < 0) {
142
142
-
xrt_system_devices_destroy(&xsysd);
143
137
return XRT_ERROR_DEVICE_CREATION_FAILED;
144
138
}
145
139
···
179
173
right_ht = u_system_devices_get_ht_device_right(xsysd);
180
174
181
175
// Assign to role(s).
182
182
-
xsysd->static_roles.head = head;
183
183
-
xsysd->static_roles.hand_tracking.left = left_ht;
184
184
-
xsysd->static_roles.hand_tracking.right = right_ht;
185
185
-
186
186
-
u_system_devices_static_finalize( //
187
187
-
usysds, // usysds
188
188
-
left, // left
189
189
-
right); // right
190
190
-
191
191
-
192
192
-
/*
193
193
-
* Done.
194
194
-
*/
195
195
-
196
196
-
*out_xsysd = xsysd;
197
197
-
u_builder_create_space_overseer_legacy( //
198
198
-
head, // head
199
199
-
left, // left
200
200
-
right, // right
201
201
-
xsysd->xdevs, // xdevs
202
202
-
xsysd->xdev_count, // xdev_count
203
203
-
out_xso); // out_xso
176
176
+
ubrh->head = head;
177
177
+
ubrh->left = left;
178
178
+
ubrh->right = right;
179
179
+
ubrh->hand_tracking.left = left_ht;
180
180
+
ubrh->hand_tracking.right = right_ht;
204
181
205
182
return XRT_SUCCESS;
206
183
}
···
221
198
struct xrt_builder *
222
199
t_builder_legacy_create(void)
223
200
{
224
224
-
struct xrt_builder *xb = U_TYPED_CALLOC(struct xrt_builder);
225
225
-
xb->estimate_system = legacy_estimate_system;
226
226
-
xb->open_system = legacy_open_system;
227
227
-
xb->destroy = legacy_destroy;
228
228
-
xb->identifier = "legacy";
229
229
-
xb->name = "Legacy probing system";
230
230
-
xb->driver_identifiers = driver_list;
231
231
-
xb->driver_identifier_count = ARRAY_SIZE(driver_list) - 1;
201
201
+
struct u_builder *ub = U_TYPED_CALLOC(struct u_builder);
202
202
+
203
203
+
// xrt_builder fields.
204
204
+
ub->base.estimate_system = legacy_estimate_system;
205
205
+
ub->base.open_system = u_builder_open_system_static_roles;
206
206
+
ub->base.destroy = legacy_destroy;
207
207
+
ub->base.identifier = "legacy";
208
208
+
ub->base.name = "Legacy probing system";
209
209
+
ub->base.driver_identifiers = driver_list;
210
210
+
ub->base.driver_identifier_count = ARRAY_SIZE(driver_list) - 1;
211
211
+
212
212
+
// u_builder fields.
213
213
+
ub->open_system_static_roles = legacy_open_system_impl;
232
214
233
233
-
return xb;
215
215
+
return &ub->base;
234
216
}
+36
-46
src/xrt/targets/common/target_builder_lighthouse.c
···
118
118
119
119
struct lighthouse_system
120
120
{
121
121
-
struct xrt_builder base;
122
122
-
struct u_system_devices_static *devices;
121
121
+
struct u_builder base;
122
122
+
123
123
+
struct xrt_frame_context *xfctx;
123
124
enum lighthouse_driver driver; //!< Which lighthouse implementation we are using
124
125
bool is_valve_index; //!< Is our HMD a Valve Index? If so, try to set up hand-tracking and SLAM as needed
125
126
struct vive_tracking_status vive_tstatus; //!< Visual tracking status for Index under Vive driver
···
165
166
void *ptr)
166
167
{
167
168
struct lighthouse_system *lhs = (struct lighthouse_system *)ptr;
168
168
-
struct u_system_devices *usysd = &lhs->devices->base;
169
169
170
170
// Hardcoded for the Index.
171
171
if (product != NULL && manufacturer != NULL) {
172
172
if ((strcmp(product, "3D Camera") == 0) && (strcmp(manufacturer, "Etron Technology, Inc.") == 0)) {
173
173
-
xrt_prober_open_video_device(xp, pdev, &usysd->xfctx, &lhs->xfs);
173
173
+
xrt_prober_open_video_device(xp, pdev, lhs->xfctx, &lhs->xfs);
174
174
return;
175
175
}
176
176
}
···
518
518
}
519
519
520
520
static xrt_result_t
521
521
-
lighthouse_open_system(struct xrt_builder *xb,
522
522
-
cJSON *config,
523
523
-
struct xrt_prober *xp,
524
524
-
struct xrt_system_devices **out_xsysd,
525
525
-
struct xrt_space_overseer **out_xso)
521
521
+
lighthouse_open_system_impl(struct xrt_builder *xb,
522
522
+
cJSON *config,
523
523
+
struct xrt_prober *xp,
524
524
+
struct xrt_tracking_origin *origin,
525
525
+
struct xrt_system_devices *xsysd,
526
526
+
struct xrt_frame_context *xfctx,
527
527
+
struct u_builder_roles_helper *ubrh)
526
528
{
527
529
struct lighthouse_system *lhs = (struct lighthouse_system *)xb;
528
528
-
529
529
-
// Use the static system devices helper, no dynamic roles.
530
530
-
lhs->devices = u_system_devices_static_allocate();
531
531
-
struct xrt_system_devices *xsysd = &lhs->devices->base.base;
532
532
-
struct xrt_frame_context *xfctx = &lhs->devices->base.xfctx;
533
533
-
534
534
-
535
530
xrt_result_t result = XRT_SUCCESS;
536
531
537
537
-
if (out_xsysd == NULL || *out_xsysd != NULL) {
538
538
-
LH_ERROR("Invalid output system pointer");
539
539
-
result = XRT_ERROR_DEVICE_CREATION_FAILED;
540
540
-
goto end_err;
541
541
-
}
532
532
+
// Needed when we probe for video devices.
533
533
+
lhs->xfctx = xfctx;
542
534
543
535
// Decide whether to initialize the SLAM tracker
544
536
bool slam_wanted = debug_get_bool_option_vive_slam();
···
755
747
}
756
748
757
749
// Assign to role(s).
758
758
-
xsysd->static_roles.head = head;
759
759
-
xsysd->static_roles.hand_tracking.left = left_ht;
760
760
-
xsysd->static_roles.hand_tracking.right = right_ht;
761
761
-
762
762
-
u_system_devices_static_finalize( //
763
763
-
lhs->devices, // usysds
764
764
-
left, // left
765
765
-
right); // right
750
750
+
ubrh->head = head;
751
751
+
ubrh->left = left;
752
752
+
ubrh->right = right;
753
753
+
ubrh->hand_tracking.left = left_ht;
754
754
+
ubrh->hand_tracking.right = right_ht;
766
755
767
767
-
*out_xsysd = xsysd;
768
768
-
u_builder_create_space_overseer_legacy( //
769
769
-
head, // head
770
770
-
left, // left
771
771
-
right, // right
772
772
-
xsysd->xdevs, // xdevs
773
773
-
xsysd->xdev_count, // xdev_count
774
774
-
out_xso); // out_xso
756
756
+
// Clean up after us.
757
757
+
lhs->xfctx = NULL;
775
758
776
759
return XRT_SUCCESS;
760
760
+
777
761
778
762
end_err:
779
779
-
xrt_system_devices_destroy(&xsysd);
763
763
+
// Clean up after us.
764
764
+
lhs->xfctx = NULL;
780
765
781
766
return result;
782
767
}
···
799
784
t_builder_lighthouse_create(void)
800
785
{
801
786
struct lighthouse_system *lhs = U_TYPED_CALLOC(struct lighthouse_system);
802
802
-
lhs->base.estimate_system = lighthouse_estimate_system;
803
803
-
lhs->base.open_system = lighthouse_open_system;
804
804
-
lhs->base.destroy = lighthouse_destroy;
805
805
-
lhs->base.identifier = "lighthouse";
806
806
-
lhs->base.name = "Lighthouse-tracked (Vive, Index, Tundra trackers, etc.) devices builder";
807
807
-
lhs->base.driver_identifiers = driver_list;
808
808
-
lhs->base.driver_identifier_count = ARRAY_SIZE(driver_list);
787
787
+
788
788
+
// xrt_builder fields.
789
789
+
lhs->base.base.estimate_system = lighthouse_estimate_system;
790
790
+
lhs->base.base.open_system = u_builder_open_system_static_roles;
791
791
+
lhs->base.base.destroy = lighthouse_destroy;
792
792
+
lhs->base.base.identifier = "lighthouse";
793
793
+
lhs->base.base.name = "Lighthouse-tracked (Vive, Index, Tundra trackers, etc.) devices builder";
794
794
+
lhs->base.base.driver_identifiers = driver_list;
795
795
+
lhs->base.base.driver_identifier_count = ARRAY_SIZE(driver_list);
796
796
+
797
797
+
// u_builder fields.
798
798
+
lhs->base.open_system_static_roles = lighthouse_open_system_impl;
809
799
810
810
-
return &lhs->base;
800
800
+
return &lhs->base.base;
811
801
}
+28
-49
src/xrt/targets/common/target_builder_north_star.c
···
102
102
103
103
struct ns_builder
104
104
{
105
105
-
struct xrt_builder base;
105
105
+
struct u_builder base;
106
106
107
107
const char *config_path;
108
108
cJSON *config_json;
···
442
442
return XRT_SUCCESS;
443
443
}
444
444
445
445
-
446
446
-
447
445
static xrt_result_t
448
448
-
ns_open_system(struct xrt_builder *xb,
449
449
-
cJSON *config,
450
450
-
struct xrt_prober *xp,
451
451
-
struct xrt_system_devices **out_xsysd,
452
452
-
struct xrt_space_overseer **out_xso)
446
446
+
ns_open_system_impl(struct xrt_builder *xb,
447
447
+
cJSON *config,
448
448
+
struct xrt_prober *xp,
449
449
+
struct xrt_tracking_origin *origin,
450
450
+
struct xrt_system_devices *xsysd,
451
451
+
struct xrt_frame_context *xfctx,
452
452
+
struct u_builder_roles_helper *ubrh)
453
453
{
454
454
struct ns_builder *nsb = (struct ns_builder *)xb;
455
455
xrt_result_t result = XRT_SUCCESS;
456
456
-
457
457
-
// Use the static system devices helper, no dynamic roles.
458
458
-
struct u_system_devices_static *usysds = u_system_devices_static_allocate();
459
459
-
struct xrt_system_devices *xsysd = &usysds->base.base;
460
460
-
struct xrt_frame_context *xfctx = &usysds->base.xfctx;
461
461
-
462
462
-
if (out_xsysd == NULL || *out_xsysd != NULL) {
463
463
-
NS_ERROR("Invalid output system pointer");
464
464
-
result = XRT_ERROR_DEVICE_CREATION_FAILED;
465
465
-
goto end;
466
466
-
}
467
467
-
468
456
469
457
bool load_success = ns_config_load(nsb);
470
458
if (!load_success) {
···
591
579
}
592
580
593
581
// Assign to role(s).
594
594
-
xsysd->static_roles.head = head_wrap;
595
595
-
xsysd->static_roles.hand_tracking.left = left_ht;
596
596
-
xsysd->static_roles.hand_tracking.right = right_ht;
597
597
-
598
598
-
u_system_devices_static_finalize( //
599
599
-
usysds, // usysds
600
600
-
left, // left
601
601
-
right); // right
602
602
-
582
582
+
ubrh->head = head_wrap;
583
583
+
ubrh->left = left;
584
584
+
ubrh->right = right;
585
585
+
ubrh->hand_tracking.left = left_ht;
586
586
+
ubrh->hand_tracking.right = right_ht;
603
587
604
588
end:
605
605
-
if (result == XRT_SUCCESS) {
606
606
-
*out_xsysd = xsysd;
607
607
-
u_builder_create_space_overseer_legacy( //
608
608
-
head_wrap, // head
609
609
-
left, // left
610
610
-
right, // right
611
611
-
xsysd->xdevs, // xdevs
612
612
-
xsysd->xdev_count, // xdev_count
613
613
-
out_xso); // out_xso
614
614
-
} else {
615
615
-
xrt_system_devices_destroy(&xsysd);
616
616
-
}
617
589
if (nsb->config_json != NULL) {
618
590
cJSON_Delete(nsb->config_json);
591
591
+
nsb->config_path = NULL;
619
592
}
620
593
621
594
return result;
···
626
599
{
627
600
free(xb);
628
601
}
602
602
+
629
603
630
604
/*
631
605
*
···
637
611
t_builder_north_star_create(void)
638
612
{
639
613
struct ns_builder *sb = U_TYPED_CALLOC(struct ns_builder);
640
640
-
sb->base.estimate_system = ns_estimate_system;
641
641
-
sb->base.open_system = ns_open_system;
642
642
-
sb->base.destroy = ns_destroy;
643
643
-
sb->base.identifier = "north_star";
644
644
-
sb->base.name = "North Star headset";
645
645
-
sb->base.driver_identifiers = driver_list;
646
646
-
sb->base.driver_identifier_count = ARRAY_SIZE(driver_list);
647
614
648
648
-
return &sb->base;
615
615
+
// xrt_builder fields.
616
616
+
sb->base.base.estimate_system = ns_estimate_system;
617
617
+
sb->base.base.open_system = u_builder_open_system_static_roles;
618
618
+
sb->base.base.destroy = ns_destroy;
619
619
+
sb->base.base.identifier = "north_star";
620
620
+
sb->base.base.name = "North Star headset";
621
621
+
sb->base.base.driver_identifiers = driver_list;
622
622
+
sb->base.base.driver_identifier_count = ARRAY_SIZE(driver_list);
623
623
+
624
624
+
// u_builder fields.
625
625
+
sb->base.open_system_static_roles = ns_open_system_impl;
626
626
+
627
627
+
return &sb->base.base;
649
628
}
+21
-43
src/xrt/targets/common/target_builder_nreal_air.c
···
82
82
}
83
83
84
84
static xrt_result_t
85
85
-
nreal_air_open_system(struct xrt_builder *xb,
86
86
-
cJSON *config,
87
87
-
struct xrt_prober *xp,
88
88
-
struct xrt_system_devices **out_xsysd,
89
89
-
struct xrt_space_overseer **out_xso)
85
85
+
nreal_air_open_system_impl(struct xrt_builder *xb,
86
86
+
cJSON *config,
87
87
+
struct xrt_prober *xp,
88
88
+
struct xrt_tracking_origin *origin,
89
89
+
struct xrt_system_devices *xsysd,
90
90
+
struct xrt_frame_context *xfctx,
91
91
+
struct u_builder_roles_helper *ubrh)
90
92
{
91
93
struct xrt_prober_device **xpdevs = NULL;
92
94
size_t xpdev_count = 0;
93
95
xrt_result_t xret = XRT_SUCCESS;
94
94
-
95
95
-
assert(out_xsysd != NULL);
96
96
-
assert(*out_xsysd == NULL);
97
96
98
97
DRV_TRACE_MARKER();
99
98
100
99
nreal_air_log_level = debug_get_log_option_nreal_air_log();
101
101
-
102
102
-
// Use the static system devices helper, no dynamic roles.
103
103
-
struct u_system_devices_static *usysds = u_system_devices_static_allocate();
104
104
-
struct xrt_system_devices *xsysd = &usysds->base.base;
105
100
106
101
xret = xrt_prober_lock_list(xp, &xpdevs, &xpdev_count);
107
102
if (xret != XRT_SUCCESS) {
···
152
147
xsysd->xdevs[xsysd->xdev_count++] = na_device;
153
148
154
149
// Assign to role(s).
155
155
-
xsysd->static_roles.head = na_device;
156
156
-
157
157
-
u_system_devices_static_finalize( //
158
158
-
usysds, // usysds
159
159
-
NULL, // left
160
160
-
NULL); // right
161
161
-
162
162
-
163
163
-
/*
164
164
-
* Done.
165
165
-
*/
166
166
-
167
167
-
*out_xsysd = xsysd;
168
168
-
u_builder_create_space_overseer_legacy( //
169
169
-
na_device, // head
170
170
-
NULL, // left
171
171
-
NULL, // right
172
172
-
xsysd->xdevs, // xdevs
173
173
-
xsysd->xdev_count, // xdev_count
174
174
-
out_xso); // out_xso
150
150
+
ubrh->head = na_device;
175
151
176
152
return XRT_SUCCESS;
177
153
···
188
164
189
165
/* Fallthrough */
190
166
fail:
191
191
-
xrt_system_devices_destroy(&xsysd);
192
192
-
193
167
return XRT_ERROR_DEVICE_CREATION_FAILED;
194
168
}
195
169
···
209
183
struct xrt_builder *
210
184
nreal_air_builder_create(void)
211
185
{
186
186
+
struct u_builder *ub = U_TYPED_CALLOC(struct u_builder);
212
187
213
213
-
struct xrt_builder *xb = U_TYPED_CALLOC(struct xrt_builder);
214
214
-
xb->estimate_system = nreal_air_estimate_system;
215
215
-
xb->open_system = nreal_air_open_system;
216
216
-
xb->destroy = nreal_air_destroy;
217
217
-
xb->identifier = "nreal_air";
218
218
-
xb->name = "Nreal Air";
219
219
-
xb->driver_identifiers = driver_list;
220
220
-
xb->driver_identifier_count = ARRAY_SIZE(driver_list);
188
188
+
// xrt_builder fields.
189
189
+
ub->base.estimate_system = nreal_air_estimate_system;
190
190
+
ub->base.open_system = u_builder_open_system_static_roles;
191
191
+
ub->base.destroy = nreal_air_destroy;
192
192
+
ub->base.identifier = "nreal_air";
193
193
+
ub->base.name = "Nreal Air";
194
194
+
ub->base.driver_identifiers = driver_list;
195
195
+
ub->base.driver_identifier_count = ARRAY_SIZE(driver_list);
221
196
222
222
-
return xb;
197
197
+
// u_builder fields.
198
198
+
ub->open_system_static_roles = nreal_air_open_system_impl;
199
199
+
200
200
+
return &ub->base;
223
201
}
+25
-42
src/xrt/targets/common/target_builder_qwerty.c
···
68
68
}
69
69
70
70
static xrt_result_t
71
71
-
qwerty_open_system(struct xrt_builder *xb,
72
72
-
cJSON *config,
73
73
-
struct xrt_prober *xp,
74
74
-
struct xrt_system_devices **out_xsysd,
75
75
-
struct xrt_space_overseer **out_xso)
71
71
+
qwerty_open_system_impl(struct xrt_builder *xb,
72
72
+
cJSON *config,
73
73
+
struct xrt_prober *xp,
74
74
+
struct xrt_tracking_origin *origin,
75
75
+
struct xrt_system_devices *xsysd,
76
76
+
struct xrt_frame_context *xfctx,
77
77
+
struct u_builder_roles_helper *ubrh)
76
78
{
77
77
-
assert(out_xsysd != NULL);
78
78
-
assert(*out_xsysd == NULL);
79
79
-
80
79
struct xrt_device *head = NULL;
81
80
struct xrt_device *left = NULL;
82
81
struct xrt_device *right = NULL;
···
87
86
return xret;
88
87
}
89
88
90
90
-
// Use the static system devices helper, no dynamic roles.
91
91
-
struct u_system_devices_static *usysds = u_system_devices_static_allocate();
92
92
-
struct xrt_system_devices *xsysd = &usysds->base.base;
93
93
-
94
89
// Add to device list.
95
90
xsysd->xdevs[xsysd->xdev_count++] = head;
96
91
if (left != NULL) {
···
101
96
}
102
97
103
98
// Assign to role(s).
104
104
-
xsysd->static_roles.head = head;
105
105
-
106
106
-
u_system_devices_static_finalize( //
107
107
-
usysds, // usysds
108
108
-
left, // left
109
109
-
right); // right
110
110
-
111
111
-
112
112
-
/*
113
113
-
* Done.
114
114
-
*/
115
115
-
116
116
-
*out_xsysd = xsysd;
117
117
-
u_builder_create_space_overseer_legacy( //
118
118
-
head, // head
119
119
-
left, // left
120
120
-
right, // right
121
121
-
xsysd->xdevs, // xdevs
122
122
-
xsysd->xdev_count, // xdev_count
123
123
-
out_xso); // out_xso
99
99
+
ubrh->head = head;
100
100
+
ubrh->left = left;
101
101
+
ubrh->right = right;
124
102
125
103
return XRT_SUCCESS;
126
104
}
···
141
119
struct xrt_builder *
142
120
t_builder_qwerty_create(void)
143
121
{
144
144
-
struct xrt_builder *xb = U_TYPED_CALLOC(struct xrt_builder);
145
145
-
xb->estimate_system = qwerty_estimate_system;
146
146
-
xb->open_system = qwerty_open_system;
147
147
-
xb->destroy = qwerty_destroy;
148
148
-
xb->identifier = "qwerty";
149
149
-
xb->name = "Qwerty devices builder";
150
150
-
xb->driver_identifiers = driver_list;
151
151
-
xb->driver_identifier_count = ARRAY_SIZE(driver_list);
152
152
-
xb->exclude_from_automatic_discovery = !debug_get_bool_option_enable_qwerty();
122
122
+
struct u_builder *ub = U_TYPED_CALLOC(struct u_builder);
123
123
+
124
124
+
// xrt_builder fields.
125
125
+
ub->base.estimate_system = qwerty_estimate_system;
126
126
+
ub->base.open_system = u_builder_open_system_static_roles;
127
127
+
ub->base.destroy = qwerty_destroy;
128
128
+
ub->base.identifier = "qwerty";
129
129
+
ub->base.name = "Qwerty devices builder";
130
130
+
ub->base.driver_identifiers = driver_list;
131
131
+
ub->base.driver_identifier_count = ARRAY_SIZE(driver_list);
132
132
+
ub->base.exclude_from_automatic_discovery = !debug_get_bool_option_enable_qwerty();
133
133
+
134
134
+
// u_builder fields.
135
135
+
ub->open_system_static_roles = qwerty_open_system_impl;
153
136
154
154
-
return xb;
137
137
+
return &ub->base;
155
138
}
+24
-46
src/xrt/targets/common/target_builder_rgb_tracking.c
···
276
276
}
277
277
278
278
static xrt_result_t
279
279
-
rgb_open_system(struct xrt_builder *xb,
280
280
-
cJSON *config,
281
281
-
struct xrt_prober *xp,
282
282
-
struct xrt_system_devices **out_xsysd,
283
283
-
struct xrt_space_overseer **out_xso)
279
279
+
rgb_open_system_impl(struct xrt_builder *xb,
280
280
+
cJSON *config,
281
281
+
struct xrt_prober *xp,
282
282
+
struct xrt_tracking_origin *origin,
283
283
+
struct xrt_system_devices *xsysd,
284
284
+
struct xrt_frame_context *xfctx,
285
285
+
struct u_builder_roles_helper *ubrh)
284
286
{
285
287
struct u_builder_search_results results = {0};
286
288
struct xrt_prober_device **xpdevs = NULL;
287
289
size_t xpdev_count = 0;
288
290
xrt_result_t xret = XRT_SUCCESS;
289
291
290
290
-
assert(out_xsysd != NULL);
291
291
-
assert(*out_xsysd == NULL);
292
292
-
293
293
-
// Use the static system devices helper, no dynamic roles.
294
294
-
struct u_system_devices_static *usysds = u_system_devices_static_allocate();
295
295
-
struct xrt_tracking_origin *origin = &usysds->base.origin;
296
296
-
struct xrt_system_devices *xsysd = &usysds->base.base;
297
297
-
struct xrt_frame_context *xfctx = &usysds->base.xfctx;
298
298
-
299
292
300
293
/*
301
294
* Tracking.
···
327
320
// Lock the device list
328
321
xret = xrt_prober_lock_list(xp, &xpdevs, &xpdev_count);
329
322
if (xret != XRT_SUCCESS) {
330
330
-
xrt_system_devices_destroy(&xsysd);
331
323
return xret;
332
324
}
333
325
···
387
379
// Unlock the device list
388
380
xret = xrt_prober_unlock_list(xp, &xpdevs);
389
381
if (xret != XRT_SUCCESS) {
390
390
-
xrt_system_devices_destroy(&xsysd);
391
382
return xret;
392
383
}
393
384
···
406
397
}
407
398
408
399
// Assign to role(s).
409
409
-
xsysd->static_roles.head = head;
410
410
-
411
411
-
u_system_devices_static_finalize( //
412
412
-
usysds, // usysds
413
413
-
left, // left
414
414
-
right); // right
415
415
-
416
416
-
417
417
-
/*
418
418
-
* Done.
419
419
-
*/
420
420
-
421
421
-
*out_xsysd = xsysd;
422
422
-
u_builder_create_space_overseer_legacy( //
423
423
-
head, // head
424
424
-
left, // left
425
425
-
right, // right
426
426
-
xsysd->xdevs, // xdevs
427
427
-
xsysd->xdev_count, // xdev_count
428
428
-
out_xso); // out_xso
429
429
-
400
400
+
ubrh->head = head;
401
401
+
ubrh->left = left;
402
402
+
ubrh->right = right;
430
403
431
404
return XRT_SUCCESS;
432
405
}
···
447
420
struct xrt_builder *
448
421
t_builder_rgb_tracking_create(void)
449
422
{
450
450
-
struct xrt_builder *xb = U_TYPED_CALLOC(struct xrt_builder);
451
451
-
xb->estimate_system = rgb_estimate_system;
452
452
-
xb->open_system = rgb_open_system;
453
453
-
xb->destroy = rgb_destroy;
454
454
-
xb->identifier = "rgb_tracking";
455
455
-
xb->name = "RGB tracking based devices (PSVR, PSMV, ...)";
456
456
-
xb->driver_identifiers = driver_list;
457
457
-
xb->driver_identifier_count = ARRAY_SIZE(driver_list);
423
423
+
struct u_builder *ub = U_TYPED_CALLOC(struct u_builder);
424
424
+
425
425
+
// xrt_builder fields.
426
426
+
ub->base.estimate_system = rgb_estimate_system;
427
427
+
ub->base.open_system = u_builder_open_system_static_roles;
428
428
+
ub->base.destroy = rgb_destroy;
429
429
+
ub->base.identifier = "rgb_tracking";
430
430
+
ub->base.name = "RGB tracking based devices (PSVR, PSMV, ...)";
431
431
+
ub->base.driver_identifiers = driver_list;
432
432
+
ub->base.driver_identifier_count = ARRAY_SIZE(driver_list);
433
433
+
434
434
+
// u_builder fields.
435
435
+
ub->open_system_static_roles = rgb_open_system_impl;
458
436
459
459
-
return xb;
437
437
+
return &ub->base;
460
438
}
+30
-44
src/xrt/targets/common/target_builder_rift_s.c
···
93
93
}
94
94
95
95
static xrt_result_t
96
96
-
rift_s_open_system(struct xrt_builder *xb,
97
97
-
cJSON *config,
98
98
-
struct xrt_prober *xp,
99
99
-
struct xrt_system_devices **out_xsysd,
100
100
-
struct xrt_space_overseer **out_xso)
96
96
+
rift_s_open_system_impl(struct xrt_builder *xb,
97
97
+
cJSON *config,
98
98
+
struct xrt_prober *xp,
99
99
+
struct xrt_tracking_origin *origin,
100
100
+
struct xrt_system_devices *xsysd,
101
101
+
struct xrt_frame_context *xfctx,
102
102
+
struct u_builder_roles_helper *ubrh)
101
103
{
102
104
struct xrt_prober_device **xpdevs = NULL;
103
105
size_t xpdev_count = 0;
104
106
xrt_result_t xret = XRT_SUCCESS;
105
105
-
106
106
-
assert(out_xsysd != NULL);
107
107
-
assert(*out_xsysd == NULL);
108
107
109
108
DRV_TRACE_MARKER();
110
109
111
110
rift_s_log_level = debug_get_log_option_rift_s_log();
112
112
-
113
113
-
// Use the static system devices helper, no dynamic roles.
114
114
-
struct u_system_devices_static *usysds = u_system_devices_static_allocate();
115
115
-
struct xrt_system_devices *xsysd = &usysds->base.base;
116
111
117
112
xret = xrt_prober_lock_list(xp, &xpdevs, &xpdev_count);
118
113
if (xret != XRT_SUCCESS) {
···
180
175
xsysd->xdevs[xsysd->xdev_count++] = right_xdev;
181
176
182
177
178
178
+
struct xrt_device *left_ht = NULL;
179
179
+
struct xrt_device *right_ht = NULL;
180
180
+
183
181
#ifdef XRT_BUILD_DRIVER_HANDTRACKING
184
182
struct xrt_device *ht_xdev = rift_s_system_get_hand_tracking_device(sys);
185
183
if (ht_xdev != NULL) {
···
189
187
struct xrt_device *two_hands[2];
190
188
cemu_devices_create(hmd_xdev, ht_xdev, two_hands);
191
189
192
192
-
xsysd->static_roles.hand_tracking.left = two_hands[0];
193
193
-
xsysd->static_roles.hand_tracking.right = two_hands[1];
190
190
+
left_ht = two_hands[0];
191
191
+
right_ht = two_hands[1];
194
192
195
193
xsysd->xdevs[xsysd->xdev_count++] = two_hands[0];
196
194
xsysd->xdevs[xsysd->xdev_count++] = two_hands[1];
···
203
201
#endif
204
202
205
203
// Assign to role(s).
206
206
-
xsysd->static_roles.head = hmd_xdev;
207
207
-
208
208
-
u_system_devices_static_finalize( //
209
209
-
usysds, // usysds
210
210
-
left_xdev, // left
211
211
-
right_xdev); // right
212
212
-
213
213
-
214
214
-
/*
215
215
-
* Done.
216
216
-
*/
217
217
-
218
218
-
*out_xsysd = xsysd;
219
219
-
u_builder_create_space_overseer_legacy( //
220
220
-
hmd_xdev, // head
221
221
-
left_xdev, // left
222
222
-
right_xdev, // right
223
223
-
xsysd->xdevs, // xdevs
224
224
-
xsysd->xdev_count, // xdev_count
225
225
-
out_xso); // out_xso
204
204
+
ubrh->head = hmd_xdev;
205
205
+
ubrh->left = left_xdev;
206
206
+
ubrh->right = right_xdev;
207
207
+
ubrh->hand_tracking.left = left_ht;
208
208
+
ubrh->hand_tracking.right = right_ht;
226
209
227
210
return XRT_SUCCESS;
228
211
···
235
218
236
219
/* Fallthrough */
237
220
fail:
238
238
-
xrt_system_devices_destroy(&xsysd);
239
221
return XRT_ERROR_DEVICE_CREATION_FAILED;
240
222
}
241
223
···
255
237
struct xrt_builder *
256
238
rift_s_builder_create(void)
257
239
{
240
240
+
struct u_builder *ub = U_TYPED_CALLOC(struct u_builder);
258
241
259
259
-
struct xrt_builder *xb = U_TYPED_CALLOC(struct xrt_builder);
260
260
-
xb->estimate_system = rift_s_estimate_system;
261
261
-
xb->open_system = rift_s_open_system;
262
262
-
xb->destroy = rift_s_destroy;
263
263
-
xb->identifier = "rift_s";
264
264
-
xb->name = "Oculus Rift S";
265
265
-
xb->driver_identifiers = driver_list;
266
266
-
xb->driver_identifier_count = ARRAY_SIZE(driver_list);
242
242
+
// xrt_builder fields.
243
243
+
ub->base.estimate_system = rift_s_estimate_system;
244
244
+
ub->base.open_system = u_builder_open_system_static_roles;
245
245
+
ub->base.destroy = rift_s_destroy;
246
246
+
ub->base.identifier = "rift_s";
247
247
+
ub->base.name = "Oculus Rift S";
248
248
+
ub->base.driver_identifiers = driver_list;
249
249
+
ub->base.driver_identifier_count = ARRAY_SIZE(driver_list);
267
250
268
268
-
return xb;
251
251
+
// u_builder fields.
252
252
+
ub->open_system_static_roles = rift_s_open_system_impl;
253
253
+
254
254
+
return &ub->base;
269
255
}
+25
-42
src/xrt/targets/common/target_builder_simulated.c
···
90
90
}
91
91
92
92
static xrt_result_t
93
93
-
simulated_open_system(struct xrt_builder *xb,
94
94
-
cJSON *config,
95
95
-
struct xrt_prober *xp,
96
96
-
struct xrt_system_devices **out_xsysd,
97
97
-
struct xrt_space_overseer **out_xso)
93
93
+
simulated_open_system_impl(struct xrt_builder *xb,
94
94
+
cJSON *config,
95
95
+
struct xrt_prober *xp,
96
96
+
struct xrt_tracking_origin *origin,
97
97
+
struct xrt_system_devices *xsysd,
98
98
+
struct xrt_frame_context *xfctx,
99
99
+
struct u_builder_roles_helper *ubrh)
98
100
{
99
99
-
assert(out_xsysd != NULL);
100
100
-
assert(*out_xsysd == NULL);
101
101
-
102
101
const struct xrt_pose head_center = {XRT_QUAT_IDENTITY, {0.0f, 1.6f, 0.0f}}; // "nominal height" 1.6m
103
102
const struct xrt_pose left_center = {XRT_QUAT_IDENTITY, {-0.2f, 1.3f, -0.5f}};
104
103
const struct xrt_pose right_center = {XRT_QUAT_IDENTITY, {0.2f, 1.3f, -0.5f}};
···
119
118
//! @todo Create a shared tracking origin on the system devices struct instead.
120
119
head->tracking_origin->type = XRT_TRACKING_TYPE_OTHER; // Just anything other then none.
121
120
122
122
-
// Use the static system devices helper, no dynamic roles.
123
123
-
struct u_system_devices_static *usysds = u_system_devices_static_allocate();
124
124
-
struct xrt_system_devices *xsysd = &usysds->base.base;
125
125
-
126
121
// Add to device list.
127
122
xsysd->xdevs[xsysd->xdev_count++] = head;
128
123
if (left != NULL) {
···
133
128
}
134
129
135
130
// Assign to role(s).
136
136
-
xsysd->static_roles.head = head;
137
137
-
138
138
-
u_system_devices_static_finalize( //
139
139
-
usysds, // usysds
140
140
-
left, // left
141
141
-
right); // right
142
142
-
143
143
-
144
144
-
/*
145
145
-
* Done.
146
146
-
*/
147
147
-
148
148
-
*out_xsysd = xsysd;
149
149
-
u_builder_create_space_overseer_legacy( //
150
150
-
head, // head
151
151
-
left, // left
152
152
-
right, // right
153
153
-
xsysd->xdevs, // xdevs
154
154
-
xsysd->xdev_count, // xdev_count
155
155
-
out_xso); // out_xso
131
131
+
ubrh->head = head;
132
132
+
ubrh->left = left;
133
133
+
ubrh->right = right;
156
134
157
135
return XRT_SUCCESS;
158
136
}
···
173
151
struct xrt_builder *
174
152
t_builder_simulated_create(void)
175
153
{
176
176
-
struct xrt_builder *xb = U_TYPED_CALLOC(struct xrt_builder);
177
177
-
xb->estimate_system = simulated_estimate_system;
178
178
-
xb->open_system = simulated_open_system;
179
179
-
xb->destroy = simulated_destroy;
180
180
-
xb->identifier = "simulated";
181
181
-
xb->name = "Simulated devices builder";
182
182
-
xb->driver_identifiers = driver_list;
183
183
-
xb->driver_identifier_count = ARRAY_SIZE(driver_list);
184
184
-
xb->exclude_from_automatic_discovery = !debug_get_bool_option_simulated_enabled();
154
154
+
struct u_builder *ub = U_TYPED_CALLOC(struct u_builder);
155
155
+
156
156
+
// xrt_builder fields.
157
157
+
ub->base.estimate_system = simulated_estimate_system;
158
158
+
ub->base.open_system = u_builder_open_system_static_roles;
159
159
+
ub->base.destroy = simulated_destroy;
160
160
+
ub->base.identifier = "simulated";
161
161
+
ub->base.name = "Simulated devices builder";
162
162
+
ub->base.driver_identifiers = driver_list;
163
163
+
ub->base.driver_identifier_count = ARRAY_SIZE(driver_list);
164
164
+
ub->base.exclude_from_automatic_discovery = !debug_get_bool_option_simulated_enabled();
165
165
+
166
166
+
// u_builder fields.
167
167
+
ub->open_system_static_roles = simulated_open_system_impl;
185
168
186
186
-
return xb;
169
169
+
return &ub->base;
187
170
}
+27
-42
src/xrt/targets/common/target_builder_simulavr.c
···
51
51
52
52
struct simula_builder
53
53
{
54
54
-
struct xrt_builder base;
54
54
+
struct u_builder base;
55
55
+
55
56
struct svr_two_displays_distortion display_distortion;
56
57
};
57
58
···
192
193
}
193
194
194
195
static xrt_result_t
195
195
-
svr_open_system(struct xrt_builder *xb,
196
196
-
cJSON *config,
197
197
-
struct xrt_prober *xp,
198
198
-
struct xrt_system_devices **out_xsysd,
199
199
-
struct xrt_space_overseer **out_xso)
196
196
+
svr_open_system_impl(struct xrt_builder *xb,
197
197
+
cJSON *config,
198
198
+
struct xrt_prober *xp,
199
199
+
struct xrt_tracking_origin *origin,
200
200
+
struct xrt_system_devices *xsysd,
201
201
+
struct xrt_frame_context *xfctx,
202
202
+
struct u_builder_roles_helper *ubrh)
200
203
{
201
204
struct simula_builder *sb = (struct simula_builder *)xb;
202
205
xrt_result_t result = XRT_SUCCESS;
203
206
204
204
-
if (out_xsysd == NULL || *out_xsysd != NULL) {
205
205
-
SVR_ERROR("Invalid output system pointer");
207
207
+
struct xrt_device *t265_dev = rs_create_tracked_device_internal_slam();
208
208
+
if (t265_dev == NULL) {
209
209
+
SVR_ERROR("Failed to open T265 device!");
206
210
result = XRT_ERROR_DEVICE_CREATION_FAILED;
207
211
goto end;
208
212
}
209
213
210
210
-
struct xrt_device *t265_dev = rs_create_tracked_device_internal_slam();
211
211
-
212
214
struct xrt_device *svr_dev = svr_hmd_create(&sb->display_distortion);
213
215
214
216
struct xrt_pose ident = XRT_POSE_IDENTITY;
···
217
219
struct xrt_device *head_device = multi_create_tracking_override(
218
220
XRT_TRACKING_OVERRIDE_ATTACHED, svr_dev, t265_dev, XRT_INPUT_GENERIC_TRACKER_POSE, &ident);
219
221
220
220
-
// Use the static system devices helper, no dynamic roles.
221
221
-
struct u_system_devices_static *usysds = u_system_devices_static_allocate();
222
222
-
struct xrt_system_devices *xsysd = &usysds->base.base;
223
223
-
224
222
// Add to device list.
225
223
xsysd->xdevs[xsysd->xdev_count++] = head_device;
226
224
227
225
// Assign to role(s).
228
228
-
xsysd->static_roles.head = head_device;
229
229
-
226
226
+
ubrh->head = head_device;
230
227
231
228
end:
232
232
-
if (result == XRT_SUCCESS) {
233
233
-
u_system_devices_static_finalize( //
234
234
-
usysds, // usysds
235
235
-
NULL, // left
236
236
-
NULL); // right
237
237
-
238
238
-
*out_xsysd = xsysd;
239
239
-
u_builder_create_space_overseer_legacy( //
240
240
-
head_device, // head
241
241
-
NULL, // left
242
242
-
NULL, // right
243
243
-
xsysd->xdevs, // xdevs
244
244
-
xsysd->xdev_count, // xdev_count
245
245
-
out_xso); // out_xso
246
246
-
} else {
247
247
-
xrt_system_devices_destroy(&xsysd);
248
248
-
}
249
249
-
250
229
return result;
251
230
}
252
231
···
255
234
{
256
235
free(xb);
257
236
}
237
237
+
258
238
259
239
/*
260
240
*
···
266
246
t_builder_simula_create(void)
267
247
{
268
248
struct simula_builder *sb = U_TYPED_CALLOC(struct simula_builder);
269
269
-
sb->base.estimate_system = svr_estimate_system;
270
270
-
sb->base.open_system = svr_open_system;
271
271
-
sb->base.destroy = svr_destroy;
272
272
-
sb->base.identifier = "simula";
273
273
-
sb->base.name = "SimulaVR headset";
274
274
-
sb->base.driver_identifiers = driver_list;
275
275
-
sb->base.driver_identifier_count = ARRAY_SIZE(driver_list);
249
249
+
250
250
+
// xrt_builder fields.
251
251
+
sb->base.base.estimate_system = svr_estimate_system;
252
252
+
sb->base.base.open_system = u_builder_open_system_static_roles;
253
253
+
sb->base.base.destroy = svr_destroy;
254
254
+
sb->base.base.identifier = "simula";
255
255
+
sb->base.base.name = "SimulaVR headset";
256
256
+
sb->base.base.driver_identifiers = driver_list;
257
257
+
sb->base.base.driver_identifier_count = ARRAY_SIZE(driver_list);
276
258
277
277
-
return &sb->base;
259
259
+
// u_builder fields.
260
260
+
sb->base.open_system_static_roles = svr_open_system_impl;
261
261
+
262
262
+
return &sb->base.base;
278
263
}
+26
-44
src/xrt/targets/common/target_builder_wmr.c
···
176
176
}
177
177
178
178
static xrt_result_t
179
179
-
wmr_open_system(struct xrt_builder *xb,
180
180
-
cJSON *config,
181
181
-
struct xrt_prober *xp,
182
182
-
struct xrt_system_devices **out_xsysd,
183
183
-
struct xrt_space_overseer **out_xso)
179
179
+
wmr_open_system_impl(struct xrt_builder *xb,
180
180
+
cJSON *config,
181
181
+
struct xrt_prober *xp,
182
182
+
struct xrt_tracking_origin *origin,
183
183
+
struct xrt_system_devices *xsysd,
184
184
+
struct xrt_frame_context *xfctx,
185
185
+
struct u_builder_roles_helper *ubrh)
184
186
{
185
187
enum u_logging_level log_level = debug_get_log_option_wmr_log();
186
188
struct wmr_bt_controllers_search_results ctrls = {0};
···
271
273
assert(xret_unlock == XRT_SUCCESS);
272
274
(void)xret_unlock;
273
275
274
274
-
struct u_system_devices_static *usysds = u_system_devices_static_allocate();
275
275
-
struct xrt_system_devices *xsysd = &usysds->base.base;
276
276
-
277
276
xsysd->xdevs[xsysd->xdev_count++] = head;
278
277
if (left != NULL) {
279
278
xsysd->xdevs[xsysd->xdev_count++] = left;
···
298
297
299
298
300
299
// Assign to role(s).
301
301
-
xsysd->static_roles.head = head;
302
302
-
xsysd->static_roles.hand_tracking.left = ht_left;
303
303
-
xsysd->static_roles.hand_tracking.right = ht_right;
304
304
-
305
305
-
u_system_devices_static_finalize( //
306
306
-
usysds, // usysds
307
307
-
left, // left
308
308
-
right); // right
309
309
-
310
310
-
// Create space overseer last once all devices set.
311
311
-
struct xrt_space_overseer *xso = NULL;
312
312
-
u_builder_create_space_overseer_legacy( //
313
313
-
head, // head
314
314
-
left, // left
315
315
-
right, // right
316
316
-
xsysd->xdevs, // xdevs
317
317
-
xsysd->xdev_count, // xdev_count
318
318
-
&xso); // out_xso
319
319
-
assert(xso != NULL);
320
320
-
321
321
-
322
322
-
/*
323
323
-
* Output.
324
324
-
*/
325
325
-
326
326
-
*out_xsysd = xsysd;
327
327
-
*out_xso = xso;
300
300
+
ubrh->head = head;
301
301
+
ubrh->left = left;
302
302
+
ubrh->right = right;
303
303
+
ubrh->hand_tracking.left = ht_left;
304
304
+
ubrh->hand_tracking.right = ht_right;
328
305
329
306
return XRT_SUCCESS;
330
307
···
355
332
struct xrt_builder *
356
333
t_builder_wmr_create(void)
357
334
{
358
358
-
struct xrt_builder *xb = U_TYPED_CALLOC(struct xrt_builder);
359
359
-
xb->estimate_system = wmr_estimate_system;
360
360
-
xb->open_system = wmr_open_system;
361
361
-
xb->destroy = wmr_destroy;
362
362
-
xb->identifier = "wmr";
363
363
-
xb->name = "Windows Mixed Reality";
364
364
-
xb->driver_identifiers = driver_list;
365
365
-
xb->driver_identifier_count = ARRAY_SIZE(driver_list);
335
335
+
struct u_builder *ub = U_TYPED_CALLOC(struct u_builder);
336
336
+
337
337
+
// xrt_builder fields.
338
338
+
ub->base.estimate_system = wmr_estimate_system;
339
339
+
ub->base.open_system = u_builder_open_system_static_roles;
340
340
+
ub->base.destroy = wmr_destroy;
341
341
+
ub->base.identifier = "wmr";
342
342
+
ub->base.name = "Windows Mixed Reality";
343
343
+
ub->base.driver_identifiers = driver_list;
344
344
+
ub->base.driver_identifier_count = ARRAY_SIZE(driver_list);
345
345
+
346
346
+
// u_builder fields.
347
347
+
ub->open_system_static_roles = wmr_open_system_impl;
366
348
367
367
-
return xb;
349
349
+
return &ub->base;
368
350
}