diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/survive_vive.c | 98 |
1 files changed, 95 insertions, 3 deletions
diff --git a/src/survive_vive.c b/src/survive_vive.c index 9a3cb03..ef150f6 100755 --- a/src/survive_vive.c +++ b/src/survive_vive.c @@ -51,6 +51,11 @@ const short vidpids[] = { 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, 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, 0x2012, 2, //Valve Watchman, USB connected (only used on HIDAPI, for lightcap) + #endif }; //length MAX_USB_INTERFACES*2 @@ -65,6 +70,10 @@ const char * devnames[] = { "HMD Lightcap", "Tracker 0 Lightcap", "Wired Watchman 1 Lightcap", + + "HMD Buttons", + "Tracker 0 Buttons", + "Wired Watchman 1 Buttons", #endif }; //length MAX_USB_INTERFACES @@ -80,7 +89,12 @@ const char * devnames[] = { #define USB_DEV_HMD_IMU_LHB 6 #define USB_DEV_TRACKER0_LIGHTCAP 7 #define USB_DEV_W_WATCHMAN1_LIGHTCAP 8 -#define MAX_USB_DEVS 9 + +#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 #endif @@ -94,7 +108,10 @@ const char * devnames[] = { #define USB_IF_LIGHTCAP 6 #define USB_IF_TRACKER0_LIGHTCAP 7 #define USB_IF_W_WATCHMAN1_LIGHTCAP 8 -#define MAX_INTERFACES 9 +#define USB_IF_HMD_BUTTONS 9 +#define USB_IF_TRACKER0_BUTTONS 10 +#define USB_IF_W_WATCHMAN1_BUTTONS 11 +#define MAX_INTERFACES 12 typedef struct SurviveUSBInterface SurviveUSBInterface; typedef struct SurviveViveData SurviveViveData; @@ -487,7 +504,13 @@ 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; 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_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_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, ww0, USB_IF_TRACKER0_LIGHTCAP, sv->udev[USB_DEV_TRACKER0], 0x82, survive_data_cb, "Tracker 0 Lightcap")) { return -13; } @@ -1192,7 +1215,10 @@ void survive_data_cb( SurviveUSBInterface * si ) ctx->imuproc( obj, 3, agm, timecode, code ); } } - + if (id != 32) + { + int a=0; // set breakpoint here + } //DONE OK. break; } @@ -1250,7 +1276,73 @@ void survive_data_cb( SurviveUSBInterface * si ) handle_lightcap( obj, &le ); } break; + + if (id != 33) + { + int a = 0; // breakpoint here + } + } + case USB_IF_TRACKER0_BUTTONS: + case USB_IF_W_WATCHMAN1_BUTTONS: + { + if (1 == id) + { + //0x00 uint8 1 reportID HID report identifier(= 1) + //0x02 uint16 2 reportType(? ) 0x0B04: Ping(every second) / 0x3C01 : User input + //0x04 uint32 4 reportCount Counter that increases with every report + //0x08 uint32 4 pressedButtons Bit field, see below for individual buttons + //0x0C uint16 2 triggerOrBattery Analog trigger value(user input) / Battery voltage ? (ping) + //0x0E uint8 1 batteryCharge Bit 7 : Charging / Bit 6..0 : Battery charge in percent + //0x10 uint32 4 hardwareID Hardware ID(user input) / 0x00000000 (ping) + //0x14 int16 2 touchpadHorizontal Horizontal thumb position(Left : -32768 / Right : 32767) + //0x16 int16 2 touchpadVertical Vertical thumb position(Bottom : -32768 / Top : 32767) + //0x18 ? 2 ? unknown + //0x1A uint16 2 triggerHighRes Analog trigger value with higher resolution + //0x1C ? 24 ? unknown + //0x34 uint16 2 triggerRawMaybe Analog trigger value, maybe raw sensor data + //0x36 ? 8 ? unknown + //0x3E uint8 1 someBitFieldMaybe 0x00 : ping / 0x64 : user input + //0x3F ? 1 ? unknown + + typedef struct + { + //uint8_t reportId; + uint16_t reportType; + uint32_t reportCount; + uint32_t pressedButtons; + uint16_t triggerOrBattery; + uint16_t batteryCharge; + uint32_t hardwareId; + int16_t touchpadHorizontal; + int16_t touchpadVertical; + uint16_t unknown1; + uint16_t triggerHighRes; + uint8_t unknown2; + uint8_t unknown3; + uint8_t unknown4; + uint16_t triggerRaw; + uint8_t unknown5; + uint8_t unknown6; // maybe some bitfield? + uint8_t unknown7; + } usb_buttons_raw; + + usb_buttons_raw *raw = (usb_buttons_raw*) readdata; + if (raw->reportType == 0x100) + { + printf("Buttons: %8.8x\n", raw->pressedButtons); + } + int a = 0; + } + else + { + int a = 0;// breakpoint here + } } + default: + { + int a = 0; // breakpoint here + } + } } |