mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-19 13:18:32 +00:00
d/survive: Use autoprober interface
This commit is contained in:
parent
a89f32470e
commit
279520c302
|
@ -207,7 +207,9 @@ endif()
|
|||
if (XRT_BUILD_DRIVER_SURVIVE)
|
||||
set(SURVIVE_SOURCE_FILES
|
||||
survive/survive_driver.c
|
||||
survive/survive_driver.h
|
||||
survive/survive_interface.h
|
||||
survive/survive_prober.c
|
||||
)
|
||||
|
||||
add_library(drv_survive STATIC ${SURVIVE_SOURCE_FILES})
|
||||
|
|
|
@ -186,7 +186,9 @@ lib_drv_survive = static_library(
|
|||
'drv_survive',
|
||||
files(
|
||||
'survive/survive_driver.c',
|
||||
'survive/survive_driver.h',
|
||||
'survive/survive_interface.h',
|
||||
'survive/survive_prober.c',
|
||||
),
|
||||
include_directories: [
|
||||
xrt_include,
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "math/m_predict.h"
|
||||
|
||||
#include "vive/vive_config.h"
|
||||
#include "survive_driver.h"
|
||||
|
||||
// reading usb config takes libsurvive about 50ms per device
|
||||
// to be safe, we wait 500 ms after the last device has been initialized
|
||||
|
@ -1188,12 +1189,11 @@ add_connected_devices(struct survive_system *ss)
|
|||
}
|
||||
|
||||
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)
|
||||
survive_device_autoprobe(struct xrt_auto_prober *xap,
|
||||
cJSON *attached_data,
|
||||
bool no_hmds,
|
||||
struct xrt_prober *xp,
|
||||
struct xrt_device **out_xdevs)
|
||||
{
|
||||
if (survive_already_initialized) {
|
||||
U_LOG_I(
|
||||
|
@ -1249,11 +1249,18 @@ survive_found(struct xrt_prober *xp,
|
|||
}
|
||||
|
||||
int out_idx = 0;
|
||||
if (ss->hmd) {
|
||||
if (ss->hmd && !no_hmds) {
|
||||
out_xdevs[out_idx++] = &ss->hmd->base;
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_TRACKED_DEVICE_COUNT; i++) {
|
||||
|
||||
if (out_idx == XRT_MAX_DEVICES_PER_PROBE - 1) {
|
||||
U_LOG_IFL_W(ss->ll, "Probed max of %d devices, ignoring further devices",
|
||||
XRT_MAX_DEVICES_PER_PROBE);
|
||||
return out_idx;
|
||||
}
|
||||
|
||||
if (ss->controllers[i] != NULL) {
|
||||
out_xdevs[out_idx++] = &ss->controllers[i]->base;
|
||||
}
|
||||
|
|
16
src/xrt/drivers/survive/survive_driver.h
Normal file
16
src/xrt/drivers/survive/survive_driver.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Copyright 2021, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
/*!
|
||||
* @file
|
||||
* @brief Adapter to Libsurvive.
|
||||
* @author Christoph Haag <christoph.haag@collabora.com>
|
||||
* @ingroup drv_survive
|
||||
*/
|
||||
|
||||
|
||||
int
|
||||
survive_device_autoprobe(struct xrt_auto_prober *xap,
|
||||
cJSON *attached_data,
|
||||
bool no_hmds,
|
||||
struct xrt_prober *xp,
|
||||
struct xrt_device **out_xdevs);
|
|
@ -14,22 +14,20 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define HTC_VID 0x0bb4
|
||||
#define VALVE_VID 0x28de
|
||||
/*!
|
||||
* @defgroup drv_survive Lighthouse tracking using libsurvive
|
||||
* @ingroup drv
|
||||
*
|
||||
* @brief
|
||||
*/
|
||||
|
||||
#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);
|
||||
/*!
|
||||
* Create a probe for libsurvive
|
||||
*
|
||||
* @ingroup drv_survive
|
||||
*/
|
||||
struct xrt_auto_prober *
|
||||
survive_create_auto_prober();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
51
src/xrt/drivers/survive/survive_prober.c
Normal file
51
src/xrt/drivers/survive/survive_prober.c
Normal file
|
@ -0,0 +1,51 @@
|
|||
// Copyright 2021, Collabora, Ltd.
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
/*!
|
||||
* @file
|
||||
* @brief libsurvive prober code.
|
||||
* @author Christoph Haag <christoph.haag@collabora.com>
|
||||
* @ingroup drv_survive
|
||||
*/
|
||||
|
||||
|
||||
#include "xrt/xrt_prober.h"
|
||||
|
||||
#include "util/u_misc.h"
|
||||
|
||||
#include "survive_interface.h"
|
||||
#include "survive_driver.h"
|
||||
|
||||
/*!
|
||||
* @implements xrt_auto_prober
|
||||
*/
|
||||
struct survive_prober
|
||||
{
|
||||
struct xrt_auto_prober base;
|
||||
};
|
||||
|
||||
//! @private @memberof survive_prober
|
||||
static inline struct survive_prober *
|
||||
survive_prober(struct xrt_auto_prober *p)
|
||||
{
|
||||
return (struct survive_prober *)p;
|
||||
}
|
||||
|
||||
//! @public @memberof survive_prober
|
||||
static void
|
||||
survive_prober_destroy(struct xrt_auto_prober *p)
|
||||
{
|
||||
struct survive_prober *survive_p = survive_prober(p);
|
||||
|
||||
free(survive_p);
|
||||
}
|
||||
|
||||
struct xrt_auto_prober *
|
||||
survive_create_auto_prober()
|
||||
{
|
||||
struct survive_prober *survive_p = U_TYPED_CALLOC(struct survive_prober);
|
||||
survive_p->base.name = "survive";
|
||||
survive_p->base.destroy = survive_prober_destroy;
|
||||
survive_p->base.lelo_dallas_autoprobe = survive_device_autoprobe;
|
||||
|
||||
return &survive_p->base;
|
||||
}
|
|
@ -97,12 +97,6 @@ struct xrt_prober_entry target_entry_list[] = {
|
|||
{HDK_VID, HDK_PID, hdk_found, "OSVR HDK", "osvr"},
|
||||
#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", "vive"},
|
||||
{HTC_VID, VIVE_PRO_MAINBOARD_PID, vive_found, "HTC Vive Pro", "vive"},
|
||||
|
@ -134,6 +128,10 @@ xrt_auto_prober_creator target_auto_list[] = {
|
|||
daydream_create_auto_prober,
|
||||
#endif
|
||||
|
||||
#ifdef XRT_BUILD_DRIVER_SURVIVE
|
||||
survive_create_auto_prober,
|
||||
#endif
|
||||
|
||||
#ifdef XRT_BUILD_DRIVER_OHMD
|
||||
// OpenHMD almost as the end as we want to override it with native drivers.
|
||||
oh_create_auto_prober,
|
||||
|
|
Loading…
Reference in a new issue