The open source OpenXR runtime

t/common: Refactor WinMR builder [NFC]

+24 -20
+24 -20
src/xrt/targets/common/target_builder_wmr.c
··· 271 271 assert(xret_unlock == XRT_SUCCESS); 272 272 (void)xret_unlock; 273 273 274 - struct u_system_devices *usysd = u_system_devices_allocate(); 274 + struct xrt_system_devices *xsysd = NULL; 275 + { 276 + struct u_system_devices *usysd = u_system_devices_allocate(); 277 + xsysd = &usysd->base; 278 + } 275 279 276 - usysd->base.xdevs[usysd->base.xdev_count++] = head; 280 + xsysd->xdevs[xsysd->xdev_count++] = head; 277 281 if (left != NULL) { 278 - usysd->base.xdevs[usysd->base.xdev_count++] = left; 282 + xsysd->xdevs[xsysd->xdev_count++] = left; 279 283 } 280 284 if (right != NULL) { 281 - usysd->base.xdevs[usysd->base.xdev_count++] = right; 285 + xsysd->xdevs[xsysd->xdev_count++] = right; 282 286 } 283 287 if (ht_left != NULL) { 284 - usysd->base.xdevs[usysd->base.xdev_count++] = ht_left; 288 + xsysd->xdevs[xsysd->xdev_count++] = ht_left; 285 289 } 286 290 if (ht_right != NULL) { 287 - usysd->base.xdevs[usysd->base.xdev_count++] = ht_right; 291 + xsysd->xdevs[xsysd->xdev_count++] = ht_right; 288 292 } 289 293 290 - usysd->base.roles.head = head; 291 - if (left != NULL) { 292 - usysd->base.roles.left = left; 293 - } else { 294 - usysd->base.roles.left = ht_left; 294 + // Use hand tracking if no controllers. 295 + if (left == NULL) { 296 + left = ht_left; 295 297 } 296 - if (right != NULL) { 297 - usysd->base.roles.right = right; 298 - } else { 299 - usysd->base.roles.right = ht_right; 298 + if (right == NULL) { 299 + right = ht_right; 300 300 } 301 301 302 - // Find hand tracking devices. 303 - usysd->base.roles.hand_tracking.left = u_system_devices_get_ht_device_left(&usysd->base); 304 - usysd->base.roles.hand_tracking.right = u_system_devices_get_ht_device_right(&usysd->base); 302 + 303 + // Assign to role(s). 304 + xsysd->roles.head = head; 305 + xsysd->roles.left = left; 306 + xsysd->roles.right = right; 307 + xsysd->roles.hand_tracking.left = ht_left; 308 + xsysd->roles.hand_tracking.right = ht_right; 305 309 306 310 // Create space overseer last once all devices set. 307 311 struct xrt_space_overseer *xso = NULL; 308 - u_builder_create_space_overseer(&usysd->base, &xso); 312 + u_builder_create_space_overseer(xsysd, &xso); 309 313 assert(xso != NULL); 310 314 311 315 ··· 313 317 * Output. 314 318 */ 315 319 316 - *out_xsysd = &usysd->base; 320 + *out_xsysd = xsysd; 317 321 *out_xso = xso; 318 322 319 323 return XRT_SUCCESS;