1 #ifndef EVENTS_H 2 #define EVENTS_H 3 4 #include <SDL/SDL.h> 5 #include <string> 6 #include <iostream> 7 #include <sstream> 8 #include <vector> 9 #include "timer.h" 10 #include "commands.h" 11 #include "execcmd.h" 12 13 using namespace std; 14 15 struct sharedTimer 16 { 17 bool active; 18 unsigned int responsetime; 19 unsigned int elapsed; 20 }; 21 22 struct event 23 { 24 string name; 25 bool active; 26 bool bindbystring; 27 long unsigned int bindkey; 28 string bindstring; 29 30 cmdsettings command; 31 32 // private timer 33 unsigned int responsetime; 34 int fresponsetime; 35 unsigned int minfresponsetime; 36 unsigned int fresponseinterval; // degredation interval 37 unsigned int elapsed; 38 39 // shared timer 40 bool timerisshared; 41 sharedTimer* stimer; 42 }; 43 44 class Events 45 { 46 public: 47 static Events* Instance(); 48 ~Events(); 49 50 void registerEvent(SDLKey key, const string& name, const cmdsettings& cmd, sharedTimer* stimer); 51 void registerEvent(SDLKey key, const string& name, const cmdsettings& cmd, unsigned int responsetime, unsigned int minfresponsetime, unsigned int fresponseinterval); 52 void registerEvent(const string& name, const cmdsettings& cmd, unsigned int responsetime, unsigned int minfresponsetime, unsigned int fresponseinterval); 53 54 void activateEvent(const long unsigned int key); 55 void activateEvent(const string& key); 56 void deactivateEvent(const long unsigned int key); 57 void deactivateEvent(const string& key); 58 59 sharedTimer* registerSharedtimer(unsigned int responsetime); 60 void processSharedTimers(); 61 void handlecommands(); 62 protected: 63 Events(); 64 private: 65 static Events* _instance; 66 Commands* cmd; 67 68 vector<event> events; 69 vector<sharedTimer> sharedtimers; 70 }; 71 72 #endif 73