diff options
author | mwturvey <michael.w.turvey@intel.com> | 2017-02-27 11:26:05 -0700 |
---|---|---|
committer | mwturvey <michael.w.turvey@intel.com> | 2017-02-27 11:26:05 -0700 |
commit | 321749a4b8e3e8b3f4b03863200fbf86e36a0bbe (patch) | |
tree | b7d81c89b3a4ccb72d46e5194929b47df88345b7 /src/survive_driverman.h | |
parent | d1a02d649c034f43a11548a04d8d2a58786ff8ff (diff) | |
parent | 51751d4a9f407f526de2b626d44e14690fbef004 (diff) | |
download | libsurvive-321749a4b8e3e8b3f4b03863200fbf86e36a0bbe.tar.gz libsurvive-321749a4b8e3e8b3f4b03863200fbf86e36a0bbe.tar.bz2 |
Merge branch 'master' of https://github.com/cnlohr/libsurvive
Diffstat (limited to 'src/survive_driverman.h')
-rw-r--r-- | src/survive_driverman.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/survive_driverman.h b/src/survive_driverman.h new file mode 100644 index 0000000..5e13caf --- /dev/null +++ b/src/survive_driverman.h @@ -0,0 +1,38 @@ +// (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 + +//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 ); } + + +// +// Specific types of drivers. +// + +struct SurviveContext; + +//Device drivers (prefix your drivers with "DriverReg") i.e. +// REGISTER_LINKTIME( DriverRegHTCVive ); +typedef int (*DeviceDriver)( struct SurviveContext * ctx ); + +//more driver types here? i.e. posefinders, etc. + +#endif + |