The open source OpenXR runtime
0
fork

Configure Feed

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

d/survive: Use hand tracking if there aren't any controllers

rebase-survive

authored by

Moses Turner and committed by
Moses Turner
db4a5041 624a676f

+37 -2
+4
src/xrt/drivers/CMakeLists.txt
··· 277 277 add_library(drv_survive STATIC ${SURVIVE_SOURCE_FILES}) 278 278 target_link_libraries(drv_survive PRIVATE xrt-interfaces aux_os aux_util aux_math aux_vive PkgConfig::SURVIVE) 279 279 list(APPEND ENABLED_HEADSET_DRIVERS survive) 280 + 281 + if (XRT_BUILD_DRIVER_HANDTRACKING) 282 + target_link_libraries(drv_survive PRIVATE drv_ht) 283 + endif() 280 284 endif() 281 285 282 286 if(XRT_BUILD_DRIVER_ANDROID)
+33 -2
src/xrt/drivers/survive/survive_driver.c
··· 5 5 * @brief Adapter to Libsurvive. 6 6 * @author Christoph Haag <christoph.haag@collabora.com> 7 7 * @author Jakob Bornecrantz <jakob@collabora.com> 8 + * @author Moses Turner <moses@collabora.com> 8 9 * @ingroup drv_survive 9 10 */ 10 11 ··· 17 18 #include <inttypes.h> 18 19 19 20 #include "math/m_api.h" 21 + #include "tracking/t_tracking.h" 20 22 #include "xrt/xrt_device.h" 21 23 #include "util/u_debug.h" 22 24 #include "util/u_device.h" ··· 28 30 29 31 #include "os/os_threading.h" 30 32 31 - #include "../auxiliary/os/os_time.h" 33 + #include "os/os_time.h" 32 34 33 35 #include "xrt/xrt_prober.h" 34 36 #include "survive_interface.h" ··· 43 45 #include "math/m_predict.h" 44 46 45 47 #include "vive/vive_config.h" 48 + 49 + #include "../ht/ht_interface.h" 50 + #include "../multi_wrapper/multi.h" 51 + #include "xrt/xrt_config_drivers.h" 52 + 46 53 #include "survive_driver.h" 47 54 48 55 // reading usb config takes libsurvive about 50ms per device ··· 1333 1340 out_xdevs[out_idx++] = &ss->hmd->base; 1334 1341 } 1335 1342 1343 + bool found_controllers = false; 1344 + 1336 1345 for (int i = 0; i < MAX_TRACKED_DEVICE_COUNT; i++) { 1337 1346 1338 1347 if (out_idx == XRT_MAX_DEVICES_PER_PROBE - 1) { ··· 1343 1352 1344 1353 if (ss->controllers[i] != NULL) { 1345 1354 out_xdevs[out_idx++] = &ss->controllers[i]->base; 1355 + found_controllers = true; 1346 1356 } 1347 1357 } 1348 1358 1359 + #ifdef XRT_BUILD_DRIVER_HANDTRACKING 1360 + // We want to hit this codepath when we find a HMD but no controllers. 1361 + if ((ss->hmd != NULL) && !found_controllers) { 1362 + struct t_stereo_camera_calibration *cal = NULL; 1363 + 1364 + struct xrt_pose head_in_left_cam; 1365 + vive_get_stereo_camera_calibration(&ss->hmd->hmd.config, &cal, &head_in_left_cam); 1366 + 1367 + struct xrt_device *ht = ht_device_create(xp, cal); 1368 + if (ht != NULL) { // Returns NULL if there's a problem and the hand tracker can't start. By no means a 1369 + // fatal error. 1370 + struct xrt_device *wrap = 1371 + multi_create_tracking_override(XRT_TRACKING_OVERRIDE_ATTACHED, ht, &ss->hmd->base, 1372 + XRT_INPUT_GENERIC_HEAD_POSE, &head_in_left_cam); 1373 + out_xdevs[out_idx++] = wrap; 1374 + } 1375 + // Don't need it anymore. And it's not even created unless we hit this codepath, which is somewhat hard. 1376 + t_stereo_camera_calibration_reference(&cal, NULL); 1377 + } 1378 + #endif 1379 + 1380 + 1349 1381 survive_already_initialized = true; 1350 1382 1351 1383 // Mutex before thread. ··· 1368 1400 } 1369 1401 return 0; 1370 1402 } 1371 - 1372 1403 return out_idx; 1373 1404 }