diff options
author | ultramn <dchapm2@umbc.edu> | 2017-03-02 19:55:54 -0800 |
---|---|---|
committer | ultramn <dchapm2@umbc.edu> | 2017-03-02 19:55:54 -0800 |
commit | a59f42935a7472da7b9f162a68b3c55aff128f7e (patch) | |
tree | e4bf6314161bbabbde6064d8b7fdb9335a764ca6 /src/survive_driverman.h | |
parent | 1c131c03fe8c5d5ab17193c9f6e7e79d81110d52 (diff) | |
parent | 9d1b1d09ed51344c8ca7b4f0a94f5841ee2c509e (diff) | |
download | libsurvive-a59f42935a7472da7b9f162a68b3c55aff128f7e.tar.gz libsurvive-a59f42935a7472da7b9f162a68b3c55aff128f7e.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 + |