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.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/survive_driverman.h (limited to 'src/survive_driverman.h') diff --git a/src/survive_driverman.h b/src/survive_driverman.h new file mode 100644 index 0000000..fb385da --- /dev/null +++ b/src/survive_driverman.h @@ -0,0 +1,22 @@ +#ifndef SURVIVE_DRIVERMAN_H +#define SURVIVE_DRIVERMAN_H + +//Driver registration +#define MAX_DRIVERS 32 + +void RegisterDriver( const char * name, void * data ); +void * GetDriver( const char * name ); +const char * GetDriverNameMatching( const char * prefix, int place ); +void ListDrivers(); + +#define REGISTER_LINKTIME( func ) \ + void __attribute__((constructor)) Register##func() { RegisterDriver( #func, &func ); } + +struct SurviveContext; + +typedef int (*DeviceDriver)( struct SurviveContext * ctx ); +typedef int (*DeviceDriverCb)( struct SurviveContext * ctx, void * driver ); +typedef int (*DeviceDriverMagicCb)( struct SurviveContext * ctx, void * driver, int magic_code, void * data, int datalen ); + +#endif + -- cgit v1.2.3 From 51751d4a9f407f526de2b626d44e14690fbef004 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Sun, 26 Feb 2017 10:28:56 -0500 Subject: cleanup --- src/survive_driverman.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/survive_driverman.h') diff --git a/src/survive_driverman.h b/src/survive_driverman.h index fb385da..5e13caf 100644 --- a/src/survive_driverman.h +++ b/src/survive_driverman.h @@ -1,3 +1,12 @@ +// (C) 2017 <>< C. N. Lohr, Under MIT/x11 License. +// +// This file is intended to be used for self-registering functions. By using +// this it means that you do not need to have complicated switch statements or +// #defines for dfferent inclusion of drivers/other code. You can simply +// register your function and it will be put into a list. +// +// + #ifndef SURVIVE_DRIVERMAN_H #define SURVIVE_DRIVERMAN_H @@ -12,11 +21,18 @@ void ListDrivers(); #define REGISTER_LINKTIME( func ) \ void __attribute__((constructor)) Register##func() { RegisterDriver( #func, &func ); } + +// +// Specific types of drivers. +// + struct SurviveContext; +//Device drivers (prefix your drivers with "DriverReg") i.e. +// REGISTER_LINKTIME( DriverRegHTCVive ); typedef int (*DeviceDriver)( struct SurviveContext * ctx ); -typedef int (*DeviceDriverCb)( struct SurviveContext * ctx, void * driver ); -typedef int (*DeviceDriverMagicCb)( struct SurviveContext * ctx, void * driver, int magic_code, void * data, int datalen ); + +//more driver types here? i.e. posefinders, etc. #endif -- cgit v1.2.3