The open source OpenXR runtime
0
fork

Configure Feed

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

t/common: Make controllers work again with the Lighthouse builder

!1418 briefly broke controller setup.

authored by

Moses Turner and committed by
Jakob Bornecrantz
2868348e 0c4b45c6

+79 -47
+13 -1
src/xrt/drivers/vive/vive_device.h
··· 12 12 #include "xrt/xrt_device.h" 13 13 #include "os/os_threading.h" 14 14 #include "util/u_logging.h" 15 + #include "util/u_debug.h" 15 16 #include "util/u_time.h" 16 17 #include "util/u_var.h" 17 18 #include "math/m_imu_3dof.h" ··· 122 123 bool slam_wanted; 123 124 bool slam_supported; 124 125 bool slam_enabled; 125 - bool hand_wanted; 126 + 127 + //! Has Monado been built with the correct libraries to do optical hand tracking? 126 128 bool hand_supported; 129 + 130 + //! Did we find controllers? 131 + bool controllers_found; 132 + 133 + //! If this is set to ON, we always do optical hand tracking even if controllers were found. 134 + //! If this is set to AUTO, we do optical hand tracking only if no controllers were found. 135 + //! If this is set to OFF, we don't do optical hand tracking. 136 + enum debug_tristate_option hand_wanted; 137 + 138 + //! Computed in target_builder_lighthouse.c based on the past three 127 139 bool hand_enabled; 128 140 }; 129 141
+66 -46
src/xrt/targets/common/target_builder_lighthouse.c
··· 64 64 DEBUG_GET_ONCE_LOG_OPTION(lh_log, "LH_LOG", U_LOGGING_WARN) 65 65 DEBUG_GET_ONCE_BOOL_OPTION(vive_over_survive, "VIVE_OVER_SURVIVE", false) 66 66 DEBUG_GET_ONCE_BOOL_OPTION(vive_slam, "VIVE_SLAM", true) 67 - DEBUG_GET_ONCE_BOOL_OPTION(lh_handtracking, "LH_HANDTRACKING", true) 67 + DEBUG_GET_ONCE_TRISTATE_OPTION(lh_handtracking, "LH_HANDTRACKING") 68 68 DEBUG_GET_ONCE_BOOL_OPTION(ht_use_old_rgb, "HT_USE_OLD_RGB", false) 69 69 70 70 #define LH_TRACE(...) U_LOG_IFL_T(debug_get_log_option_lh_log(), __VA_ARGS__) ··· 482 482 return success; 483 483 } 484 484 485 + static void 486 + try_add_opengloves(struct u_system_devices *usysd) 487 + { 488 + #ifdef XRT_BUILD_DRIVER_OPENGLOVES 489 + size_t openglove_device_count = 490 + opengloves_create_devices(&usysd->base.xdevs[usysd->base.xdev_count], &usysd->base); 491 + for (size_t i = usysd->base.xdev_count; i < usysd->base.xdev_count + openglove_device_count; i++) { 492 + struct xrt_device *xdev = usysd->base.xdevs[i]; 493 + 494 + for (uint32_t j = 0; j < xdev->input_count; j++) { 495 + struct xrt_input *input = &xdev->inputs[j]; 496 + 497 + if (input->name == XRT_INPUT_GENERIC_HAND_TRACKING_LEFT) { 498 + usysd->base.roles.hand_tracking.left = xdev; 499 + 500 + break; 501 + } 502 + if (input->name == XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT) { 503 + usysd->base.roles.hand_tracking.right = xdev; 504 + 505 + break; 506 + } 507 + } 508 + } 509 + 510 + usysd->base.xdev_count += openglove_device_count; 511 + 512 + #endif 513 + } 514 + 485 515 static xrt_result_t 486 516 lighthouse_open_system(struct xrt_builder *xb, 487 517 cJSON *config, ··· 507 537 bool slam_enabled = slam_supported && slam_wanted; 508 538 509 539 // Decide whether to initialize the hand tracker 510 - bool hand_wanted = debug_get_bool_option_lh_handtracking(); 511 540 #ifdef XRT_BUILD_DRIVER_HANDTRACKING 512 541 bool hand_supported = true; 513 542 #else 514 543 bool hand_supported = false; 515 544 #endif 516 - bool hand_enabled = hand_supported && hand_wanted; 517 545 518 - struct vive_tracking_status tstatus = { 519 - .slam_wanted = slam_wanted, 520 - .slam_supported = slam_supported, 521 - .slam_enabled = slam_enabled, 522 - .hand_wanted = hand_wanted, 523 - .hand_supported = hand_supported, 524 - .hand_enabled = hand_enabled, 525 - }; 546 + struct vive_tracking_status tstatus = {.slam_wanted = slam_wanted, 547 + .slam_supported = slam_supported, 548 + .slam_enabled = slam_enabled, 549 + .controllers_found = false, 550 + .hand_supported = hand_supported, 551 + .hand_wanted = debug_get_tristate_option_lh_handtracking()}; 526 552 lhs.vive_tstatus = tstatus; 527 553 528 554 struct vive_config *hmd_config = NULL; ··· 585 611 586 612 // It's okay if we didn't find controllers 587 613 if (left_idx >= 0) { 614 + lhs.vive_tstatus.controllers_found = true; 588 615 usysd->base.roles.left = usysd->base.xdevs[left_idx]; 589 616 usysd->base.roles.hand_tracking.left = 590 617 u_system_devices_get_ht_device(usysd, XRT_INPUT_GENERIC_HAND_TRACKING_LEFT); 591 618 } 592 619 593 620 if (right_idx >= 0) { 621 + lhs.vive_tstatus.controllers_found = true; 594 622 usysd->base.roles.right = usysd->base.xdevs[right_idx]; 595 623 usysd->base.roles.hand_tracking.right = 596 624 u_system_devices_get_ht_device(usysd, XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT); 597 625 } 598 626 627 + if (lhs.vive_tstatus.hand_wanted == DEBUG_TRISTATE_ON) { 628 + lhs.vive_tstatus.hand_enabled = true; 629 + } else if (lhs.vive_tstatus.hand_wanted == DEBUG_TRISTATE_AUTO) { 630 + if (lhs.vive_tstatus.controllers_found) { 631 + lhs.vive_tstatus.hand_enabled = false; 632 + } else { 633 + lhs.vive_tstatus.hand_enabled = true; 634 + } 635 + } else if (lhs.vive_tstatus.hand_wanted == DEBUG_TRISTATE_OFF) { 636 + lhs.vive_tstatus.hand_enabled = false; 637 + } 638 + 599 639 bool success = true; 600 640 601 641 struct xrt_slam_sinks sinks = {0}; ··· 606 646 goto end; 607 647 } 608 648 609 - if (hand_devices[0] != NULL) { 610 - usysd->base.roles.left = hand_devices[0]; 611 - usysd->base.roles.hand_tracking.left = hand_devices[0]; 612 - usysd->base.xdevs[usysd->base.xdev_count++] = hand_devices[0]; 613 - } 649 + if (lhs.vive_tstatus.hand_enabled) { 650 + if (hand_devices[0] != NULL) { 651 + usysd->base.roles.left = hand_devices[0]; 652 + usysd->base.roles.hand_tracking.left = hand_devices[0]; 653 + usysd->base.xdevs[usysd->base.xdev_count++] = hand_devices[0]; 654 + } 614 655 615 - if (hand_devices[1] != NULL) { 616 - usysd->base.roles.right = hand_devices[1]; 617 - usysd->base.roles.hand_tracking.right = hand_devices[1]; 618 - usysd->base.xdevs[usysd->base.xdev_count++] = hand_devices[1]; 656 + if (hand_devices[1] != NULL) { 657 + usysd->base.roles.right = hand_devices[1]; 658 + usysd->base.roles.hand_tracking.right = hand_devices[1]; 659 + usysd->base.xdevs[usysd->base.xdev_count++] = hand_devices[1]; 660 + } 619 661 } 620 662 621 663 success = stream_data_sources(usysd, xp, sinks); ··· 624 666 goto end; 625 667 } 626 668 627 - #ifdef XRT_BUILD_DRIVER_OPENGLOVES 628 - size_t openglove_device_count = 629 - opengloves_create_devices(&usysd->base.xdevs[usysd->base.xdev_count], &usysd->base); 630 - for (size_t i = usysd->base.xdev_count; i < usysd->base.xdev_count + openglove_device_count; i++) { 631 - struct xrt_device *xdev = usysd->base.xdevs[i]; 632 669 633 - for (uint32_t j = 0; j < xdev->input_count; j++) { 634 - struct xrt_input *input = &xdev->inputs[j]; 635 - 636 - if (input->name == XRT_INPUT_GENERIC_HAND_TRACKING_LEFT) { 637 - usysd->base.roles.hand_tracking.left = xdev; 638 - 639 - break; 640 - } 641 - if (input->name == XRT_INPUT_GENERIC_HAND_TRACKING_RIGHT) { 642 - usysd->base.roles.hand_tracking.right = xdev; 643 - 644 - break; 645 - } 646 - } 670 + end: 671 + if (!lhs.vive_tstatus.hand_enabled) { 672 + // We only want to try to add opengloves if we aren't optically tracking hands 673 + try_add_opengloves(usysd); 647 674 } 648 - 649 - usysd->base.xdev_count += openglove_device_count; 650 - 651 - #endif 652 - 653 - *out_xsysd = &usysd->base; 654 - end: 655 675 656 676 if (result == XRT_SUCCESS) { 657 677 *out_xsysd = &usysd->base;