Key.h 741 B

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