The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

t/common: Refactor North Star builder [NFC]

+32 -20
+32 -20
src/xrt/targets/common/target_builder_north_star.c
··· 440 440 struct xrt_space_overseer **out_xso) 441 441 { 442 442 struct ns_builder *nsb = (struct ns_builder *)xb; 443 + xrt_result_t result = XRT_SUCCESS; 443 444 444 - 445 - struct u_system_devices *usysd = u_system_devices_allocate(); 446 - xrt_result_t result = XRT_SUCCESS; 445 + struct xrt_system_devices *xsysd = NULL; 446 + { 447 + struct u_system_devices *usysds = u_system_devices_allocate(); 448 + xsysd = &usysds->base; 449 + } 447 450 448 451 if (out_xsysd == NULL || *out_xsysd != NULL) { 449 452 NS_ERROR("Invalid output system pointer"); ··· 533 536 } 534 537 535 538 536 - 539 + // Devices to be created and filled in. 537 540 struct xrt_device *head_wrap = NULL; 538 541 539 542 if (slam_device != NULL) { 540 - usysd->base.xdevs[usysd->base.xdev_count++] = slam_device; 543 + xsysd->xdevs[xsysd->xdev_count++] = slam_device; 541 544 head_wrap = multi_create_tracking_override(XRT_TRACKING_OVERRIDE_DIRECT, ns_hmd, slam_device, 542 545 XRT_INPUT_GENERIC_TRACKER_POSE, &head_offset); 543 546 } else { ··· 545 548 head_wrap = ns_hmd; 546 549 } 547 550 548 - usysd->base.xdevs[usysd->base.xdev_count++] = head_wrap; 549 - usysd->base.roles.head = head_wrap; 551 + // Add the device now. 552 + struct xrt_device *left = NULL, *right = NULL; 553 + struct xrt_device *left_ht = NULL, *right_ht = NULL; 554 + xsysd->xdevs[xsysd->xdev_count++] = head_wrap; 550 555 551 556 if (hand_device != NULL) { 552 557 // note: hand_parented_to_head_tracker is always false when slam_device is NULL ··· 558 563 struct xrt_device *two_hands[2]; 559 564 cemu_devices_create(head_wrap, hand_wrap, two_hands); 560 565 566 + xsysd->xdevs[xsysd->xdev_count++] = two_hands[0]; 567 + xsysd->xdevs[xsysd->xdev_count++] = two_hands[1]; 561 568 562 - // usysd->base.xdev_count = 0; 563 - usysd->base.xdevs[usysd->base.xdev_count++] = two_hands[0]; 564 - usysd->base.xdevs[usysd->base.xdev_count++] = two_hands[1]; 569 + left_ht = two_hands[0]; 570 + right_ht = two_hands[1]; 571 + } 565 572 566 - 567 - usysd->base.roles.hand_tracking.left = two_hands[0]; 568 - usysd->base.roles.hand_tracking.right = two_hands[1]; 569 - 570 - usysd->base.roles.left = two_hands[0]; 571 - usysd->base.roles.right = two_hands[1]; 573 + // Fallback to hand-tracking if no controllers have been used. 574 + if (left == NULL) { 575 + left = left_ht; 576 + } 577 + if (right == NULL) { 578 + right = right_ht; 572 579 } 573 580 574 - 581 + // Assign to role(s). 582 + xsysd->roles.head = head_wrap; 583 + xsysd->roles.left = left; 584 + xsysd->roles.right = right; 585 + xsysd->roles.hand_tracking.left = left_ht; 586 + xsysd->roles.hand_tracking.right = right_ht; 575 587 576 588 end: 577 589 if (result == XRT_SUCCESS) { 578 - *out_xsysd = &usysd->base; 579 - u_builder_create_space_overseer(&usysd->base, out_xso); 590 + *out_xsysd = xsysd; 591 + u_builder_create_space_overseer(xsysd, out_xso); 580 592 } else { 581 - u_system_devices_destroy(&usysd); 593 + xrt_system_devices_destroy(&xsysd); 582 594 } 583 595 if (nsb->config_json != NULL) { 584 596 cJSON_Delete(nsb->config_json);