aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCNLohr <lohr85@gmail.com>2017-03-16 01:57:36 -0400
committerCNLohr <lohr85@gmail.com>2017-03-16 01:57:36 -0400
commit2eaf385fdd769c232be5826353fcf0dba13b827e (patch)
tree782faeebab0b031b8f75bb03b7f7aa06e26e552c
parenta15a75ea846f434691fc30f0db79e5fa844c065c (diff)
downloadlibsurvive-2eaf385fdd769c232be5826353fcf0dba13b827e.tar.gz
libsurvive-2eaf385fdd769c232be5826353fcf0dba13b827e.tar.bz2
Make the vive able to deal with data in new-valve-mode or old-valve-mode.
-rw-r--r--.gitignore7
-rwxr-xr-xsrc/survive_vive.c34
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
}
}
}