The open source OpenXR runtime
0
fork

Configure Feed

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

t/common: Refactor lighthouse builder to use vive_builder helper

+11 -60
+11 -60
src/xrt/targets/common/target_builder_lighthouse.c
··· 27 27 #include "vive/vive_common.h" 28 28 #include "vive/vive_config.h" 29 29 #include "vive/vive_calibration.h" 30 + #include "vive/vive_builder.h" 30 31 #include "vive/vive_device.h" 31 32 #include "vive/vive_source.h" 32 33 #include "v4l2/v4l2_interface.h" ··· 337 338 LH_WARN("Requested driver %s was not available, so we went with %s instead", drv, selected); 338 339 } 339 340 340 - U_ZERO(estimate); 341 - 342 - struct u_builder_search_results results = {0}; 343 - struct xrt_prober_device **xpdevs = NULL; 344 - size_t xpdev_count = 0; 345 - xrt_result_t xret = XRT_SUCCESS; 346 - 347 - // Lock the device list 348 - xret = xrt_prober_lock_list(xp, &xpdevs, &xpdev_count); 349 - if (xret != XRT_SUCCESS) { 350 - return xret; 351 - } 352 - 353 - bool have_vive = u_builder_find_prober_device(xpdevs, xpdev_count, HTC_VID, VIVE_PID, XRT_BUS_TYPE_USB); 354 - bool have_vive_pro = 355 - u_builder_find_prober_device(xpdevs, xpdev_count, HTC_VID, VIVE_PRO_MAINBOARD_PID, XRT_BUS_TYPE_USB); 356 - lhs->is_valve_index = 357 - u_builder_find_prober_device(xpdevs, xpdev_count, VALVE_VID, VIVE_PRO_LHR_PID, XRT_BUS_TYPE_USB); 358 - 359 - 360 - if (have_vive || have_vive_pro || lhs->is_valve_index) { 361 - estimate->certain.head = true; 362 - if (lhs->driver != DRIVER_VIVE) { 363 - estimate->maybe.dof6 = true; 364 - estimate->certain.dof6 = true; 365 - } 366 - } 367 - 368 341 #ifdef XRT_BUILD_DRIVER_HANDTRACKING 369 - // Valve Indices have UVC stereo cameras on the front. If we've found an Index, we'll probably be able to open 370 - // the camera and use it to track hands even if we haven't found controllers. 371 - if (lhs->is_valve_index) { 372 - estimate->maybe.left = true; 373 - estimate->maybe.right = true; 374 - } 342 + bool have_hand_tracking = true; 343 + #else 344 + bool have_hand_tracking = false; 375 345 #endif 376 346 377 - static struct u_builder_search_filter maybe_controller_filters[] = { 378 - {VALVE_VID, VIVE_WATCHMAN_DONGLE, XRT_BUS_TYPE_USB}, 379 - {VALVE_VID, VIVE_WATCHMAN_DONGLE_GEN2, XRT_BUS_TYPE_USB}, 380 - }; 381 - 382 - results.xpdev_count = 0; 383 - xpdev_count = 0; 347 + bool have_6dof = lhs->driver != DRIVER_VIVE; 384 348 385 - u_builder_search(xp, xpdevs, xpdev_count, maybe_controller_filters, ARRAY_SIZE(maybe_controller_filters), 386 - &results); 387 - if (results.xpdev_count != 0) { 388 - estimate->maybe.left = true; 389 - estimate->maybe.right = true; 390 - 391 - // Good assumption that if the user has more than 2 wireless devices, two of them will be controllers 392 - // and the rest will be vive trackers. 393 - if (results.xpdev_count > 2) { 394 - estimate->maybe.extra_device_count = results.xpdev_count - 2; 395 - } 396 - } 397 - 398 - estimate->priority = 0; 399 - 400 - xret = xrt_prober_unlock_list(xp, &xpdevs); 401 - LH_ASSERT_(xret == XRT_SUCCESS); 402 - 403 - return XRT_SUCCESS; 349 + return vive_builder_estimate( // 350 + xp, // xp 351 + have_6dof, // have_6dof 352 + have_hand_tracking, // have_hand_tracking 353 + &lhs->is_valve_index, // out_have_valve_index 354 + estimate); // out_estimate 404 355 } 405 356 406 357 // If the HMD is a Valve Index, decide if we want visual (HT/Slam) trackers, and if so set them up.