mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2024-12-28 02:26:16 +00:00
d/survive: Add survive driver
This commit is contained in:
parent
5b2efcbb7a
commit
5908c33439
|
@ -107,6 +107,7 @@ option(BUILD_WITH_HDK "Enable HDK driver" ON)
|
|||
option(BUILD_WITH_PSMV "Enable Playstation Move driver" ON)
|
||||
option(BUILD_WITH_HYDRA "Enable Hydra driver" ON)
|
||||
option(BUILD_WITH_NS "Enable North Star driver" ON)
|
||||
option(BUILD_WITH_LIBSURVIVE "Enable libsurvive driver" OFF)
|
||||
|
||||
# You can set this from a superproject to add a driver
|
||||
list(APPEND AVAILABLE_DRIVERS ARDUINO DUMMY HDK HYDRA NS OHMD PSMV PSVR RS V4L2 VIVE DAYDREAM)
|
||||
|
@ -182,6 +183,13 @@ if(BUILD_WITH_NS)
|
|||
set(BUILD_DRIVER_NS TRUE)
|
||||
endif()
|
||||
|
||||
if (BUILD_WITH_LIBSURVIVE)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(SURVIVE REQUIRED IMPORTED_TARGET survive)
|
||||
add_definitions(-DXRT_BUILD_DRIVER_SURVIVE)
|
||||
set(BUILD_DRIVER_SURVIVE TRUE)
|
||||
endif()
|
||||
|
||||
if(BUILD_WITH_PSVR)
|
||||
if (NOT ${HIDAPI_FOUND})
|
||||
message(FATAL_ERROR "PSVR driver requires hidapi")
|
||||
|
|
26
README.md
26
README.md
|
@ -178,6 +178,32 @@ You can verify that it stuck with the command.
|
|||
xrandr --prop
|
||||
```
|
||||
|
||||
## Using libsurvive
|
||||
|
||||
To enable the libsurvive driver, libsurvive has to be installed as a library with a pkgconfig file
|
||||
(https://github.com/cntools/libsurvive/pull/187).
|
||||
|
||||
When starting any libsrvive or 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 (e.g. to force recalibration) delete the following
|
||||
files/directories:
|
||||
|
||||
rm -r *config.json calinfo
|
||||
|
||||
Though working and somewhat usable, support for the libsurvive driver is **experimental**.
|
||||
Therefore with both meson and cmake, the survive driver has to be explicitly enabled with
|
||||
|
||||
```
|
||||
#cmake
|
||||
-DBUILD_WITH_LIBSURVIVE=On
|
||||
|
||||
#meson
|
||||
-Ddrivers=auto,survive
|
||||
```
|
||||
|
||||
## Coding style and formatting
|
||||
|
||||
[clang-format][] is used,
|
||||
|
|
|
@ -65,6 +65,7 @@ udev = dependency('libudev', required: false)
|
|||
libuvc = dependency('libuvc', required: false)
|
||||
vulkan = dependency('vulkan', required: true)
|
||||
zlib = dependency('zlib', required: false)
|
||||
survive = dependency('survive', required: false)
|
||||
|
||||
opencv = dependency('opencv4', required: false)
|
||||
if not opencv.found()
|
||||
|
@ -183,6 +184,12 @@ if v4l2.found() and ('auto' in drivers or 'v4l2' in drivers)
|
|||
endif
|
||||
endif
|
||||
|
||||
if survive.found() and ('survive' in drivers)
|
||||
if 'survive' not in drivers
|
||||
drivers += ['survive']
|
||||
endif
|
||||
endif
|
||||
|
||||
if drivers.length() == 0 or drivers == ['auto']
|
||||
error('You must enable at least one driver.')
|
||||
endif
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
option('drivers',
|
||||
type: 'array',
|
||||
choices: ['auto', 'dummy', 'hdk', 'hydra', 'ns', 'ohmd', 'psmv', 'psvr', 'rs', 'v4l2', 'vive'],
|
||||
choices: ['auto', 'dummy', 'hdk', 'hydra', 'ns', 'ohmd', 'psmv', 'psvr', 'rs', 'v4l2', 'vive', 'survive'],
|
||||
value: ['auto'],
|
||||
description: 'Set of drivers to build')
|
||||
|
||||
|
|
|
@ -162,6 +162,19 @@ if(BUILD_DRIVER_V4L2)
|
|||
list(APPEND ENABLED_DRIVERS v4l2)
|
||||
endif()
|
||||
|
||||
if (BUILD_WITH_LIBSURVIVE)
|
||||
set(SURVIVE_SOURCE_FILES
|
||||
survive/survive_driver.c
|
||||
survive/survive_interface.h
|
||||
survive/survive_wrap.c
|
||||
survive/survive_wrap.h
|
||||
)
|
||||
|
||||
add_library(drv_survive STATIC ${SURVIVE_SOURCE_FILES})
|
||||
target_link_libraries(drv_survive PRIVATE xrt-interfaces aux_os aux_util aux_math PkgConfig::SURVIVE)
|
||||
list(APPEND ENABLED_HEADSET_DRIVERS survive)
|
||||
endif()
|
||||
|
||||
if(ENABLED_HEADSET_DRIVERS)
|
||||
set(ENABLED_DRIVERS ${ENABLED_HEADSET_DRIVERS} ${ENABLED_DRIVERS})
|
||||
list(SORT ENABLED_DRIVERS)
|
||||
|
|
|
@ -136,3 +136,19 @@ lib_drv_vive = static_library(
|
|||
dependencies: [aux, zlib],
|
||||
build_by_default: 'vive' in drivers,
|
||||
)
|
||||
|
||||
lib_drv_survive = static_library(
|
||||
'drv_survive',
|
||||
files(
|
||||
'survive/survive_driver.c',
|
||||
'survive/survive_interface.h',
|
||||
'survive/survive_wrap.c',
|
||||
'survive/survive_wrap.h'
|
||||
),
|
||||
include_directories: [
|
||||
xrt_include,
|
||||
cjson_include,
|
||||
],
|
||||
dependencies: [aux, zlib, survive],
|
||||
build_by_default: 'survive' in drivers,
|
||||
)
|
||||
|
|
1165
src/xrt/drivers/survive/survive_driver.c
Normal file
1165
src/xrt/drivers/survive/survive_driver.c
Normal file
File diff suppressed because it is too large
Load diff
36
src/xrt/drivers/survive/survive_interface.h
Normal file
36
src/xrt/drivers/survive/survive_interface.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
// Copyright 2019, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*!
|
||||
* @file
|
||||
* @brief Interface to Libsurvive adapter.
|
||||
* @author Christoph Haag <christoph.haag@collabora.com>
|
||||
* @author Jakob Bornecrantz <jakob@collabora.com>
|
||||
* @ingroup drv_survive
|
||||
*/
|
||||
|
||||
#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,
|
||||
cJSON *attached_data,
|
||||
struct xrt_device **out_xdevs);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
30
src/xrt/drivers/survive/survive_wrap.c
Normal file
30
src/xrt/drivers/survive/survive_wrap.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
// Copyright 2020, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
/*!
|
||||
* @file
|
||||
* @brief low level libsurvive wrapper
|
||||
* @author Christoph Haag <christoph.haag@collabora.com>
|
||||
* @ingroup drv_survive
|
||||
*/
|
||||
|
||||
#define SURVIVE_ENABLE_FULL_API 1
|
||||
#include "survive_api.h"
|
||||
|
||||
#include "survive_wrap.h"
|
||||
|
||||
// TODO: expose config values we need through actual survive API
|
||||
#include "survive.h"
|
||||
|
||||
bool
|
||||
survive_config_ready(const SurviveSimpleObject *sso)
|
||||
{
|
||||
SurviveObject *so = survive_simple_get_survive_object(sso);
|
||||
return so->conf != 0;
|
||||
}
|
||||
|
||||
char *
|
||||
survive_get_json_config(const SurviveSimpleObject *sso)
|
||||
{
|
||||
SurviveObject *so = survive_simple_get_survive_object(sso);
|
||||
return so->conf;
|
||||
}
|
18
src/xrt/drivers/survive/survive_wrap.h
Normal file
18
src/xrt/drivers/survive/survive_wrap.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Copyright 2020, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
/*!
|
||||
* @file
|
||||
* @brief low level libsurvive wrapper
|
||||
* @author Christoph Haag <christoph.haag@collabora.com>
|
||||
* @ingroup drv_survive
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "survive_api.h"
|
||||
|
||||
bool
|
||||
survive_config_ready(const SurviveSimpleObject *sso);
|
||||
|
||||
char *
|
||||
survive_get_json_config(const SurviveSimpleObject *sso);
|
|
@ -67,6 +67,9 @@ if(BUILD_DRIVER_VIVE)
|
|||
target_link_libraries(target_lists PRIVATE drv_vive)
|
||||
endif()
|
||||
|
||||
if(BUILD_DRIVER_SURVIVE)
|
||||
target_link_libraries(target_lists PRIVATE drv_survive)
|
||||
endif()
|
||||
|
||||
####
|
||||
# Instance
|
||||
|
|
|
@ -42,6 +42,10 @@
|
|||
#include "hydra/hydra_interface.h"
|
||||
#endif
|
||||
|
||||
#ifdef XRT_BUILD_DRIVER_SURVIVE
|
||||
#include "survive/survive_interface.h"
|
||||
#endif
|
||||
|
||||
#ifdef XRT_BUILD_DRIVER_VIVE
|
||||
#include "vive/vive_prober.h"
|
||||
#include "vive/vive_controller_interface.h"
|
||||
|
@ -82,6 +86,12 @@ struct xrt_prober_entry target_entry_list[] = {
|
|||
{HDK_VID, HDK_PID, hdk_found, "OSVR HDK"},
|
||||
#endif // XRT_BUILD_DRIVER_HDK
|
||||
|
||||
#ifdef XRT_BUILD_DRIVER_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"},
|
||||
|
|
|
@ -54,6 +54,10 @@ if 'vive' in drivers
|
|||
driver_libs += [lib_drv_vive]
|
||||
endif
|
||||
|
||||
if 'survive' in drivers
|
||||
driver_libs += [lib_drv_survive]
|
||||
endif
|
||||
|
||||
subdir('common')
|
||||
subdir('openxr')
|
||||
subdir('cli')
|
||||
|
|
Loading…
Reference in a new issue