From 130582c2091727ee6cc1d0659bfa4e49d05be67c Mon Sep 17 00:00:00 2001 From: Milan Jaros <milan.jaros@vsb.cz> Date: Wed, 29 Jun 2022 08:17:34 +0200 Subject: [PATCH] add survive for win --- CMakeLists.txt | 7 +++++ src/xrt/drivers/CMakeLists.txt | 34 +++++++++++++++++------- src/xrt/drivers/survive/survive_driver.c | 8 ++++++ src/xrt/drivers/vive/vive_win32.h | 13 +++++++++ 4 files changed, 52 insertions(+), 10 deletions(-) create mode 100644 src/xrt/drivers/vive/vive_win32.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a18a5395..1c07d83dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,6 +168,13 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") pkg_check_modules(SURVIVE IMPORTED_TARGET survive) endif() +if(WIN32) + set(SURVIVE_INCLUDE_DIRS "" CACHE PATH "") + set(SURVIVE_LIBRARIES "" CACHE FILEPATH "") + + set(SURVIVE_FOUND ON) +endif() + # Find a external SLAM implementation set(EXTERNAL_SLAM_SYSTEMS kimera_vio basalt) foreach(slam_system IN LISTS EXTERNAL_SLAM_SYSTEMS) diff --git a/src/xrt/drivers/CMakeLists.txt b/src/xrt/drivers/CMakeLists.txt index 020588c64..f89a1d4e3 100644 --- a/src/xrt/drivers/CMakeLists.txt +++ b/src/xrt/drivers/CMakeLists.txt @@ -247,16 +247,30 @@ if(XRT_BUILD_DRIVER_SURVIVE) drv_survive STATIC survive/survive_driver.c survive/survive_driver.h survive/survive_interface.h survive/survive_prober.c ) - target_link_libraries( - drv_survive - PRIVATE - xrt-interfaces - aux_os - aux_util - aux_math - aux_vive - PkgConfig::SURVIVE - ) + if(WIN32) + target_link_libraries( + drv_survive + PRIVATE + xrt-interfaces + aux_os + aux_util + aux_math + aux_vive + ${SURVIVE_LIBRARIES} + ) + target_include_directories(drv_survive PRIVATE ${SURVIVE_INCLUDE_DIRS}) + else() + target_link_libraries( + drv_survive + PRIVATE + xrt-interfaces + aux_os + aux_util + aux_math + aux_vive + PkgConfig::SURVIVE + ) + endif() list(APPEND ENABLED_HEADSET_DRIVERS survive) if(XRT_BUILD_DRIVER_HANDTRACKING) diff --git a/src/xrt/drivers/survive/survive_driver.c b/src/xrt/drivers/survive/survive_driver.c index b7f2341be..57f374bed 100644 --- a/src/xrt/drivers/survive/survive_driver.c +++ b/src/xrt/drivers/survive/survive_driver.c @@ -231,9 +231,13 @@ survive_device_destroy(struct xrt_device *xdev) static double survive_timecode_now_s() { +#ifdef XRT_OS_WINDOWS + return (double)os_monotonic_get_ns() / 1000000000.; +#else struct timeval tv; gettimeofday(&tv, 0); return ((double)tv.tv_usec) / 1000000. + (tv.tv_sec); +#endif } static timepoint_ns @@ -1397,6 +1401,10 @@ survive_device_autoprobe(struct xrt_auto_prober *xap, return 0; } +#ifdef XRT_OS_WINDOWS + os_thread_helper_init(&ss->event_thread); +#endif + ret = os_thread_helper_start(&ss->event_thread, run_event_thread, ss); if (ret != 0) { U_LOG_IFL_E(ss->log_level, "Failed to start event thread!"); diff --git a/src/xrt/drivers/vive/vive_win32.h b/src/xrt/drivers/vive/vive_win32.h new file mode 100644 index 000000000..ade3c7b1d --- /dev/null +++ b/src/xrt/drivers/vive/vive_win32.h @@ -0,0 +1,13 @@ +// Copyright 2016-2019, Philipp Zabel +// Copyright 2019, Collabora, Ltd. +// SPDX-License-Identifier: BSL-1.0 +/*! + * @file + * @brief Common vive header + * @author Lubosz Sarnecki <lubosz.sarnecki@collabora.com> + * @ingroup drv_vive + */ + +#pragma once + +#define VIVE_ATTRIBUTE_PACKED -- GitLab