From 55cedfc6a6b035d6eb54457782818fef61cae500 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sat, 25 Feb 2017 23:52:48 -0500 Subject: Huge shift: Put HTC vive into its own file, to free up the rest of the system for libsurvive. --- src/survive_driverman.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/survive_driverman.c (limited to 'src/survive_driverman.c') diff --git a/src/survive_driverman.c b/src/survive_driverman.c new file mode 100644 index 0000000..b4684c8 --- /dev/null +++ b/src/survive_driverman.c @@ -0,0 +1,50 @@ +#include "survive_driverman.h" +#include +#include + +static void * Drivers[MAX_DRIVERS]; +static const char * DriverNames[MAX_DRIVERS]; +static int NrDrivers; + +void RegisterDriver( const char * element, void * data ) +{ + Drivers[NrDrivers] = data; + DriverNames[NrDrivers] = element; + NrDrivers++; +} + +void * GetDriver( const char * element ) +{ + int i; + for( i = 0; i < NrDrivers; i++ ) + { + if( strcmp( element, DriverNames[i] ) == 0 ) return Drivers[i]; + } + return 0; +} + +const char * GetDriverNameMatching( const char * prefix, int place ) +{ + int i; + int prefixlen = strlen( prefix ); + + for( i = 0; i < NrDrivers; i++ ) + { + if( memcmp( prefix, DriverNames[i], prefixlen ) == 0 ) + if( 0 == (place--) ) + return DriverNames[i]; + } + return 0; +} + +void ListDrivers() +{ + int i; + printf( "Drivers (%d/%d):\n", NrDrivers, MAX_DRIVERS ); + for( i = 0; i < NrDrivers; i++ ) + { + printf( " %s\n", DriverNames[i] ); + } + +} + -- cgit v1.2.3