diff --git a/src/xrt/drivers/CMakeLists.txt b/src/xrt/drivers/CMakeLists.txt index 0b84ff093..7231ecd2c 100644 --- a/src/xrt/drivers/CMakeLists.txt +++ b/src/xrt/drivers/CMakeLists.txt @@ -313,7 +313,6 @@ if(XRT_BUILD_DRIVER_RIFT) rift/rift_bindings.h rift/rift_driver.c rift/rift_distortion.c - rift/rift_prober.c rift/rift_usb.c rift/rift_usb.h rift/rift_radio.c diff --git a/src/xrt/drivers/rift/rift_interface.h b/src/xrt/drivers/rift/rift_interface.h index 437112d25..eb4de2ce8 100644 --- a/src/xrt/drivers/rift/rift_interface.h +++ b/src/xrt/drivers/rift/rift_interface.h @@ -45,31 +45,6 @@ enum rift_variant #define RIFT_DK2_PRODUCT_STRING "Rift DK2" #define RIFT_CV1_PRODUCT_STRING "Rift CV1" -/*! - * Checks whether the given device is an Oculus device, by checking the manufacturer string. - * - * @ingroup drv_rift - * @param xp The prober to use for getting string descriptors. - * @param dev The device to check. - * @return true if the device is an Oculus device, false otherwise. - */ -bool -rift_is_oculus(struct xrt_prober *xp, struct xrt_prober_device *dev); - -/*! - * Probing function for Oculus Rift devices. - * - * @ingroup drv_rift - * @see xrt_prober_found_func_t - */ -int -rift_found(struct xrt_prober *xp, - struct xrt_prober_device **devices, - size_t device_count, - size_t index, - cJSON *attached_data, - struct xrt_device **out_xdev); - /*! * Creates Rift HMD and related devices. * diff --git a/src/xrt/drivers/rift/rift_prober.c b/src/xrt/drivers/rift/rift_prober.c deleted file mode 100644 index 39daf2047..000000000 --- a/src/xrt/drivers/rift/rift_prober.c +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2025, Beyley Cardellio -// SPDX-License-Identifier: BSL-1.0 -/*! - * @file - * @brief Prober for finding an Oculus Rift device based on USB VID/PID. - * @author Beyley Cardellio - * @ingroup drv_rift - */ - -#include "xrt/xrt_prober.h" -#include "xrt/xrt_config.h" - -#include "util/u_misc.h" -#include "util/u_logging.h" -#include "util/u_debug.h" - -#include "rift_internal.h" - - -#ifdef XRT_BUILD_DRIVER_OHMD -#define DEFAULT_ENABLE false -#else -#define DEFAULT_ENABLE true -#endif - -DEBUG_GET_ONCE_BOOL_OPTION(rift_prober_enable, "RIFT_PROBER_ENABLE", DEFAULT_ENABLE) - -bool -rift_is_oculus(struct xrt_prober *xp, struct xrt_prober_device *dev) -{ - unsigned char manufacturer[128] = {0}; - int result = xrt_prober_get_string_descriptor(xp, dev, XRT_PROBER_STRING_MANUFACTURER, manufacturer, - sizeof(manufacturer)); - if (result < 0) { - return false; - } - - // Some non-oculus devices (VR-Tek HMDs) reuse the same USB IDs as the oculus headsets, so we should check the - // manufacturer - if (strncmp((const char *)manufacturer, "Oculus VR, Inc.", sizeof(manufacturer)) != 0) { - return false; - } - - return true; -} - -int -rift_found(struct xrt_prober *xp, - struct xrt_prober_device **devices, - size_t device_count, - size_t index, - cJSON *attached_data, - struct xrt_device **out_xdevs) -{ - struct xrt_prober_device *dev = devices[index]; - - // don't do anything if rift probing is not enabled - if (!debug_get_bool_option_rift_prober_enable()) { - return -1; - } - - unsigned char serial_number[21] = {0}; - int result = xrt_prober_get_string_descriptor(xp, dev, XRT_PROBER_STRING_SERIAL_NUMBER, serial_number, - sizeof(serial_number)); - if (result < 0) { - return -1; - } - - if (!rift_is_oculus(xp, dev)) { - return -1; - } - - enum rift_variant variant; - switch (dev->product_id) { - case OCULUS_DK2_PID: variant = RIFT_VARIANT_DK2; break; - case OCULUS_CV1_PID: variant = RIFT_VARIANT_CV1; break; - default: return -1; break; - } - - U_LOG_I("%s - Found at least the tracker of some Rift -- opening\n", __func__); - struct os_hid_device *hmd_dev = NULL; - result = xrt_prober_open_hid_interface(xp, dev, 0, &hmd_dev); - if (result != 0) { - return -1; - } - - struct os_hid_device *radio_dev = NULL; - if (variant == RIFT_VARIANT_CV1) { - result = xrt_prober_open_hid_interface(xp, dev, 1, &radio_dev); - if (result != 0) { - return -1; - } - } - - struct rift_hmd *hmd = NULL; - int created_devices = rift_devices_create( // - hmd_dev, // - radio_dev, // - variant, // - (char *)serial_number, // - NULL, // - &hmd, // - out_xdevs); // - if (created_devices < 0) { - return -1; - } - - return created_devices; -} diff --git a/src/xrt/targets/common/target_builder_interface.h b/src/xrt/targets/common/target_builder_interface.h index dd4671df3..50e71586d 100644 --- a/src/xrt/targets/common/target_builder_interface.h +++ b/src/xrt/targets/common/target_builder_interface.h @@ -47,6 +47,10 @@ #define T_BUILDER_RIFT #endif +#if defined(XRT_BUILD_DRIVER_RIFT_S) || defined(XRT_DOXYGEN) +#define T_BUILDER_RIFT_S +#endif + #if defined(XRT_BUILD_DRIVER_PSMV) || defined(XRT_BUILD_DRIVER_PSVR) || defined(XRT_DOXYGEN) #define T_BUILDER_RGB_TRACKING #endif @@ -118,6 +122,14 @@ struct xrt_builder * rift_builder_create(void); #endif +#ifdef T_BUILDER_RIFT_S +/*! + * The Rift S driver builder. + */ +struct xrt_builder * +rift_s_builder_create(void); +#endif + #ifdef T_BUILDER_QWERTY /*! * The qwerty driver builder. diff --git a/src/xrt/targets/common/target_builder_rift.c b/src/xrt/targets/common/target_builder_rift.c index fd553fa7d..fbd7742a0 100644 --- a/src/xrt/targets/common/target_builder_rift.c +++ b/src/xrt/targets/common/target_builder_rift.c @@ -121,6 +121,24 @@ static const char *driver_list[] = { #endif }; +static bool +rift_is_oculus(struct xrt_prober *xp, struct xrt_prober_device *dev) +{ + unsigned char manufacturer[128] = {0}; + int result = xrt_prober_get_string_descriptor(xp, dev, XRT_PROBER_STRING_MANUFACTURER, manufacturer, + sizeof(manufacturer)); + if (result < 0) { + return false; + } + + // Some non-oculus devices (VR-Tek HMDs) reuse the same USB IDs as the oculus headsets, so we should check the + // manufacturer + if (strncmp((const char *)manufacturer, "Oculus VR, Inc.", sizeof(manufacturer)) != 0) { + return false; + } + + return true; +} /* * diff --git a/src/xrt/targets/common/target_lists.c b/src/xrt/targets/common/target_lists.c index 90af5c854..78efb9b3b 100644 --- a/src/xrt/targets/common/target_lists.c +++ b/src/xrt/targets/common/target_lists.c @@ -48,18 +48,10 @@ #include "psvr/psvr_interface.h" #endif -#ifdef XRT_BUILD_DRIVER_RIFT -#include "rift/rift_interface.h" -#endif - #ifdef XRT_BUILD_DRIVER_PSVR2 #include "psvr2/psvr2_interface.h" #endif -#ifdef XRT_BUILD_DRIVER_RIFT_S -#include "rift_s/rift_s_interface.h" -#endif - #ifdef XRT_BUILD_DRIVER_ROKID #include "rokid/rokid_interface.h" #endif @@ -207,11 +199,6 @@ struct xrt_prober_entry target_entry_list[] = { {PSMV_VID, PSMV_PID_ZCM2, psmv_found, "PS Move Controller (ZCM2)", "psmv"}, #endif // XRT_BUILD_DRIVER_PSMV -#ifdef XRT_BUILD_DRIVER_RIFT - {OCULUS_VR_VID, OCULUS_DK2_PID, rift_found, RIFT_DK2_PRODUCT_STRING, "rift"}, - {OCULUS_VR_VID, OCULUS_CV1_PID, rift_found, RIFT_CV1_PRODUCT_STRING, "rift"}, -#endif // XRT_BUILD_DRIVER_RIFT - #ifdef XRT_BUILD_DRIVER_BLUBUR_S1 {BLUBUR_S1_VID, BLUBUR_S1_PID, blubur_s1_found, "Blubur S1", "blubur_s1"}, #endif // XRT_BUILD_DRIVER_BLUBUR_S1