mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-04 06:06:17 +00:00
t/common: Integrate SteamVR Lighthouse driver into builder
Replaced VIVE_OVER_SURVIVE env var with LH_DRIVER, which takes a string and allows choosing one of the three lighthouse tracking implementations.
This commit is contained in:
parent
4a9f92e151
commit
a3c2b89067
|
@ -28,7 +28,10 @@ if(XRT_BUILD_DRIVER_RIFT_S)
|
||||||
target_sources(target_lists PRIVATE target_builder_rift_s.c)
|
target_sources(target_lists PRIVATE target_builder_rift_s.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(XRT_BUILD_DRIVER_SURVIVE OR XRT_BUILD_DRIVER_VIVE)
|
if(XRT_BUILD_DRIVER_SURVIVE
|
||||||
|
OR XRT_BUILD_DRIVER_VIVE
|
||||||
|
OR XRT_BUILD_DRIVER_STEAMVR_LIGHTHOUSE
|
||||||
|
)
|
||||||
target_sources(target_lists PRIVATE target_builder_lighthouse.c)
|
target_sources(target_lists PRIVATE target_builder_lighthouse.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -149,6 +152,10 @@ if(XRT_BUILD_DRIVER_SURVIVE)
|
||||||
target_link_libraries(target_lists PRIVATE drv_survive)
|
target_link_libraries(target_lists PRIVATE drv_survive)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(XRT_BUILD_DRIVER_STEAMVR_LIGHTHOUSE)
|
||||||
|
target_link_libraries(target_lists PRIVATE drv_steamvr_lh)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(XRT_BUILD_DRIVER_ANDROID)
|
if(XRT_BUILD_DRIVER_ANDROID)
|
||||||
target_link_libraries(target_lists PRIVATE drv_android)
|
target_link_libraries(target_lists PRIVATE drv_android)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -46,6 +46,10 @@
|
||||||
#include "survive/survive_interface.h"
|
#include "survive/survive_interface.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef XRT_BUILD_DRIVER_STEAMVR_LIGHTHOUSE
|
||||||
|
#include "steamvr_lh/steamvr_lh_interface.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef XRT_BUILD_DRIVER_HANDTRACKING
|
#ifdef XRT_BUILD_DRIVER_HANDTRACKING
|
||||||
#include "ht/ht_interface.h"
|
#include "ht/ht_interface.h"
|
||||||
#include "ht_ctrl_emu/ht_ctrl_emu_interface.h"
|
#include "ht_ctrl_emu/ht_ctrl_emu_interface.h"
|
||||||
|
@ -57,9 +61,16 @@
|
||||||
#include "opengloves/opengloves_interface.h"
|
#include "opengloves/opengloves_interface.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(XRT_BUILD_DRIVER_SURVIVE)
|
||||||
|
#define DEFAULT_DRIVER "survive"
|
||||||
|
#elif defined(XRT_BUILD_DRIVER_STEAMVR_LIGHTHOUSE)
|
||||||
|
#define DEFAULT_DRIVER "steamvr"
|
||||||
|
#else
|
||||||
|
#define DEFAULT_DRIVER "vive"
|
||||||
|
#endif
|
||||||
|
|
||||||
DEBUG_GET_ONCE_LOG_OPTION(lh_log, "LH_LOG", U_LOGGING_WARN)
|
DEBUG_GET_ONCE_LOG_OPTION(lh_log, "LH_LOG", U_LOGGING_WARN)
|
||||||
DEBUG_GET_ONCE_BOOL_OPTION(vive_over_survive, "VIVE_OVER_SURVIVE", false)
|
DEBUG_GET_ONCE_OPTION(lh_impl, "LH_DRIVER", DEFAULT_DRIVER)
|
||||||
DEBUG_GET_ONCE_BOOL_OPTION(vive_slam, "VIVE_SLAM", false)
|
DEBUG_GET_ONCE_BOOL_OPTION(vive_slam, "VIVE_SLAM", false)
|
||||||
DEBUG_GET_ONCE_TRISTATE_OPTION(lh_handtracking, "LH_HANDTRACKING")
|
DEBUG_GET_ONCE_TRISTATE_OPTION(lh_handtracking, "LH_HANDTRACKING")
|
||||||
|
|
||||||
|
@ -80,6 +91,10 @@ DEBUG_GET_ONCE_TRISTATE_OPTION(lh_handtracking, "LH_HANDTRACKING")
|
||||||
#define LH_ASSERT_(predicate) LH_ASSERT(predicate, "Assertion failed " #predicate)
|
#define LH_ASSERT_(predicate) LH_ASSERT(predicate, "Assertion failed " #predicate)
|
||||||
|
|
||||||
static const char *driver_list[] = {
|
static const char *driver_list[] = {
|
||||||
|
#ifdef XRT_BUILD_DRIVER_STEAMVR_LIGHTHOUSE
|
||||||
|
"steamvr_lh",
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef XRT_BUILD_DRIVER_SURVIVE
|
#ifdef XRT_BUILD_DRIVER_SURVIVE
|
||||||
"survive",
|
"survive",
|
||||||
#endif
|
#endif
|
||||||
|
@ -93,12 +108,18 @@ static const char *driver_list[] = {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum lighthouse_driver
|
||||||
|
{
|
||||||
|
DRIVER_VIVE,
|
||||||
|
DRIVER_SURVIVE,
|
||||||
|
DRIVER_STEAMVR
|
||||||
|
};
|
||||||
|
|
||||||
struct lighthouse_system
|
struct lighthouse_system
|
||||||
{
|
{
|
||||||
struct xrt_builder base;
|
struct xrt_builder base;
|
||||||
struct u_system_devices *devices;
|
struct u_system_devices *devices;
|
||||||
bool use_libsurvive; //!< Whether we are using survive driver or vive driver
|
enum lighthouse_driver driver; //!< Which lighthouse implementation we are using
|
||||||
bool is_valve_index; //!< Is our HMD a Valve Index? If so, try to set up hand-tracking and SLAM as needed
|
bool is_valve_index; //!< Is our HMD a Valve Index? If so, try to set up hand-tracking and SLAM as needed
|
||||||
struct vive_tracking_status vive_tstatus; //!< Visual tracking status for Index under Vive driver
|
struct vive_tracking_status vive_tstatus; //!< Visual tracking status for Index under Vive driver
|
||||||
struct xrt_fs *xfs; //!< Frameserver for Valve Index camera, if we have one.
|
struct xrt_fs *xfs; //!< Frameserver for Valve Index camera, if we have one.
|
||||||
|
@ -277,30 +298,34 @@ lighthouse_estimate_system(struct xrt_builder *xb,
|
||||||
bool have_survive_drv = false;
|
bool have_survive_drv = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool vive_over_survive = debug_get_bool_option_vive_over_survive();
|
#ifdef XRT_BUILD_DRIVER_STEAMVR_LIGHTHOUSE
|
||||||
if (have_survive_drv && have_vive_drv) {
|
bool have_steamvr_drv = true;
|
||||||
// We have both drivers - default to libsurvive, but if the user asks specifically for vive we'll give
|
#else
|
||||||
// it to them
|
bool have_steamvr_drv = false;
|
||||||
if (vive_over_survive) {
|
#endif
|
||||||
LH_DEBUG("Using driver vive (over survive)!");
|
|
||||||
} else {
|
const char *drv = debug_get_option_lh_impl();
|
||||||
LH_DEBUG("Using driver survive (both)!");
|
if (have_steamvr_drv && strcmp(drv, "steamvr") == 0) {
|
||||||
}
|
lhs->driver = DRIVER_STEAMVR;
|
||||||
lhs->use_libsurvive = !vive_over_survive;
|
} else if (have_survive_drv && strcmp(drv, "survive") == 0) {
|
||||||
} else if (have_survive_drv) {
|
lhs->driver = DRIVER_SURVIVE;
|
||||||
// We only have libsurvive - don't listen to the env var
|
} else if (have_vive_drv && strcmp(drv, "vive") == 0) {
|
||||||
// Note: this is a super edge-case, Vive gets built by default on Linux.
|
lhs->driver = DRIVER_VIVE;
|
||||||
if (vive_over_survive) {
|
|
||||||
LH_WARN("Asked for vive driver, but it isn't built. Using libsurvive.");
|
|
||||||
}
|
|
||||||
LH_DEBUG("Using driver survive (only built)!");
|
|
||||||
lhs->use_libsurvive = true;
|
|
||||||
} else if (have_vive_drv) {
|
|
||||||
LH_DEBUG("Using driver vive (only built)!");
|
|
||||||
// We only have vive
|
|
||||||
lhs->use_libsurvive = false;
|
|
||||||
} else {
|
} else {
|
||||||
LH_ASSERT_(false);
|
const char *selected;
|
||||||
|
if (have_survive_drv) {
|
||||||
|
selected = "survive";
|
||||||
|
lhs->driver = DRIVER_SURVIVE;
|
||||||
|
} else if (have_steamvr_drv) {
|
||||||
|
selected = "steamvr";
|
||||||
|
lhs->driver = DRIVER_STEAMVR;
|
||||||
|
} else if (have_vive_drv) {
|
||||||
|
selected = "vive";
|
||||||
|
lhs->driver = DRIVER_VIVE;
|
||||||
|
} else {
|
||||||
|
LH_ASSERT_(false);
|
||||||
|
}
|
||||||
|
LH_WARN("Requested driver %s was not available, so we went with %s instead", drv, selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
U_ZERO(estimate);
|
U_ZERO(estimate);
|
||||||
|
@ -325,7 +350,7 @@ lighthouse_estimate_system(struct xrt_builder *xb,
|
||||||
|
|
||||||
if (have_vive || have_vive_pro || lhs->is_valve_index) {
|
if (have_vive || have_vive_pro || lhs->is_valve_index) {
|
||||||
estimate->certain.head = true;
|
estimate->certain.head = true;
|
||||||
if (lhs->use_libsurvive) {
|
if (lhs->driver != DRIVER_VIVE) {
|
||||||
estimate->maybe.dof6 = true;
|
estimate->maybe.dof6 = true;
|
||||||
estimate->certain.dof6 = true;
|
estimate->certain.dof6 = true;
|
||||||
}
|
}
|
||||||
|
@ -415,7 +440,7 @@ valve_index_setup_visual_trackers(struct lighthouse_system *lhs,
|
||||||
|
|
||||||
t_stereo_camera_calibration_reference(&stereo_calib, NULL);
|
t_stereo_camera_calibration_reference(&stereo_calib, NULL);
|
||||||
|
|
||||||
if (!lhs->use_libsurvive) { // Refresh trackers status in vive driver
|
if (lhs->driver == DRIVER_VIVE) { // Refresh trackers status in vive driver
|
||||||
struct vive_device *d = (struct vive_device *)lhs->devices->base.roles.head;
|
struct vive_device *d = (struct vive_device *)lhs->devices->base.roles.head;
|
||||||
vive_set_trackers_status(d, lhs->vive_tstatus);
|
vive_set_trackers_status(d, lhs->vive_tstatus);
|
||||||
}
|
}
|
||||||
|
@ -552,7 +577,7 @@ lighthouse_open_system(struct xrt_builder *xb,
|
||||||
// Decide whether to initialize the SLAM tracker
|
// Decide whether to initialize the SLAM tracker
|
||||||
bool slam_wanted = debug_get_bool_option_vive_slam();
|
bool slam_wanted = debug_get_bool_option_vive_slam();
|
||||||
#ifdef XRT_FEATURE_SLAM
|
#ifdef XRT_FEATURE_SLAM
|
||||||
bool slam_supported = !lhs->use_libsurvive; // Only with vive driver
|
bool slam_supported = lhs->driver == DRIVER_VIVE; // Only with vive driver
|
||||||
#else
|
#else
|
||||||
bool slam_supported = false;
|
bool slam_supported = false;
|
||||||
#endif
|
#endif
|
||||||
|
@ -573,12 +598,21 @@ lighthouse_open_system(struct xrt_builder *xb,
|
||||||
.hand_wanted = debug_get_tristate_option_lh_handtracking()};
|
.hand_wanted = debug_get_tristate_option_lh_handtracking()};
|
||||||
lhs->vive_tstatus = tstatus;
|
lhs->vive_tstatus = tstatus;
|
||||||
|
|
||||||
if (lhs->use_libsurvive) {
|
switch (lhs->driver) {
|
||||||
|
case DRIVER_STEAMVR: {
|
||||||
|
#ifdef XRT_BUILD_DRIVER_STEAMVR_LIGHTHOUSE
|
||||||
|
usysd->base.xdev_count += steamvr_lh_get_devices(&usysd->base.xdevs[usysd->base.xdev_count]);
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DRIVER_SURVIVE: {
|
||||||
#ifdef XRT_BUILD_DRIVER_SURVIVE
|
#ifdef XRT_BUILD_DRIVER_SURVIVE
|
||||||
usysd->base.xdev_count +=
|
usysd->base.xdev_count +=
|
||||||
survive_get_devices(&usysd->base.xdevs[usysd->base.xdev_count], &lhs->hmd_config);
|
survive_get_devices(&usysd->base.xdevs[usysd->base.xdev_count], &lhs->hmd_config);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
break;
|
||||||
|
}
|
||||||
|
case DRIVER_VIVE: {
|
||||||
#ifdef XRT_BUILD_DRIVER_VIVE
|
#ifdef XRT_BUILD_DRIVER_VIVE
|
||||||
struct xrt_prober_device **xpdevs = NULL;
|
struct xrt_prober_device **xpdevs = NULL;
|
||||||
size_t xpdev_count = 0;
|
size_t xpdev_count = 0;
|
||||||
|
@ -617,7 +651,14 @@ lighthouse_open_system(struct xrt_builder *xb,
|
||||||
}
|
}
|
||||||
xrt_prober_unlock_list(xp, &xpdevs);
|
xrt_prober_unlock_list(xp, &xpdevs);
|
||||||
#endif
|
#endif
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
default: {
|
||||||
|
LH_ASSERT(false, "Driver was not set to a known value");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int head_idx = -1;
|
int head_idx = -1;
|
||||||
int left_idx = -1;
|
int left_idx = -1;
|
||||||
int right_idx = -1;
|
int right_idx = -1;
|
||||||
|
|
Loading…
Reference in a new issue