1234567891011121314151617181920212223242526272829303132333435363738 |
- #ifndef KEY_H
- #define KEY_H
- #include <GLFW/glfw3.h>
- class KeyManager
- {
- public:
- KeyManager();
-
- bool isDown(int mapping);
- bool isReleased(int mapping);
- unsigned int getDownTime(int mapping);
- void resetDownTime(int mapping);
- bool map(int mapping, int key);
-
- void tick();
- void press(int key);
- void release(int key);
-
- private:
- static const int NUMBER_OF_KEYS = GLFW_KEY_LAST + 1;
-
- bool isInRange(int i);
-
- struct Key
- {
- bool down = false;
- bool shouldRelease = false;
- unsigned int downTime = 0;
- };
-
- Key keyArray[NUMBER_OF_KEYS];
- int mappingArray[NUMBER_OF_KEYS];
- };
- #endif
|