From 2eaf385fdd769c232be5826353fcf0dba13b827e Mon Sep 17 00:00:00 2001 From: CNLohr Date: Thu, 16 Mar 2017 01:57:36 -0400 Subject: Make the vive able to deal with data in new-valve-mode or old-valve-mode. --- .gitignore | 7 +++++++ src/survive_vive.c | 34 +++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index cb8f780..ed33e2b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,10 @@ windows/calibrate.exe windows/calinfo/1.json.gz windows/calibrate.def windows/calinfo/3.json.gz +windows/calinfo/WM1_points.csv +windows/calinfo/HMD_normals.csv +windows/calinfo/WM0_points.csv +windows/calinfo/WM1_normals.csv +windows/calinfo/HMD_points.csv +windows/calinfo/WM0_normals.csv +windows/calinfo/2.json.gz diff --git a/src/survive_vive.c b/src/survive_vive.c index 12d8c16..c3967cd 100755 --- a/src/survive_vive.c +++ b/src/survive_vive.c @@ -1082,24 +1082,28 @@ void survive_data_cb( SurviveUSBInterface * si ) case USB_IF_LIGHTCAP: { int i; - #ifdef HIDAPI - for( i = 0; i < 7; i++ ) + + if( si->buffer[0] == 0x25 ) //Once the valve drivers run, they somehow put the HMD into 7-byte-width messages. { - LightcapElement le; - le.sensor_id = POP1; - le.type = 0xfe; - le.length = POP2; - le.timestamp = POP4; - if( le.sensor_id == 0xff ) break; - handle_lightcap( obj, &le ); - } - #else - for( i = 0; i < 7; i++ ) + for( i = 0; i < 9; i++ ) + { + LightcapElement le; + le.sensor_id = POP1; + le.type = 0xfe; + le.length = POP2; + le.timestamp = POP4; + if( le.sensor_id == 0xff ) break; + handle_lightcap( obj, &le ); + } + } + else //Otherwise, we're in the old mode. { - handle_lightcap( obj, (LightcapElement*)&readdata[i*8] ); + for( i = 0; i < 7; i++ ) + { + handle_lightcap( obj, (LightcapElement*)&readdata[i*8] ); + } + break; } - break; - #endif } } } -- cgit v1.2.3