aboutsummaryrefslogtreecommitdiff
path: root/src/survive_driverman.c
diff options
context:
space:
mode:
authorcnlohr <lohr85@gmail.com>2017-02-25 23:52:48 -0500
committercnlohr <lohr85@gmail.com>2017-02-25 23:52:48 -0500
commit55cedfc6a6b035d6eb54457782818fef61cae500 (patch)
treeca11020aeb8970830a6f52ada199767686078fd4 /src/survive_driverman.c
parentf92f5dc93cbb53a99da51984541a7e4a70605639 (diff)
downloadlibsurvive-55cedfc6a6b035d6eb54457782818fef61cae500.tar.gz
libsurvive-55cedfc6a6b035d6eb54457782818fef61cae500.tar.bz2
Huge shift: Put HTC vive into its own file, to free up the rest of the system for libsurvive.
Diffstat (limited to 'src/survive_driverman.c')
-rw-r--r--src/survive_driverman.c50
1 files changed, 50 insertions, 0 deletions
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 <string.h>
+#include <stdio.h>
+
+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] );
+ }
+
+}
+