d/vive: Use hand tracking if VIVE_USE_HANDTRACKING is set

This commit is contained in:
Moses Turner 2021-09-02 01:31:46 -05:00 committed by Moses Turner
parent db4a50410c
commit d7fc516cfb
2 changed files with 38 additions and 3 deletions

View file

@ -221,6 +221,10 @@ if(XRT_BUILD_DRIVER_VIVE)
target_link_libraries(drv_vive PRIVATE ${ZLIB_LIBRARIES})
target_include_directories(drv_vive PRIVATE ${ZLIB_INCLUDE_DIRS})
list(APPEND ENABLED_HEADSET_DRIVERS vive)
if (XRT_BUILD_DRIVER_HANDTRACKING)
target_link_libraries(drv_vive PRIVATE drv_ht)
endif()
endif()
if(XRT_HAVE_V4L2)

View file

@ -16,6 +16,10 @@
#include "vive_controller.h"
#include "vive_prober.h"
#include "../ht/ht_interface.h"
#include "../multi_wrapper/multi.h"
#include "xrt/xrt_config_drivers.h"
static const char VIVE_PRODUCT_STRING[] = "HTC Vive";
static const char VIVE_PRO_PRODUCT_STRING[] = "VIVE Pro";
static const char VALVE_INDEX_PRODUCT_STRING[] = "Index HMD";
@ -24,6 +28,10 @@ static const char VIVE_MANUFACTURER_STRING[] = "HTC";
DEBUG_GET_ONCE_LOG_OPTION(vive_log, "VIVE_LOG", U_LOGGING_WARN)
#ifdef XRT_BUILD_DRIVER_HANDTRACKING
DEBUG_GET_ONCE_BOOL_OPTION(vive_use_handtracking, "VIVE_USE_HANDTRACKING", false)
#endif
static int
log_vive_string(struct xrt_prober *xp, struct xrt_prober_device *dev, enum xrt_prober_string type)
{
@ -199,7 +207,7 @@ init_valve_index(struct xrt_prober *xp,
struct xrt_prober_device **devices,
size_t num_devices,
enum u_logging_level ll,
struct xrt_device **out_xdev)
struct xrt_device **out_xdevs)
{
log_vive_device(ll, xp, dev);
@ -239,9 +247,32 @@ init_valve_index(struct xrt_prober *xp,
return -1;
}
*out_xdev = &d->base;
int out_idx = 0;
return 1;
out_xdevs[out_idx++] = &d->base;
#ifdef XRT_BUILD_DRIVER_HANDTRACKING
if (debug_get_bool_option_vive_use_handtracking()) {
struct t_stereo_camera_calibration *cal = NULL;
struct xrt_pose head_in_left_cam;
// vive_get_stereo_camera_calibration(&ss->hmd->hmd.config, &cal, &head_in_left_cam);
vive_get_stereo_camera_calibration(&d->config, &cal, &head_in_left_cam);
struct xrt_device *ht = ht_device_create(xp, cal);
if (ht != NULL) { // Returns NULL if there's a problem and the hand tracker can't start. By no means a
// fatal error.
struct xrt_device *wrap =
multi_create_tracking_override(XRT_TRACKING_OVERRIDE_ATTACHED, ht, &d->base,
XRT_INPUT_GENERIC_HEAD_POSE, &head_in_left_cam);
out_xdevs[out_idx++] = wrap;
}
// Don't need it anymore. And it's not even created unless we hit this codepath, which is somewhat hard.
t_stereo_camera_calibration_reference(&cal, NULL);
}
#endif
return out_idx;
}
int