The open source OpenXR runtime

d/wmr: Publish Reverb G2 tunnelled controllers

If there are HMD-tunnelled controllers present,
publish them in the prober and builder so they
can be used.

authored by

Jan Schmidt and committed by
Jakob Bornecrantz
9966c16c e356d57a

+59 -12
+19 -2
src/xrt/drivers/wmr/wmr_hmd.c
··· 170 170 if (controller_id >= WMR_MAX_CONTROLLERS) 171 171 return; 172 172 173 - if (wh->controller[controller_id] != NULL) 173 + if (wh->controller[controller_id] != NULL) { 174 174 return; 175 + } 175 176 176 177 WMR_DEBUG(wh, "Adding controller device %d", controller_id); 177 178 ··· 1928 1929 struct xrt_prober_device *dev_holo, 1929 1930 enum u_logging_level log_level, 1930 1931 struct xrt_device **out_hmd, 1931 - struct xrt_device **out_handtracker) 1932 + struct xrt_device **out_handtracker, 1933 + struct xrt_device **out_left_controller, 1934 + struct xrt_device **out_right_controller) 1932 1935 { 1933 1936 DRV_TRACE_MARKER(); 1934 1937 ··· 2150 2153 2151 2154 *out_hmd = &wh->base; 2152 2155 *out_handtracker = hand_device; 2156 + 2157 + os_mutex_lock(&wh->controller_status_lock); 2158 + if (wh->controller[0] != NULL) { 2159 + *out_left_controller = wmr_hmd_controller_connection_get_controller(wh->controller[0]); 2160 + } else { 2161 + *out_left_controller = NULL; 2162 + } 2163 + 2164 + if (wh->controller[1] != NULL) { 2165 + *out_right_controller = wmr_hmd_controller_connection_get_controller(wh->controller[1]); 2166 + } else { 2167 + *out_right_controller = NULL; 2168 + } 2169 + os_mutex_unlock(&wh->controller_status_lock); 2153 2170 } 2154 2171 2155 2172 bool
+3 -1
src/xrt/drivers/wmr/wmr_hmd.h
··· 215 215 struct xrt_prober_device *dev_holo, 216 216 enum u_logging_level log_level, 217 217 struct xrt_device **out_hmd, 218 - struct xrt_device **out_handtracker); 218 + struct xrt_device **out_handtracker, 219 + struct xrt_device **out_left_controller, 220 + struct xrt_device **out_right_controller); 219 221 220 222 bool 221 223 wmr_hmd_send_controller_packet(struct wmr_hmd *hmd, const uint8_t *buffer, uint32_t buf_size);
+3 -1
src/xrt/drivers/wmr/wmr_interface.h
··· 136 136 enum u_logging_level log_level, 137 137 struct xrt_device **out_hmd, 138 138 struct xrt_device **out_left, 139 - struct xrt_device **out_right); 139 + struct xrt_device **out_right, 140 + struct xrt_device **out_ht_left, 141 + struct xrt_device **out_ht_right); 140 142 141 143 /*! 142 144 * Creates a WMR BT controller device.
+11 -4
src/xrt/drivers/wmr/wmr_prober.c
··· 316 316 enum u_logging_level log_level, 317 317 struct xrt_device **out_hmd, 318 318 struct xrt_device **out_left, 319 - struct xrt_device **out_right) 319 + struct xrt_device **out_right, 320 + struct xrt_device **out_ht_left, 321 + struct xrt_device **out_ht_right) 320 322 { 321 323 DRV_TRACE_MARKER(); 322 324 ··· 343 345 struct xrt_device *hmd = NULL; 344 346 struct xrt_device *ht = NULL; 345 347 struct xrt_device *two_hands[2] = {NULL, NULL}; // Must initialize, always returned. 346 - wmr_hmd_create(type, hid_holo, hid_companion, xpdev_holo, log_level, &hmd, &ht); 348 + struct xrt_device *hmd_left_ctrl = NULL, *hmd_right_ctrl = NULL; 349 + wmr_hmd_create(type, hid_holo, hid_companion, xpdev_holo, log_level, &hmd, &ht, &hmd_left_ctrl, 350 + &hmd_right_ctrl); 347 351 348 352 if (hmd == NULL) { 349 353 U_LOG_IFL_E(log_level, "Failed to create WMR HMD device."); ··· 359 363 #endif 360 364 361 365 *out_hmd = hmd; 362 - *out_left = two_hands[0]; 363 - *out_right = two_hands[1]; 366 + *out_left = hmd_left_ctrl; 367 + *out_right = hmd_right_ctrl; 368 + 369 + *out_ht_left = two_hands[0]; 370 + *out_ht_right = two_hands[1]; 364 371 365 372 return XRT_SUCCESS; 366 373
+23 -4
src/xrt/targets/common/target_builder_wmr.c
··· 230 230 struct xrt_device *head = NULL; 231 231 struct xrt_device *left = NULL; 232 232 struct xrt_device *right = NULL; 233 + struct xrt_device *ht_left = NULL; 234 + struct xrt_device *ht_right = NULL; 233 235 234 236 xret = wmr_create_headset( // 235 237 xp, // ··· 239 241 log_level, // 240 242 &head, // 241 243 &left, // 242 - &right); // 244 + &right, // 245 + &ht_left, // 246 + &ht_right); // 243 247 if (xret != XRT_SUCCESS) { 244 248 goto error; 245 249 } ··· 268 272 269 273 struct u_system_devices *usysd = u_system_devices_allocate(); 270 274 271 - usysd->base.roles.head = head; 272 - usysd->base.roles.left = left; 273 - usysd->base.roles.right = right; 274 275 usysd->base.xdevs[usysd->base.xdev_count++] = head; 275 276 if (left != NULL) { 276 277 usysd->base.xdevs[usysd->base.xdev_count++] = left; 277 278 } 278 279 if (right != NULL) { 279 280 usysd->base.xdevs[usysd->base.xdev_count++] = right; 281 + } 282 + if (ht_left != NULL) { 283 + usysd->base.xdevs[usysd->base.xdev_count++] = ht_left; 284 + } 285 + if (ht_right != NULL) { 286 + usysd->base.xdevs[usysd->base.xdev_count++] = ht_right; 287 + } 288 + 289 + usysd->base.roles.head = head; 290 + if (left != NULL) { 291 + usysd->base.roles.left = left; 292 + } else { 293 + usysd->base.roles.left = ht_left; 294 + } 295 + if (right != NULL) { 296 + usysd->base.roles.right = right; 297 + } else { 298 + usysd->base.roles.right = ht_right; 280 299 } 281 300 282 301 // Find hand tracking devices.