From c1603243eeba3f7f9ff8f9f70098105c634166e5 Mon Sep 17 00:00:00 2001 From: WenZheng Li Date: Tue, 12 Jun 2018 23:33:01 +0900 Subject: fixed Makefile for LINUX_USE_HIDAPI, updated tracker usb pid, fixed wired tracker lightcap data callback --- Makefile | 12 ++++++------ src/survive_vive.c | 31 +++++-------------------------- useful_files/81-vive.rules | 4 ++-- 3 files changed, 13 insertions(+), 34 deletions(-) diff --git a/Makefile b/Makefile index eb2177a..0d80dd0 100644 --- a/Makefile +++ b/Makefile @@ -57,18 +57,18 @@ else # Linux / FreeBSD GRAPHICS_LOFI:=redist/CNFGFunctions.c redist/CNFGXDriver.c endif +ifdef LINUX_USE_HIDAPI + CFLAGS:=$(CFLAGS) -DHIDAPI + REDISTS:=$(REDISTS) redist/hid-linux.c + LDFLAGS:=$(LDFLAGS) -ludev +endif + ifdef MINIMAL LIBSURVIVE_C:=$(REDISTS) $(LIBSURVIVE_CORE) $(MINIMAL_NEEDED) else LIBSURVIVE_C:=$(POSERS) $(REDISTS) $(LIBSURVIVE_CORE) $(SBA) $(MINIMAL_NEEDED) $(AUX_NEEDED) endif -ifdef LINUX_USE_HIDAPI - CFLAGS:=$(CFLAGS) -DHIDAPI - REDISTS:=$(REDISTS) redist/hid-linux.o - LDFLAGS:=$(LDFLAGS) -ludev -endif - #Actually make object and dependency lists. LIBSURVIVE_O:=$(LIBSURVIVE_C:%.c=$(OBJDIR)/%.o) diff --git a/src/survive_vive.c b/src/survive_vive.c index 493215a..8a4bcd5 100755 --- a/src/survive_vive.c +++ b/src/survive_vive.c @@ -47,15 +47,15 @@ const short vidpids[] = { 0x28de, 0x2000, 0, //Valve HMD IMU & Lighthouse Sensors 0x28de, 0x2101, 0, //Valve Watchman 0x28de, 0x2101, 1, //Valve Watchman - 0x28de, 0x2022, 0, //HTC Tracker + 0x28de, 0x2300, 0, //HTC Tracker 0x28de, 0x2012, 0, //Valve Watchman, USB connected #ifdef HIDAPI 0x28de, 0x2000, 1, //Valve HMD lighthouse(B) (only used on HIDAPI, for lightcap) - 0x28de, 0x2022, 1, //HTC Tracker (only used on HIDAPI, for lightcap) + 0x28de, 0x2300, 1, //HTC Tracker (only used on HIDAPI, for lightcap) 0x28de, 0x2012, 1, //Valve Watchman, USB connected (only used on HIDAPI, for lightcap) 0x28de, 0x2000, 2, //Valve HMD lighthouse(B) (only used on HIDAPI, for lightcap) - 0x28de, 0x2022, 2, //HTC Tracker (only used on HIDAPI, for lightcap) + 0x28de, 0x2300, 2, //HTC Tracker (only used on HIDAPI, for lightcap) 0x28de, 0x2012, 2, //Valve Watchman, USB connected (only used on HIDAPI, for lightcap) #endif @@ -1515,6 +1515,8 @@ void survive_data_cb( SurviveUSBInterface * si ) break; } case USB_IF_LIGHTCAP: + case USB_IF_TRACKER0_LIGHTCAP: + case USB_IF_W_WATCHMAN1_LIGHTCAP: { int i; for( i = 0; i < 9; i++ ) @@ -1528,29 +1530,6 @@ void survive_data_cb( SurviveUSBInterface * si ) } break; } - case USB_IF_W_WATCHMAN1_LIGHTCAP: - case USB_IF_TRACKER0_LIGHTCAP: - { - int i=0; - for( i = 0; i < 7; i++ ) - { - unsigned short *sensorId = (unsigned short *)readdata; - unsigned short *length = (unsigned short *)(&(readdata[2])); - unsigned long *time = (unsigned long *)(&(readdata[4])); - LightcapElement le; - le.sensor_id = (uint8_t)POP2; - le.length = POP2; - le.timestamp = POP4; - if( le.sensor_id > 0xfd ) continue; // - handle_lightcap( obj, &le ); - } - break; - - if (id != 33) - { - int a = 0; // breakpoint here - } - } case USB_IF_TRACKER0_BUTTONS: case USB_IF_W_WATCHMAN1_BUTTONS: { diff --git a/useful_files/81-vive.rules b/useful_files/81-vive.rules index ea5be37..a8b4e63 100644 --- a/useful_files/81-vive.rules +++ b/useful_files/81-vive.rules @@ -6,7 +6,7 @@ KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="28de", ATTRS{idProduct KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2050", TAG+="uaccess" KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2011", TAG+="uaccess" KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2012", TAG+="uaccess" -KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2022", TAG+="uaccess" +KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2300", TAG+="uaccess" SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="2c87", TAG+="uaccess" # HTC Camera USB Node @@ -21,7 +21,7 @@ SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="2c87", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2000", MODE="0666" # Light input SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2101", MODE="0666" # Watchman SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2012", MODE="0666" # Watchman wired -SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2022", MODE="0666" # Tracker wired +SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2300", MODE="0666" # Tracker wired #KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0bb4", ATTR{idProduct}=="2c87", MODE="0666" # HTC #KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="28de", ATTR{idProduct}=="2000", MODE="0666" # Valve -- cgit v1.2.3 From 65ccd71e7f44baa759e56f3f29b2a825ccebb5f6 Mon Sep 17 00:00:00 2001 From: WenZheng Li Date: Wed, 13 Jun 2018 22:35:34 +0900 Subject: changed to distro specific hidapi lib --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0d80dd0..0a16b32 100644 --- a/Makefile +++ b/Makefile @@ -59,8 +59,9 @@ endif ifdef LINUX_USE_HIDAPI CFLAGS:=$(CFLAGS) -DHIDAPI - REDISTS:=$(REDISTS) redist/hid-linux.c - LDFLAGS:=$(LDFLAGS) -ludev + #TODO why doesn't the redist version work + #REDISTS:=$(REDISTS) redist/hid-linux.c + LDFLAGS:=$(LDFLAGS) -ludev -lhidapi-libusb endif ifdef MINIMAL -- cgit v1.2.3 From 8261107f6f276ec49b13aa75781a496e26d63b4b Mon Sep 17 00:00:00 2001 From: woobianca Date: Thu, 14 Jun 2018 23:56:28 +0900 Subject: under construction --- src/survive_vive.c | 80 +++++++++++++++++++++++++++------------------- useful_files/81-vive.rules | 4 ++- 2 files changed, 50 insertions(+), 34 deletions(-) diff --git a/src/survive_vive.c b/src/survive_vive.c index 8a4bcd5..ef94677 100755 --- a/src/survive_vive.c +++ b/src/survive_vive.c @@ -47,14 +47,17 @@ const short vidpids[] = { 0x28de, 0x2000, 0, //Valve HMD IMU & Lighthouse Sensors 0x28de, 0x2101, 0, //Valve Watchman 0x28de, 0x2101, 1, //Valve Watchman - 0x28de, 0x2300, 0, //HTC Tracker + 0x28de, 0x2022, 0, //HTC Tracker + 0x28de, 0x2300, 0, //HTC Tracker 2018 0x28de, 0x2012, 0, //Valve Watchman, USB connected #ifdef HIDAPI 0x28de, 0x2000, 1, //Valve HMD lighthouse(B) (only used on HIDAPI, for lightcap) - 0x28de, 0x2300, 1, //HTC Tracker (only used on HIDAPI, for lightcap) + 0x28de, 0x2022, 1, //HTC Tracker (only used on HIDAPI, for lightcap) + 0x28de, 0x2300, 1, //HTC Tracker 2018 (only used on HIDAPI, for lightcap) 0x28de, 0x2012, 1, //Valve Watchman, USB connected (only used on HIDAPI, for lightcap) 0x28de, 0x2000, 2, //Valve HMD lighthouse(B) (only used on HIDAPI, for lightcap) + 0x28de, 0x2022, 2, //HTC Tracker (only used on HIDAPI, for lightcap) 0x28de, 0x2300, 2, //HTC Tracker (only used on HIDAPI, for lightcap) 0x28de, 0x2012, 2, //Valve Watchman, USB connected (only used on HIDAPI, for lightcap) @@ -67,53 +70,64 @@ const char * devnames[] = { "Watchman 1", "Watchman 2", "Tracker 0", + "Tracker(2018) 0", "Wired Watchman 1", #ifdef HIDAPI "HMD Lightcap", "Tracker 0 Lightcap", + "Tracker(2018) 0 Lightcap", "Wired Watchman 1 Lightcap", "HMD Buttons", "Tracker 0 Buttons", + "Tracker(2018) Buttons", "Wired Watchman 1 Buttons", #endif }; //length MAX_USB_INTERFACES -#define USB_DEV_HMD 0 -#define USB_DEV_HMD_IMU_LH 1 -#define USB_DEV_WATCHMAN1 2 -#define USB_DEV_WATCHMAN2 3 -#define USB_DEV_TRACKER0 4 -#define USB_DEV_W_WATCHMAN1 5 // Wired Watchman attached via USB - +enum { + USB_DEV_HMD = 0, + USB_DEV_HMD_IMU_LH, + USB_DEV_WATCHMAN1, + USB_DEV_WATCHMAN2, + USB_DEV_TRACKER0, + USB_DEV_TRACKER0_2018, + USB_DEV_W_WATCHMAN1, // Wired Watchman attached via USB #ifdef HIDAPI -#define USB_DEV_HMD_IMU_LHB 6 -#define USB_DEV_TRACKER0_LIGHTCAP 7 -#define USB_DEV_W_WATCHMAN1_LIGHTCAP 8 - -#define USB_DEV_HMD_BUTTONS 9 -#define USB_DEV_TRACKER0_BUTTONS 10 -#define USB_DEV_W_WATCHMAN1_BUTTONS 11 - -#define MAX_USB_DEVS 12 -#else -#define MAX_USB_DEVS 6 + USB_DEV_HMD_IMU_LHB, + USB_DEV_TRACKER0_LIGHTCAP, + USB_DEV_TRACKER0_2018_LIGHTCAP, + USB_DEV_W_WATCHMAN1_LIGHTCAP, + + USB_DEV_HMD_BUTTONS, + USB_DEV_TRACKER0_BUTTONS, + USB_DEV_TRACKER0_2018_BUTTONS, + USB_DEV_W_WATCHMAN1_BUTTONS, #endif + MAX_USB_DEVS +} -#define USB_IF_HMD 0 -#define USB_IF_HMD_IMU_LH 1 -#define USB_IF_WATCHMAN1 2 -#define USB_IF_WATCHMAN2 3 -#define USB_IF_TRACKER0 4 -#define USB_IF_W_WATCHMAN1 5 -#define USB_IF_LIGHTCAP 6 -#define USB_IF_TRACKER0_LIGHTCAP 7 -#define USB_IF_W_WATCHMAN1_LIGHTCAP 8 -#define USB_IF_HMD_BUTTONS 9 -#define USB_IF_TRACKER0_BUTTONS 10 -#define USB_IF_W_WATCHMAN1_BUTTONS 11 -#define MAX_INTERFACES 12 +enum { + USB_IF_HMD = 0 + USB_IF_HMD_IMU_LH, + USB_IF_WATCHMAN1, + USB_IF_WATCHMAN2, + USB_IF_TRACKER0, + USB_IF_TRACKER0_2018, + USB_IF_W_WATCHMAN1, + + USB_IF_LIGHTCAP, + USB_IF_TRACKER0_LIGHTCAP, + USB_IF_TRACKER0_2018_LIGHTCAP, + USB_IF_W_WATCHMAN1_LIGHTCAP, + + USB_IF_HMD_BUTTONS, + USB_IF_TRACKER0_BUTTON, + USB_IF_TRACKER0_2018_BUTTON, + USB_IF_W_WATCHMAN1_BUTTONS, + MAX_INTERFACES +} typedef struct SurviveUSBInterface SurviveUSBInterface; typedef struct SurviveViveData SurviveViveData; diff --git a/useful_files/81-vive.rules b/useful_files/81-vive.rules index a8b4e63..97b1f65 100644 --- a/useful_files/81-vive.rules +++ b/useful_files/81-vive.rules @@ -6,6 +6,7 @@ KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="28de", ATTRS{idProduct KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2050", TAG+="uaccess" KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2011", TAG+="uaccess" KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2012", TAG+="uaccess" +KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2022", TAG+="uaccess" KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2300", TAG+="uaccess" SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="2c87", TAG+="uaccess" @@ -21,7 +22,8 @@ SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="2c87", MODE="0666" SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2000", MODE="0666" # Light input SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2101", MODE="0666" # Watchman SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2012", MODE="0666" # Watchman wired -SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2300", MODE="0666" # Tracker wired +SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2022", MODE="0666" # Tracker wired +SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", ATTRS{idProduct}=="2300", MODE="0666" # Tracker 2018 wired #KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0bb4", ATTR{idProduct}=="2c87", MODE="0666" # HTC #KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="28de", ATTR{idProduct}=="2000", MODE="0666" # Valve -- cgit v1.2.3 From 92939b1ff61c4f3675db5d223b77a59599e6f242 Mon Sep 17 00:00:00 2001 From: WenZheng Li Date: Fri, 15 Jun 2018 17:56:43 +0900 Subject: added TR1 device for vive tracker(2018) --- src/survive_default_devices.c | 4 +++ src/survive_default_devices.h | 2 ++ src/survive_vive.c | 68 ++++++++++++++++++++++++++++++------------- 3 files changed, 54 insertions(+), 20 deletions(-) diff --git a/src/survive_default_devices.c b/src/survive_default_devices.c index 05dd10d..48f3b41 100644 --- a/src/survive_default_devices.c +++ b/src/survive_default_devices.c @@ -40,6 +40,10 @@ SurviveObject *survive_create_tr0(SurviveContext *ctx, const char *driver_name, void *driver) { return survive_create_device(ctx, driver_name, driver, "TR0", 0); } +SurviveObject *survive_create_tr1(SurviveContext *ctx, const char *driver_name, + void *driver) { + return survive_create_device(ctx, driver_name, driver, "TR1", 0); +} SurviveObject *survive_create_ww0(SurviveContext *ctx, const char *driver_name, void *driver) { return survive_create_device(ctx, driver_name, driver, "WW0", 0); diff --git a/src/survive_default_devices.h b/src/survive_default_devices.h index de7f0d4..2af6280 100644 --- a/src/survive_default_devices.h +++ b/src/survive_default_devices.h @@ -11,6 +11,8 @@ SurviveObject *survive_create_wm1(SurviveContext *ctx, const char *driver_name, void *driver, haptic_func cb); SurviveObject *survive_create_tr0(SurviveContext *ctx, const char *driver_name, void *driver); +SurviveObject *survive_create_tr1(SurviveContext *ctx, const char *driver_name, + void *driver); SurviveObject *survive_create_ww0(SurviveContext *ctx, const char *driver_name, void *driver); diff --git a/src/survive_vive.c b/src/survive_vive.c index ef94677..87ec1fe 100755 --- a/src/survive_vive.c +++ b/src/survive_vive.c @@ -58,7 +58,7 @@ const short vidpids[] = { 0x28de, 0x2000, 2, //Valve HMD lighthouse(B) (only used on HIDAPI, for lightcap) 0x28de, 0x2022, 2, //HTC Tracker (only used on HIDAPI, for lightcap) - 0x28de, 0x2300, 2, //HTC Tracker (only used on HIDAPI, for lightcap) + 0x28de, 0x2300, 2, //HTC Tracker 2018 (only used on HIDAPI, for lightcap) 0x28de, 0x2012, 2, //Valve Watchman, USB connected (only used on HIDAPI, for lightcap) #endif @@ -70,64 +70,64 @@ const char * devnames[] = { "Watchman 1", "Watchman 2", "Tracker 0", - "Tracker(2018) 0", + "Tracker 1", "Wired Watchman 1", #ifdef HIDAPI "HMD Lightcap", "Tracker 0 Lightcap", - "Tracker(2018) 0 Lightcap", + "Tracker 1 Lightcap", "Wired Watchman 1 Lightcap", "HMD Buttons", "Tracker 0 Buttons", - "Tracker(2018) Buttons", + "Tracker 1 Buttons", "Wired Watchman 1 Buttons", #endif }; //length MAX_USB_INTERFACES enum { - USB_DEV_HMD = 0, + USB_DEV_HMD = 0, USB_DEV_HMD_IMU_LH, USB_DEV_WATCHMAN1, USB_DEV_WATCHMAN2, USB_DEV_TRACKER0, - USB_DEV_TRACKER0_2018, + USB_DEV_TRACKER1, USB_DEV_W_WATCHMAN1, // Wired Watchman attached via USB #ifdef HIDAPI USB_DEV_HMD_IMU_LHB, USB_DEV_TRACKER0_LIGHTCAP, - USB_DEV_TRACKER0_2018_LIGHTCAP, + USB_DEV_TRACKER1_LIGHTCAP, USB_DEV_W_WATCHMAN1_LIGHTCAP, USB_DEV_HMD_BUTTONS, USB_DEV_TRACKER0_BUTTONS, - USB_DEV_TRACKER0_2018_BUTTONS, + USB_DEV_TRACKER1_BUTTONS, USB_DEV_W_WATCHMAN1_BUTTONS, #endif MAX_USB_DEVS -} +}; enum { - USB_IF_HMD = 0 + USB_IF_HMD = 0, USB_IF_HMD_IMU_LH, USB_IF_WATCHMAN1, USB_IF_WATCHMAN2, USB_IF_TRACKER0, - USB_IF_TRACKER0_2018, + USB_IF_TRACKER1, USB_IF_W_WATCHMAN1, USB_IF_LIGHTCAP, USB_IF_TRACKER0_LIGHTCAP, - USB_IF_TRACKER0_2018_LIGHTCAP, + USB_IF_TRACKER1_LIGHTCAP, USB_IF_W_WATCHMAN1_LIGHTCAP, USB_IF_HMD_BUTTONS, - USB_IF_TRACKER0_BUTTON, - USB_IF_TRACKER0_2018_BUTTON, + USB_IF_TRACKER0_BUTTONS, + USB_IF_TRACKER1_BUTTONS, USB_IF_W_WATCHMAN1_BUTTONS, MAX_INTERFACES -} +}; typedef struct SurviveUSBInterface SurviveUSBInterface; typedef struct SurviveViveData SurviveViveData; @@ -182,7 +182,7 @@ void survive_data_cb( SurviveUSBInterface * si ); //USB Subsystem void survive_usb_close( SurviveContext * t ); -int survive_usb_init( SurviveViveData * sv, SurviveObject * hmd, SurviveObject *wm0, SurviveObject * wm1, SurviveObject * tr0 , SurviveObject * ww0 ); +int survive_usb_init( SurviveViveData * sv, SurviveObject * hmd, SurviveObject *wm0, SurviveObject * wm1, SurviveObject * tr0 , SurviveObject * tr1, SurviveObject * ww0 ); int survive_usb_poll( SurviveContext * ctx ); int survive_get_config( char ** config, SurviveViveData * ctx, int devno, int iface, int send_extra_magic ); int survive_vive_send_magic(SurviveContext * ctx, void * drv, int magic_code, void * data, int datalen ); @@ -349,7 +349,7 @@ static inline int hid_get_feature_report_timeout(USBHANDLE device, uint16_t ifac return -1; } -int survive_usb_init( SurviveViveData * sv, SurviveObject * hmd, SurviveObject *wm0, SurviveObject * wm1, SurviveObject * tr0 , SurviveObject * ww0 ) +int survive_usb_init( SurviveViveData * sv, SurviveObject * hmd, SurviveObject *wm0, SurviveObject * wm1, SurviveObject * tr0, SurviveObject * tr1, SurviveObject * ww0 ) { SurviveContext * ctx = sv->ctx; #ifdef HIDAPI @@ -517,6 +517,7 @@ int survive_usb_init( SurviveViveData * sv, SurviveObject * hmd, SurviveObject * if( sv->udev[USB_DEV_WATCHMAN1] ) { survive_add_object( ctx, wm0 ); } if( sv->udev[USB_DEV_WATCHMAN2] ) { survive_add_object( ctx, wm1 ); } if( sv->udev[USB_DEV_TRACKER0] ) { survive_add_object( ctx, tr0 ); } + if( sv->udev[USB_DEV_TRACKER1] ) { survive_add_object( ctx, tr1 ); } if( sv->udev[USB_DEV_W_WATCHMAN1] ) { survive_add_object( ctx, ww0 ); } if( sv->udev[USB_DEV_HMD] && AttachInterface( sv, hmd, USB_IF_HMD, sv->udev[USB_DEV_HMD], 0x81, survive_data_cb, "Mainboard" ) ) { return -6; } @@ -524,6 +525,7 @@ int survive_usb_init( SurviveViveData * sv, SurviveObject * hmd, SurviveObject * if( sv->udev[USB_DEV_WATCHMAN1] && AttachInterface( sv, wm0, USB_IF_WATCHMAN1, sv->udev[USB_DEV_WATCHMAN1], 0x81, survive_data_cb, "Watchman 1" ) ) { return -8; } if( sv->udev[USB_DEV_WATCHMAN2] && AttachInterface( sv, wm1, USB_IF_WATCHMAN2, sv->udev[USB_DEV_WATCHMAN2], 0x81, survive_data_cb, "Watchman 2")) { return -9; } if( sv->udev[USB_DEV_TRACKER0] && AttachInterface( sv, tr0, USB_IF_TRACKER0, sv->udev[USB_DEV_TRACKER0], 0x81, survive_data_cb, "Tracker 1")) { return -10; } + if( sv->udev[USB_DEV_TRACKER1] && AttachInterface( sv, tr0, USB_IF_TRACKER1, sv->udev[USB_DEV_TRACKER1], 0x81, survive_data_cb, "Tracker 2")) { return -10; } if( sv->udev[USB_DEV_W_WATCHMAN1] && AttachInterface( sv, ww0, USB_IF_W_WATCHMAN1, sv->udev[USB_DEV_W_WATCHMAN1], 0x81, survive_data_cb, "Wired Watchman 1")) { return -11; } #ifdef HIDAPI //Tricky: use other interface for actual lightcap. XXX THIS IS NOT YET RIGHT!!! @@ -531,7 +533,9 @@ int survive_usb_init( SurviveViveData * sv, SurviveObject * hmd, SurviveObject * // This is a HACK! But it works. Need to investigate further sv->uiface[USB_DEV_TRACKER0_LIGHTCAP].actual_len = 64; + sv->uiface[USB_DEV_TRACKER1_LIGHTCAP].actual_len = 64; if( sv->udev[USB_DEV_TRACKER0_LIGHTCAP] && AttachInterface( sv, tr0, USB_IF_TRACKER0_LIGHTCAP, sv->udev[USB_DEV_TRACKER0_LIGHTCAP], 0x82, survive_data_cb, "Tracker 1 Lightcap")) { return -13; } + if( sv->udev[USB_DEV_TRACKER1_LIGHTCAP] && AttachInterface( sv, tr0, USB_IF_TRACKER1_LIGHTCAP, sv->udev[USB_DEV_TRACKER1_LIGHTCAP], 0x82, survive_data_cb, "Tracker 2 Lightcap")) { return -13; } if( sv->udev[USB_DEV_W_WATCHMAN1_LIGHTCAP] && AttachInterface( sv, ww0, USB_IF_W_WATCHMAN1_LIGHTCAP, sv->udev[USB_DEV_W_WATCHMAN1_LIGHTCAP], 0x82, survive_data_cb, "Wired Watchman 1 Lightcap")) { return -13; } @@ -542,6 +546,7 @@ int survive_usb_init( SurviveViveData * sv, SurviveObject * hmd, SurviveObject * #else if( sv->udev[USB_DEV_HMD_IMU_LH] && AttachInterface( sv, hmd, USB_IF_LIGHTCAP, sv->udev[USB_DEV_HMD_IMU_LH], 0x82, survive_data_cb, "Lightcap")) { return -12; } if( sv->udev[USB_DEV_TRACKER0] && AttachInterface( sv, tr0, USB_IF_TRACKER0_LIGHTCAP, sv->udev[USB_DEV_TRACKER0], 0x82, survive_data_cb, "Tracker 0 Lightcap")) { return -13; } + if( sv->udev[USB_DEV_TRACKER1] && AttachInterface( sv, tr0, USB_IF_TRACKER1_LIGHTCAP, sv->udev[USB_DEV_TRACKER1], 0x82, survive_data_cb, "Tracker 1 Lightcap")) { return -13; } if( sv->udev[USB_DEV_W_WATCHMAN1] && AttachInterface( sv, ww0, USB_IF_W_WATCHMAN1_LIGHTCAP, sv->udev[USB_DEV_W_WATCHMAN1], 0x82, survive_data_cb, "Wired Watchman 1 Lightcap")) { return -13; } #endif SV_INFO( "All enumerated devices attached." ); @@ -1529,8 +1534,7 @@ void survive_data_cb( SurviveUSBInterface * si ) break; } case USB_IF_LIGHTCAP: - case USB_IF_TRACKER0_LIGHTCAP: - case USB_IF_W_WATCHMAN1_LIGHTCAP: + case USB_IF_TRACKER1_LIGHTCAP: { int i; for( i = 0; i < 9; i++ ) @@ -1544,6 +1548,29 @@ void survive_data_cb( SurviveUSBInterface * si ) } break; } + case USB_IF_W_WATCHMAN1_LIGHTCAP: + case USB_IF_TRACKER0_LIGHTCAP: + { + int i=0; + for( i = 0; i < 7; i++ ) + { + unsigned short *sensorId = (unsigned short *)readdata; + unsigned short *length = (unsigned short *)(&(readdata[2])); + unsigned long *time = (unsigned long *)(&(readdata[4])); + LightcapElement le; + le.sensor_id = (uint8_t)POP2; + le.length = POP2; + le.timestamp = POP4; + if( le.sensor_id > 0xfd ) continue; // + handle_lightcap( obj, &le ); + } + break; + + if (id != 33) + { + int a = 0; // breakpoint here + } + } case USB_IF_TRACKER0_BUTTONS: case USB_IF_W_WATCHMAN1_BUTTONS: { @@ -1690,6 +1717,7 @@ int DriverRegHTCVive( SurviveContext * ctx ) SurviveObject * wm0 = survive_create_wm0(ctx, "HTC", sv, 0); SurviveObject * wm1 = survive_create_wm1(ctx, "HTC", sv, 0); SurviveObject * tr0 = survive_create_tr0(ctx, "HTC", sv); + SurviveObject * tr1 = survive_create_tr1(ctx, "HTC", sv); SurviveObject * ww0 = survive_create_ww0(ctx, "HTC", sv); sv->ctx = ctx; @@ -1703,7 +1731,7 @@ int DriverRegHTCVive( SurviveContext * ctx ) #endif //USB must happen last. - if (survive_usb_init(sv, hmd, wm0, wm1, tr0, ww0)) { + if (survive_usb_init(sv, hmd, wm0, wm1, tr0, tr1, ww0)) { // TODO: Cleanup any libUSB stuff sitting around. goto fail_gracefully; } -- cgit v1.2.3 From 902bbde43fb6e000140da0da56c05f2d4af1df5f Mon Sep 17 00:00:00 2001 From: WenZheng Li Date: Fri, 15 Jun 2018 18:37:01 +0900 Subject: fixed load config segfault --- src/survive_vive.c | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/survive_vive.c b/src/survive_vive.c index 87ec1fe..c000307 100755 --- a/src/survive_vive.c +++ b/src/survive_vive.c @@ -525,7 +525,7 @@ int survive_usb_init( SurviveViveData * sv, SurviveObject * hmd, SurviveObject * if( sv->udev[USB_DEV_WATCHMAN1] && AttachInterface( sv, wm0, USB_IF_WATCHMAN1, sv->udev[USB_DEV_WATCHMAN1], 0x81, survive_data_cb, "Watchman 1" ) ) { return -8; } if( sv->udev[USB_DEV_WATCHMAN2] && AttachInterface( sv, wm1, USB_IF_WATCHMAN2, sv->udev[USB_DEV_WATCHMAN2], 0x81, survive_data_cb, "Watchman 2")) { return -9; } if( sv->udev[USB_DEV_TRACKER0] && AttachInterface( sv, tr0, USB_IF_TRACKER0, sv->udev[USB_DEV_TRACKER0], 0x81, survive_data_cb, "Tracker 1")) { return -10; } - if( sv->udev[USB_DEV_TRACKER1] && AttachInterface( sv, tr0, USB_IF_TRACKER1, sv->udev[USB_DEV_TRACKER1], 0x81, survive_data_cb, "Tracker 2")) { return -10; } + if( sv->udev[USB_DEV_TRACKER1] && AttachInterface( sv, tr1, USB_IF_TRACKER1, sv->udev[USB_DEV_TRACKER1], 0x81, survive_data_cb, "Tracker 2")) { return -10; } if( sv->udev[USB_DEV_W_WATCHMAN1] && AttachInterface( sv, ww0, USB_IF_W_WATCHMAN1, sv->udev[USB_DEV_W_WATCHMAN1], 0x81, survive_data_cb, "Wired Watchman 1")) { return -11; } #ifdef HIDAPI //Tricky: use other interface for actual lightcap. XXX THIS IS NOT YET RIGHT!!! @@ -535,18 +535,19 @@ int survive_usb_init( SurviveViveData * sv, SurviveObject * hmd, SurviveObject * sv->uiface[USB_DEV_TRACKER0_LIGHTCAP].actual_len = 64; sv->uiface[USB_DEV_TRACKER1_LIGHTCAP].actual_len = 64; if( sv->udev[USB_DEV_TRACKER0_LIGHTCAP] && AttachInterface( sv, tr0, USB_IF_TRACKER0_LIGHTCAP, sv->udev[USB_DEV_TRACKER0_LIGHTCAP], 0x82, survive_data_cb, "Tracker 1 Lightcap")) { return -13; } - if( sv->udev[USB_DEV_TRACKER1_LIGHTCAP] && AttachInterface( sv, tr0, USB_IF_TRACKER1_LIGHTCAP, sv->udev[USB_DEV_TRACKER1_LIGHTCAP], 0x82, survive_data_cb, "Tracker 2 Lightcap")) { return -13; } + if( sv->udev[USB_DEV_TRACKER1_LIGHTCAP] && AttachInterface( sv, tr1, USB_IF_TRACKER1_LIGHTCAP, sv->udev[USB_DEV_TRACKER1_LIGHTCAP], 0x82, survive_data_cb, "Tracker 2 Lightcap")) { return -13; } if( sv->udev[USB_DEV_W_WATCHMAN1_LIGHTCAP] && AttachInterface( sv, ww0, USB_IF_W_WATCHMAN1_LIGHTCAP, sv->udev[USB_DEV_W_WATCHMAN1_LIGHTCAP], 0x82, survive_data_cb, "Wired Watchman 1 Lightcap")) { return -13; } if (sv->udev[USB_DEV_TRACKER0_BUTTONS] && AttachInterface(sv, tr0, USB_IF_TRACKER0_BUTTONS, sv->udev[USB_DEV_TRACKER0_BUTTONS], 0x83, survive_data_cb, "Tracker 1 Buttons")) { return -13; } + if (sv->udev[USB_DEV_TRACKER1_BUTTONS] && AttachInterface(sv, tr1, USB_IF_TRACKER1_BUTTONS, sv->udev[USB_DEV_TRACKER1_BUTTONS], 0x83, survive_data_cb, "Tracker 2 Buttons")) { return -13; } if (sv->udev[USB_DEV_W_WATCHMAN1_BUTTONS] && AttachInterface(sv, ww0, USB_IF_W_WATCHMAN1_BUTTONS, sv->udev[USB_DEV_W_WATCHMAN1_BUTTONS], 0x83, survive_data_cb, "Wired Watchman 1 BUTTONS")) { return -13; } #else if( sv->udev[USB_DEV_HMD_IMU_LH] && AttachInterface( sv, hmd, USB_IF_LIGHTCAP, sv->udev[USB_DEV_HMD_IMU_LH], 0x82, survive_data_cb, "Lightcap")) { return -12; } if( sv->udev[USB_DEV_TRACKER0] && AttachInterface( sv, tr0, USB_IF_TRACKER0_LIGHTCAP, sv->udev[USB_DEV_TRACKER0], 0x82, survive_data_cb, "Tracker 0 Lightcap")) { return -13; } - if( sv->udev[USB_DEV_TRACKER1] && AttachInterface( sv, tr0, USB_IF_TRACKER1_LIGHTCAP, sv->udev[USB_DEV_TRACKER1], 0x82, survive_data_cb, "Tracker 1 Lightcap")) { return -13; } + if( sv->udev[USB_DEV_TRACKER1] && AttachInterface( sv, tr1, USB_IF_TRACKER1_LIGHTCAP, sv->udev[USB_DEV_TRACKER1], 0x82, survive_data_cb, "Tracker 1 Lightcap")) { return -13; } if( sv->udev[USB_DEV_W_WATCHMAN1] && AttachInterface( sv, ww0, USB_IF_W_WATCHMAN1_LIGHTCAP, sv->udev[USB_DEV_W_WATCHMAN1], 0x82, survive_data_cb, "Wired Watchman 1 Lightcap")) { return -13; } #endif SV_INFO( "All enumerated devices attached." ); @@ -651,6 +652,23 @@ int survive_vive_send_magic(SurviveContext * ctx, void * drv, int magic_code, vo //#endif + if (sv->udev[USB_DEV_TRACKER1]) + { + static uint8_t vive_magic_power_on[5] = { 0x04 }; + r = update_feature_report( sv->udev[USB_DEV_TRACKER1], 0, vive_magic_power_on, sizeof( vive_magic_power_on ) ); + if( r != sizeof( vive_magic_power_on ) ) return 5; + } + if (sv->udev[USB_DEV_TRACKER1]) + { + static uint8_t vive_magic_enable_lighthouse[5] = { 0x04 }; + r = update_feature_report( sv->udev[USB_DEV_TRACKER1], 0, vive_magic_enable_lighthouse, sizeof( vive_magic_enable_lighthouse ) ); + if( r != sizeof( vive_magic_enable_lighthouse ) ) return 5; + + static uint8_t vive_magic_enable_lighthouse2[5] = { 0x07, 0x02 }; //Switch to 0x25 mode (able to get more light updates) + r = update_feature_report( sv->udev[USB_DEV_TRACKER1], 0, vive_magic_enable_lighthouse2, sizeof( vive_magic_enable_lighthouse2 ) ); + if( r != sizeof( vive_magic_enable_lighthouse2 ) ) return 5; + } + #if 0 for (int j=0; j < 40; j++) { @@ -1471,6 +1489,7 @@ void survive_data_cb( SurviveUSBInterface * si ) case USB_IF_HMD_IMU_LH: case USB_IF_W_WATCHMAN1: case USB_IF_TRACKER0: + case USB_IF_TRACKER1: { int i; //printf( "%d -> ", size ); @@ -1572,6 +1591,7 @@ void survive_data_cb( SurviveUSBInterface * si ) } } case USB_IF_TRACKER0_BUTTONS: + case USB_IF_TRACKER1_BUTTONS: case USB_IF_W_WATCHMAN1_BUTTONS: { if (1 == id) @@ -1740,6 +1760,7 @@ int DriverRegHTCVive( SurviveContext * ctx ) sv->udev[USB_DEV_WATCHMAN1] || sv->udev[USB_DEV_WATCHMAN2] || sv->udev[USB_DEV_TRACKER0] || + sv->udev[USB_DEV_TRACKER1] || sv->udev[USB_DEV_W_WATCHMAN1] ) { survive_add_driver( ctx, sv, survive_vive_usb_poll, survive_vive_close, survive_vive_send_magic ); } else { @@ -1747,13 +1768,14 @@ int DriverRegHTCVive( SurviveContext * ctx ) } //Next, pull out the config stuff. - if (sv->udev[USB_DEV_HMD_IMU_LH] && LoadConfig(sv, hmd, 1, 0, 0)) { + if (sv->udev[USB_DEV_HMD_IMU_LH] && LoadConfig(sv, hmd, USB_DEV_HMD_IMU_LH, 0, 0)) { SV_INFO("HMD config issue."); } - if( sv->udev[USB_DEV_WATCHMAN1] && LoadConfig( sv, wm0, 2, 0, 1 )) { SV_INFO( "Watchman 0 config issue." ); } - if( sv->udev[USB_DEV_WATCHMAN2] && LoadConfig( sv, wm1, 3, 0, 1 )) { SV_INFO( "Watchman 1 config issue." ); } - if( sv->udev[USB_DEV_TRACKER0] && LoadConfig( sv, tr0, 4, 0, 0 )) { SV_INFO( "Tracker 0 config issue." ); } - if( sv->udev[USB_DEV_W_WATCHMAN1] && LoadConfig( sv, ww0, 5, 0, 0 )) { SV_INFO( "Wired Watchman 0 config issue." ); } + if( sv->udev[USB_DEV_WATCHMAN1] && LoadConfig( sv, wm0, USB_DEV_WATCHMAN1, 0, 1 )) { SV_INFO( "Watchman 0 config issue." ); } + if( sv->udev[USB_DEV_WATCHMAN2] && LoadConfig( sv, wm1, USB_DEV_WATCHMAN2, 0, 1 )) { SV_INFO( "Watchman 1 config issue." ); } + if( sv->udev[USB_DEV_TRACKER0] && LoadConfig( sv, tr0, USB_DEV_TRACKER0, 0, 0 )) { SV_INFO( "Tracker 0 config issue." ); } + if( sv->udev[USB_DEV_TRACKER1] && LoadConfig( sv, tr1, USB_DEV_TRACKER1, 0, 0 )) { SV_INFO( "Tracker 1 config issue." ); } + if( sv->udev[USB_DEV_W_WATCHMAN1] && LoadConfig( sv, ww0, USB_DEV_W_WATCHMAN1, 0, 0 )) { SV_INFO( "Wired Watchman 0 config issue." ); } return 0; @@ -1762,6 +1784,7 @@ fail_gracefully: free( wm0 ); free( wm1 ); free( tr0 ); + free( tr1 ); free( ww0 ); survive_vive_usb_close( sv ); free( sv ); -- cgit v1.2.3