Commit b0d38286 authored by Christoph Haag's avatar Christoph Haag

d/survive: Add libsurvive with positional tracking as submodule

parent 5f0ba122
[submodule "src/external/libsurvive"]
path = src/external/libsurvive
url = https://github.com/cnlohr/libsurvive.git
......@@ -71,11 +71,11 @@ cmake_dependent_option(BUILD_WITH_OPENCV "Enable OpenCV backend" ON "OpenCV_FOUN
cmake_dependent_option(BUILD_WITH_LIBUVC "Enable libuvc video driver" ON "LIBUVC_FOUND" OFF)
cmake_dependent_option(BUILD_WITH_FFMPEG "Enable ffmpeg testing video driver" ON "FFMPEG_FOUND" OFF)
cmake_dependent_option(BUILD_WITH_PSVR "Enable PSVR HMD driver" ON "HIDAPI_FOUND" OFF)
cmake_dependent_option(BUILD_WITH_VIVE "Enable Vive driver" OFF "ZLIB_FOUND" OFF)
option(BUILD_WITH_DUMMY "Enable dummy driver" ON)
cmake_dependent_option(BUILD_WITH_VIVE "Enable Vive driver" ON "ZLIB_FOUND" OFF)
cmake_dependent_option(BUILD_WITH_OPENHMD "Enable OpenHMD driver" ON "OPENHMD_FOUND" OFF)
cmake_dependent_option(BUILD_WITH_SDL2 "Enable SDL2 based test application" ON "SDL2_FOUND" OFF)
option(BUILD_WITH_LIBSURVIVE "Enable libsurvive driver" ON)
cmake_dependent_option(BUILD_WITH_OPENHMD "Enable OpenHMD driver" OFF "OPENHMD_FOUND" OFF)
# These all use the Monado internal hid wrapper which is assumed to be available.
option(BUILD_WITH_HDK "Enable HDK driver" ON)
option(BUILD_WITH_PSMV "Enable Playstation Move driver" ON)
......@@ -143,6 +143,10 @@ endif()
if(BUILD_WITH_NS)
set(BUILD_DRIVER_NS TRUE)
endif()
if (BUILD_WITH_LIBSURVIVE)
add_definitions(-DXRT_BUILD_SURVIVE)
set(BUILD_DRIVER_SURVIVE TRUE)
endif()
if(BUILD_WITH_PSVR)
if (NOT ${HIDAPI_FOUND})
......
# Monado - XR Runtime (XRT)
# Monado - XR Runtime (XRT) - experimental libsurvive branch
> * Promotional homepage: <https://monado.dev>
> * Maintained at <https://gitlab.freedesktop.org/monado/monado>
......@@ -15,6 +15,28 @@ The project currently is being developed for GNU/Linux
and aims to support other operating systems in the near future.
"Monado" has no specific meaning and is just a name.
# About the libsurvive Branch
This branch contains libsurvive as a submodule in src/xrt/external/libsurvive.
Libsurvive is compiled as a shared library and the runtime links to libsurvive.
A device prober using the libsurvive simple api is implemented in src/xrt/drivers/survive.
When starting an OpenXR application, libsurvive will run calibration and save configuration
and calibration data in the current working directory.
Make sure the HMD can see both basestations and is not moved during calibration.
To remove libsurvive's calibration data delete the following files/directories:
rm -r config.json HMD_config.json calinfo
Though working and usable, support for the libsurvive driver is **experimental**.
For example it contains many hardcoded values from OpenHMD's configuration for the Vive 1 and
does not behave well yet when no Vive is connected.
libsurvive may only build when the `-DUSE_OPENCV=OFF` cmake option is used.
## Monado source tree
* `src/xrt/include` - headers that define the internal interfaces of Monado.
......
# Copyright 2019-2020, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
if (BUILD_WITH_LIBSURVIVE)
add_subdirectory(external/libsurvive)
endif()
if(BUILD_TRACKING)
set(XRT_BUILD_TRACKING TRUE)
......
Subproject commit 592ff220e5243c80502fa449f37bd5c35eefcc6c
......@@ -140,3 +140,21 @@ if(ENABLED_HEADSET_DRIVERS)
else()
message(FATAL_ERROR "You must enable at least one headset driver to build Monado.")
endif()
if (BUILD_WITH_LIBSURVIVE)
set(SURVIVE_SOURCE_FILES
survive/survive_driver.c
survive/survive_interface.h
)
# Use OBJECT to not create a archive, since it just gets in the way.
add_library(drv_survive OBJECT ${SURVIVE_SOURCE_FILES})
set_property(TARGET drv_survive PROPERTY POSITION_INDEPENDENT_CODE ON)
target_include_directories(drv_survive SYSTEM
PRIVATE
${PROJECT_SOURCE_DIR}/src/external/libsurvive/include
${PROJECT_SOURCE_DIR}/src/external/libsurvive/include/libsurvive
${PROJECT_SOURCE_DIR}/src/external/libsurvive/redist
)
endif()
This diff is collapsed.
// Copyright 2019, Collabora, Ltd.
// SPDX-License-Identifier: Apache-2.0
/*!
* @file
* @brief Interface to OpenHMD driver code.
* @author Jakob Bornecrantz <jakob@collabora.com>
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#define HTC_VID 0x0bb4
#define VALVE_VID 0x28de
#define VIVE_PID 0x2c87
#define VIVE_LIGHTHOUSE_FPGA_RX 0x2000
#define VIVE_PRO_MAINBOARD_PID 0x0309
#define VIVE_PRO_LHR_PID 0x2300
int
survive_found(struct xrt_prober *xp,
struct xrt_prober_device **devices,
size_t num_devices,
size_t index,
struct xrt_device **out_xdevs);
#ifdef __cplusplus
}
#endif
......@@ -347,6 +347,7 @@ enum xrt_device_name
XRT_DEVICE_PSMV = 2,
XRT_DEVICE_HYDRA = 3,
XRT_DEVICE_INDEX_CONTROLLER = 4
};
/*!
......@@ -431,6 +432,32 @@ enum xrt_input_name
XRT_INPUT_HYDRA_JOYSTICK_VALUE = XRT_INPUT_NAME(0x0037, VEC2_MINUS_ONE_TO_ONE),
XRT_INPUT_HYDRA_TRIGGER_VALUE = XRT_INPUT_NAME(0x0038, VEC1_ZERO_TO_ONE),
XRT_INPUT_HYDRA_POSE = XRT_INPUT_NAME(0x0039, POSE),
XRT_INPUT_INDEX_SYSTEM_CLICK = XRT_INPUT_NAME(0x0040, BOOLEAN),
XRT_INPUT_INDEX_SYSTEM_TOUCH = XRT_INPUT_NAME(0x0041, BOOLEAN),
XRT_INPUT_INDEX_A_CLICK = XRT_INPUT_NAME(0x0042, BOOLEAN),
XRT_INPUT_INDEX_A_TOUCH = XRT_INPUT_NAME(0x0043, BOOLEAN),
XRT_INPUT_INDEX_B_CLICK = XRT_INPUT_NAME(0x0044, BOOLEAN),
XRT_INPUT_INDEX_B_TOUCH = XRT_INPUT_NAME(0x0045, BOOLEAN),
XRT_INPUT_INDEX_SQUEEZE_VALUE = XRT_INPUT_NAME(0x0046, VEC1_ZERO_TO_ONE),
XRT_INPUT_INDEX_SQUEEZE_FORCE = XRT_INPUT_NAME(0x0047, VEC1_ZERO_TO_ONE),
XRT_INPUT_INDEX_TRIGGER_CLICK = XRT_INPUT_NAME(0x0048, BOOLEAN),
XRT_INPUT_INDEX_TRIGGER_VALUE = XRT_INPUT_NAME(0x0049, VEC1_ZERO_TO_ONE),
XRT_INPUT_INDEX_TRIGGER_TOUCH = XRT_INPUT_NAME(0x004A, BOOLEAN),
XRT_INPUT_INDEX_THUMBSTICK_X = XRT_INPUT_NAME(0x004B, VEC1_ZERO_TO_ONE),
XRT_INPUT_INDEX_THUMBSTICK_Y = XRT_INPUT_NAME(0x004C, VEC1_ZERO_TO_ONE),
XRT_INPUT_INDEX_THUMBSTICK_CLICK = XRT_INPUT_NAME(0x004D, BOOLEAN),
XRT_INPUT_INDEX_THUMBSTICK_TOUCH = XRT_INPUT_NAME(0x004E, BOOLEAN),
XRT_INPUT_INDEX_TRACKPAD_X = XRT_INPUT_NAME(0x004F, VEC1_ZERO_TO_ONE),
XRT_INPUT_INDEX_TRACKPAD_Y = XRT_INPUT_NAME(0x0050, VEC1_ZERO_TO_ONE),
XRT_INPUT_INDEX_TRACKPAD_FORCE = XRT_INPUT_NAME(0x0051, VEC1_ZERO_TO_ONE),
XRT_INPUT_INDEX_TRACKPAD_TOUCH = XRT_INPUT_NAME(0x0052, BOOLEAN),
XRT_INPUT_INDEX_GRIP_POSE = XRT_INPUT_NAME(0x0053, POSE),
XRT_INPUT_INDEX_AIM_POSE = XRT_INPUT_NAME(0x0054, POSE),
// special hacky values
XRT_INPUT_INDEX_THUMBSTICK_XY = XRT_INPUT_NAME(0x0055, VEC2_MINUS_ONE_TO_ONE),
XRT_INPUT_INDEX_TRACKPAD_XY = XRT_INPUT_NAME(0x0056, VEC2_MINUS_ONE_TO_ONE),
// clang-format on
};
......@@ -472,6 +499,7 @@ enum xrt_output_name
{
// clang-format off
XRT_OUTPUT_NAME_PSMV_RUMBLE_VIBRATION = XRT_OUTPUT_NAME(0x0020, VIBRATION),
XRT_OUTPUT_NAME_INDEX_HAPTIC = XRT_OUTPUT_NAME(0x0030, VIBRATION),
// clang-format on
};
......
......@@ -249,6 +249,12 @@ oxr_find_profile_for_device(struct oxr_logger *log,
interaction_profile_find(log, inst, inst->path_cache.mnd_ball_on_stick_controller, out_p);
// clang-format on
return;
case XRT_DEVICE_INDEX_CONTROLLER:
// clang-format off
interaction_profile_find(log, inst, inst->path_cache.khr_simple_controller, out_p);
interaction_profile_find(log, inst, inst->path_cache.valve_index_controller, out_p);
// clang-format on
return;
default: return;
}
}
......
......@@ -11,7 +11,6 @@
#include "oxr_objects.h"
struct binding_template
{
enum oxr_sub_action_path sub_path;
......@@ -59,6 +58,7 @@ static struct binding_template khr_simple_controller_bindings[10] = {
{
XRT_INPUT_PSMV_TRIGGER_VALUE,
XRT_INPUT_HYDRA_TRIGGER_VALUE,
XRT_INPUT_INDEX_TRIGGER_VALUE,
(enum xrt_input_name)0,
},
},
......@@ -74,6 +74,7 @@ static struct binding_template khr_simple_controller_bindings[10] = {
{
XRT_INPUT_PSMV_MOVE_CLICK,
XRT_INPUT_HYDRA_MIDDLE_CLICK,
XRT_INPUT_INDEX_B_CLICK,
(enum xrt_input_name)0,
},
},
......@@ -89,6 +90,7 @@ static struct binding_template khr_simple_controller_bindings[10] = {
{
XRT_INPUT_PSMV_BODY_CENTER_POSE,
XRT_INPUT_HYDRA_POSE,
XRT_INPUT_INDEX_GRIP_POSE,
(enum xrt_input_name)0,
},
},
......@@ -104,6 +106,7 @@ static struct binding_template khr_simple_controller_bindings[10] = {
{
XRT_INPUT_PSMV_BALL_TIP_POSE,
XRT_INPUT_HYDRA_POSE,
XRT_INPUT_INDEX_AIM_POSE,
(enum xrt_input_name)0,
},
},
......@@ -132,6 +135,7 @@ static struct binding_template khr_simple_controller_bindings[10] = {
{
XRT_INPUT_PSMV_TRIGGER_VALUE,
XRT_INPUT_HYDRA_TRIGGER_VALUE,
XRT_INPUT_INDEX_TRIGGER_VALUE,
(enum xrt_input_name)0,
},
},
......@@ -147,6 +151,7 @@ static struct binding_template khr_simple_controller_bindings[10] = {
{
XRT_INPUT_PSMV_MOVE_CLICK,
XRT_INPUT_HYDRA_MIDDLE_CLICK,
XRT_INPUT_INDEX_B_CLICK,
(enum xrt_input_name)0,
},
},
......@@ -162,6 +167,7 @@ static struct binding_template khr_simple_controller_bindings[10] = {
{
XRT_INPUT_PSMV_BODY_CENTER_POSE,
XRT_INPUT_HYDRA_POSE,
XRT_INPUT_INDEX_GRIP_POSE,
(enum xrt_input_name)0,
},
},
......@@ -177,6 +183,7 @@ static struct binding_template khr_simple_controller_bindings[10] = {
{
XRT_INPUT_PSMV_BALL_TIP_POSE,
XRT_INPUT_HYDRA_POSE,
XRT_INPUT_INDEX_AIM_POSE,
(enum xrt_input_name)0,
},
},
......@@ -767,7 +774,126 @@ static struct binding_template mnd_ball_on_stick_controller_bindings[26] = {
},
};
static struct profile_template profiles[3] = {
#define MAKE_INPUT(COMPONENT, SUFFIX, INPUT) \
{ \
.sub_path = OXR_SUB_ACTION_PATH_LEFT, \
.paths = \
{ \
"/user/hand/left/input/" #COMPONENT "/" #SUFFIX, \
"/user/hand/left/input/" #COMPONENT, \
NULL, \
}, \
.inputs = \
{ \
INPUT, \
(enum xrt_input_name)0, \
}, \
}, \
{ \
.sub_path = OXR_SUB_ACTION_PATH_RIGHT, \
.paths = \
{ \
"/user/hand/right/input/" #COMPONENT "/" #SUFFIX, \
"/user/hand/right/input/" #COMPONENT, \
NULL, \
}, \
.inputs = \
{ \
INPUT, \
(enum xrt_input_name)0, \
}, \
},
#define MAKE_INPUT_NO_DOWNGRADE(COMPONENT, SUFFIX, INPUT) \
{ \
.sub_path = OXR_SUB_ACTION_PATH_LEFT, \
.paths = \
{ \
"/user/hand/left/input/" #COMPONENT #SUFFIX, \
NULL, \
}, \
.inputs = \
{ \
INPUT, \
(enum xrt_input_name)0, \
}, \
}, \
{ \
.sub_path = OXR_SUB_ACTION_PATH_RIGHT, \
.paths = \
{ \
"/user/hand/right/input/" #COMPONENT #SUFFIX, \
NULL, \
}, \
.inputs = \
{ \
INPUT, \
(enum xrt_input_name)0, \
}, \
},
#define MAKE_OUTPUT(COMPONENT, SUFFIX, OUTPUT) \
{ \
.sub_path = OXR_SUB_ACTION_PATH_LEFT, \
.paths = \
{ \
"/user/hand/left/output/" #COMPONENT "/" #SUFFIX, \
"/user/hand/left/output/" #COMPONENT, \
NULL, \
}, \
.outputs = \
{ \
OUTPUT, \
(enum xrt_output_name)0, \
}, \
}, \
{ \
.sub_path = OXR_SUB_ACTION_PATH_RIGHT, \
.paths = \
{ \
"/user/hand/right/output/" #COMPONENT "/" #SUFFIX, \
"/user/hand/right/output/" #COMPONENT, \
NULL, \
}, \
.outputs = \
{ \
OUTPUT, \
(enum xrt_output_name)0, \
}, \
},
static struct binding_template valve_index_controller_bindings[48] = {
MAKE_INPUT_NO_DOWNGRADE(thumbstick, , XRT_INPUT_INDEX_THUMBSTICK_XY)
MAKE_INPUT_NO_DOWNGRADE(trackpad, , XRT_INPUT_INDEX_TRACKPAD_XY)
MAKE_INPUT(system, click, XRT_INPUT_INDEX_SYSTEM_CLICK)
MAKE_INPUT(system, touch, XRT_INPUT_INDEX_SYSTEM_TOUCH)
MAKE_INPUT(a, click, XRT_INPUT_INDEX_A_CLICK)
MAKE_INPUT(a, touch, XRT_INPUT_INDEX_A_TOUCH)
MAKE_INPUT(b, click, XRT_INPUT_INDEX_B_CLICK)
MAKE_INPUT(b, touch, XRT_INPUT_INDEX_B_TOUCH)
MAKE_INPUT(squeeze, value, XRT_INPUT_INDEX_SQUEEZE_VALUE)
MAKE_INPUT(squeeze, force, XRT_INPUT_INDEX_SQUEEZE_VALUE)
MAKE_INPUT(trigger, click, XRT_INPUT_INDEX_TRIGGER_CLICK)
MAKE_INPUT(trigger, value, XRT_INPUT_INDEX_TRIGGER_VALUE)
MAKE_INPUT(trigger, touch, XRT_INPUT_INDEX_TRIGGER_TOUCH)
MAKE_INPUT_NO_DOWNGRADE(thumbstick, /x, XRT_INPUT_INDEX_THUMBSTICK_X)
MAKE_INPUT_NO_DOWNGRADE(thumbstick, /y, XRT_INPUT_INDEX_THUMBSTICK_Y)
MAKE_INPUT(thumbstick, click, XRT_INPUT_INDEX_THUMBSTICK_CLICK)
MAKE_INPUT(thumbstick, touch, XRT_INPUT_INDEX_THUMBSTICK_TOUCH)
MAKE_INPUT_NO_DOWNGRADE(trackpad, /x, XRT_INPUT_INDEX_TRACKPAD_X)
MAKE_INPUT_NO_DOWNGRADE(trackpad, /y, XRT_INPUT_INDEX_TRACKPAD_Y)
MAKE_INPUT(trackpad, force, XRT_INPUT_INDEX_TRACKPAD_FORCE)
MAKE_INPUT(trackpad, touch, XRT_INPUT_INDEX_TRACKPAD_TOUCH)
MAKE_INPUT(grip, pose, XRT_INPUT_INDEX_GRIP_POSE)
MAKE_INPUT(aim, pose, XRT_INPUT_INDEX_AIM_POSE)
MAKE_OUTPUT(haptic, , XRT_OUTPUT_NAME_INDEX_HAPTIC)
};
static struct profile_template profiles[4] = {
{
.path = "/interaction_profiles/khr/simple_controller",
.bindings = khr_simple_controller_bindings,
......@@ -783,4 +909,9 @@ static struct profile_template profiles[3] = {
.bindings = mnd_ball_on_stick_controller_bindings,
.num_bindings = ARRAY_SIZE(mnd_ball_on_stick_controller_bindings),
},
{
.path = "/interaction_profiles/valve/index_controller",
.bindings = valve_index_controller_bindings,
.num_bindings = ARRAY_SIZE(valve_index_controller_bindings),
},
};
......@@ -594,6 +594,8 @@ oxr_source_cache_update(struct oxr_logger *log,
}
if (cache->num_inputs > 0) {
cache->current.active = true;
/*!
* @todo This logic should be a lot more smarter.
......
......@@ -60,9 +60,13 @@ if(BUILD_DRIVER_VIVE)
list(APPEND DRIVER_LIBRARIES ${ZLIB_LIBRARIES})
endif()
list(APPEND DRIVER_OBJECTS $<TARGET_OBJECTS:aux_tracking>)
if(BUILD_DRIVER_SURVIVE)
list(APPEND DRIVER_OBJECTS $<TARGET_OBJECTS:drv_survive>)
list(APPEND DRIVER_LIBRARIES survive)
endif()
if(BUILD_TRACKING)
list(APPEND DRIVER_OBJECTS $<TARGET_OBJECTS:aux_tracking>)
list(APPEND DRIVER_LIBRARIES ${OpenCV_LIBRARIES})
endif()
......
......@@ -18,7 +18,11 @@
#include "hdk/hdk_interface.h"
#endif
#ifdef XRT_BUILD_DRIVER_OHMD
#ifdef XRT_BUILD_SURVIVE
#include "survive/survive_interface.h"
#endif
#ifdef XRT_BUILD_OHMD
#include "ohmd/oh_interface.h"
#endif
......@@ -38,6 +42,10 @@
#include "hydra/hydra_interface.h"
#endif
#ifdef XRT_BUILD_SURVIVE
#include "survive/survive_interface.h"
#endif
#ifdef XRT_BUILD_DRIVER_VIVE
#include "vive/vive_prober.h"
#endif
......@@ -73,6 +81,12 @@ struct xrt_prober_entry target_entry_list[] = {
{HDK_VID, HDK_PID, hdk_found, "OSVR HDK"},
#endif // XRT_BUILD_DRIVER_HDK
#ifdef XRT_BUILD_SURVIVE
{HTC_VID, VIVE_PID, survive_found, "HTC Vive"},
{HTC_VID, VIVE_PRO_MAINBOARD_PID, survive_found, "HTC Vive Pro"},
{VALVE_VID, VIVE_PRO_LHR_PID, survive_found, "Valve Index"},
#endif
#ifdef XRT_BUILD_DRIVER_VIVE
{HTC_VID, VIVE_PID, vive_found, "HTC Vive"},
{HTC_VID, VIVE_PRO_MAINBOARD_PID, vive_found, "HTC Vive Pro"},
......
......@@ -61,6 +61,11 @@ if(DRIVER_OBJECTS)
)
endif()
if (BUILD_DRIVER_SURVIVE)
target_sources(${RUNTIME_TARGET} PRIVATE $<TARGET_OBJECTS:drv_survive>)
target_link_libraries(${RUNTIME_TARGET} PRIVATE survive)
endif()
if(DRIVER_LIBRARIES)
target_link_libraries(${RUNTIME_TARGET} PRIVATE
${DRIVER_LIBRARIES}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment