From 464dd9734a8de20df818fd83e7c1b016b068bb52 Mon Sep 17 00:00:00 2001 From: Caio Mendes Date: Thu, 21 Sep 2023 00:32:38 -0300 Subject: [PATCH] Fix windows wireless dongle setup --- src/driver_vive.c | 9 ++++++--- src/driver_vive.hidapi.h | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/driver_vive.c b/src/driver_vive.c index c2da1487..d741b9b2 100755 --- a/src/driver_vive.c +++ b/src/driver_vive.c @@ -218,14 +218,17 @@ static uint8_t vive_magic_power_off[] = { static uint8_t vive_magic_raw_mode_1[] = {VIVE_REPORT_CHANGE_MODE, 0x01, 0x00, 0x00, 0x00}; static uint8_t vive_request_version_info[] = {VIVE_REPORT_VERSION}; -static uint8_t vive_magic_rf_raw_mode_0[] = { +// Windows needs 64 size for the wireless dongle +static uint8_t vive_magic_rf_raw_mode_0[64] = { VIVE_REPORT_COMMAND, VIVE_COMMAND_CHANGE_PROTOCOL, 0x6, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00}; static uint8_t vive_magic_rf_raw_mode_1[] = { VIVE_REPORT_COMMAND, VIVE_COMMAND_CHANGE_PROTOCOL, 0x6, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00}; -static uint8_t vive_magic_protocol_switch[] = { +// Windows needs 64 size for the wireless dongle +static uint8_t vive_magic_protocol_switch[64] = { VIVE_REPORT_COMMAND, VIVE_COMMAND_CHANGE_PROTOCOL, 0x3, 0x00, 0x01, 0x00}; static uint8_t vive_request_pairing[] = {VIVE_REPORT_COMMAND, VIVE_COMMAND_PAIR, 0x03, 0x01, 0x10, 0x27}; -static uint8_t vive_magic_protocol_super_magic[] = {VIVE_REPORT_COMMAND, +// Windows needs 64 size for the wireless dongle +static uint8_t vive_magic_protocol_super_magic[64] = {VIVE_REPORT_COMMAND, VIVE_COMMAND_CONFIGURE_RADIO, 0x10, 0xbe, diff --git a/src/driver_vive.hidapi.h b/src/driver_vive.hidapi.h index 5e7bb78d..5d3d4a0d 100644 --- a/src/driver_vive.hidapi.h +++ b/src/driver_vive.hidapi.h @@ -171,8 +171,10 @@ static survive_usb_device_t get_next_device(survive_usb_device_enumerator* d, su return *d = head; } + // On Windows the wireless dongle interface is -1 + // That's why we check for <= 0 for (survive_usb_device_t c = (*d)->next; c; c = c->next) { - if (c->interface_number == 0) { + if (c->interface_number <= 0) { return *d = c; } }