KeyManager.h 681 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef KEY_H
  2. #define KEY_H
  3. #include <GLFW/glfw3.h>
  4. class KeyManager
  5. {
  6. public:
  7. KeyManager();
  8. bool isDown(int mapping);
  9. bool isReleased(int mapping);
  10. unsigned int getDownTime(int mapping);
  11. void resetDownTime(int mapping);
  12. bool map(int mapping, int key);
  13. void tick();
  14. void press(int key);
  15. void release(int key);
  16. private:
  17. static const int NUMBER_OF_KEYS = GLFW_KEY_LAST + 1;
  18. bool isInRange(int i);
  19. struct Key
  20. {
  21. bool down = false;
  22. bool shouldRelease = false;
  23. unsigned int downTime = 0;
  24. };
  25. Key keyArray[NUMBER_OF_KEYS];
  26. int mappingArray[NUMBER_OF_KEYS];
  27. };
  28. #endif