libsurvive icon indicating copy to clipboard operation
libsurvive copied to clipboard

Wireless dongle not working on Linux

Open nicshackle opened this issue 1 year ago • 1 comments

It seems that https://github.com/cntools/libsurvive/pull/291 introduced a regression on Linux. The below patch fixes it; happy to submit a PR but a) not sure if my method of detecting Windows is idiomatic and b) I don't have a windows system to test on:

diff --git a/src/driver_vive.c b/src/driver_vive.c
index d741b9b..9c35487 100755
--- a/src/driver_vive.c
+++ b/src/driver_vive.c
@@ -219,16 +219,16 @@ static uint8_t vive_magic_raw_mode_1[] = {VIVE_REPORT_CHANGE_MODE, 0x01, 0x00, 0
 static uint8_t vive_request_version_info[] = {VIVE_REPORT_VERSION};
 
 // Windows needs 64 size for the wireless dongle
-static uint8_t vive_magic_rf_raw_mode_0[64] = {
+static uint8_t vive_magic_rf_raw_mode_0[MAGIC_COMMAND_LENGTH] = {
 	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};
 // Windows needs 64 size for the wireless dongle
-static uint8_t vive_magic_protocol_switch[64] = {
+static uint8_t vive_magic_protocol_switch[MAGIC_COMMAND_LENGTH] = {
 	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};
 // Windows needs 64 size for the wireless dongle
-static uint8_t vive_magic_protocol_super_magic[64] = {VIVE_REPORT_COMMAND,
+static uint8_t vive_magic_protocol_super_magic[MAGIC_COMMAND_LENGTH] = {VIVE_REPORT_COMMAND,
 													VIVE_COMMAND_CONFIGURE_RADIO,
 													0x10,
 													0xbe,
diff --git a/src/driver_vive.h b/src/driver_vive.h
index 4aa7833..9c9e7ab 100644
--- a/src/driver_vive.h
+++ b/src/driver_vive.h
@@ -16,6 +16,11 @@
 #include <libusb-1.0/libusb.h>
 #endif
 #endif
+#if defined(WINDOWS) || defined(WIN32) || defined(_WIN32)
+#define MAGIC_COMMAND_LENGTH 64
+#else
+#define MAGIC_COMMAND_LENGTH
+#endif
 
 #include "os_generic.h"

Hardware setup USB dongle --> Tracker (3.0)

Desktop:

  • OS: Ubuntu
  • Version 22

nicshackle avatar Nov 03 '23 11:11 nicshackle

this patch is ok for me, thank you very much

maoyangchien avatar Dec 19 '23 03:12 maoyangchien