diff options
author | CNLohr <lohr85@gmail.com> | 2017-03-16 01:57:36 -0400 |
---|---|---|
committer | CNLohr <lohr85@gmail.com> | 2017-03-16 01:57:36 -0400 |
commit | 2eaf385fdd769c232be5826353fcf0dba13b827e (patch) | |
tree | 782faeebab0b031b8f75bb03b7f7aa06e26e552c /src/survive_vive.c | |
parent | a15a75ea846f434691fc30f0db79e5fa844c065c (diff) | |
download | libsurvive-2eaf385fdd769c232be5826353fcf0dba13b827e.tar.gz libsurvive-2eaf385fdd769c232be5826353fcf0dba13b827e.tar.bz2 |
Make the vive able to deal with data in new-valve-mode or old-valve-mode.
Diffstat (limited to 'src/survive_vive.c')
-rwxr-xr-x | src/survive_vive.c | 34 |
1 files changed, 19 insertions, 15 deletions
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 } } } |