The open source OpenXR runtime
0
fork

Configure Feed

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

d/vive: Use hand tracking if VIVE_USE_HANDTRACKING is set

authored by

Moses Turner and committed by
Moses Turner
d7fc516c db4a5041

+38 -3
+4
src/xrt/drivers/CMakeLists.txt
··· 221 221 target_link_libraries(drv_vive PRIVATE ${ZLIB_LIBRARIES}) 222 222 target_include_directories(drv_vive PRIVATE ${ZLIB_INCLUDE_DIRS}) 223 223 list(APPEND ENABLED_HEADSET_DRIVERS vive) 224 + 225 + if (XRT_BUILD_DRIVER_HANDTRACKING) 226 + target_link_libraries(drv_vive PRIVATE drv_ht) 227 + endif() 224 228 endif() 225 229 226 230 if(XRT_HAVE_V4L2)
+34 -3
src/xrt/drivers/vive/vive_prober.c
··· 16 16 #include "vive_controller.h" 17 17 #include "vive_prober.h" 18 18 19 + #include "../ht/ht_interface.h" 20 + #include "../multi_wrapper/multi.h" 21 + #include "xrt/xrt_config_drivers.h" 22 + 19 23 static const char VIVE_PRODUCT_STRING[] = "HTC Vive"; 20 24 static const char VIVE_PRO_PRODUCT_STRING[] = "VIVE Pro"; 21 25 static const char VALVE_INDEX_PRODUCT_STRING[] = "Index HMD"; ··· 23 27 static const char VIVE_MANUFACTURER_STRING[] = "HTC"; 24 28 25 29 DEBUG_GET_ONCE_LOG_OPTION(vive_log, "VIVE_LOG", U_LOGGING_WARN) 30 + 31 + #ifdef XRT_BUILD_DRIVER_HANDTRACKING 32 + DEBUG_GET_ONCE_BOOL_OPTION(vive_use_handtracking, "VIVE_USE_HANDTRACKING", false) 33 + #endif 26 34 27 35 static int 28 36 log_vive_string(struct xrt_prober *xp, struct xrt_prober_device *dev, enum xrt_prober_string type) ··· 199 207 struct xrt_prober_device **devices, 200 208 size_t num_devices, 201 209 enum u_logging_level ll, 202 - struct xrt_device **out_xdev) 210 + struct xrt_device **out_xdevs) 203 211 { 204 212 log_vive_device(ll, xp, dev); 205 213 ··· 239 247 return -1; 240 248 } 241 249 242 - *out_xdev = &d->base; 250 + int out_idx = 0; 251 + 252 + out_xdevs[out_idx++] = &d->base; 253 + 254 + #ifdef XRT_BUILD_DRIVER_HANDTRACKING 255 + if (debug_get_bool_option_vive_use_handtracking()) { 256 + struct t_stereo_camera_calibration *cal = NULL; 257 + 258 + struct xrt_pose head_in_left_cam; 259 + // vive_get_stereo_camera_calibration(&ss->hmd->hmd.config, &cal, &head_in_left_cam); 260 + vive_get_stereo_camera_calibration(&d->config, &cal, &head_in_left_cam); 261 + 262 + struct xrt_device *ht = ht_device_create(xp, cal); 263 + if (ht != NULL) { // Returns NULL if there's a problem and the hand tracker can't start. By no means a 264 + // fatal error. 265 + struct xrt_device *wrap = 266 + multi_create_tracking_override(XRT_TRACKING_OVERRIDE_ATTACHED, ht, &d->base, 267 + XRT_INPUT_GENERIC_HEAD_POSE, &head_in_left_cam); 268 + out_xdevs[out_idx++] = wrap; 269 + } 270 + // Don't need it anymore. And it's not even created unless we hit this codepath, which is somewhat hard. 271 + t_stereo_camera_calibration_reference(&cal, NULL); 272 + } 273 + #endif 243 274 244 - return 1; 275 + return out_idx; 245 276 } 246 277 247 278 int