Keys.h 498 B

12345678910111213141516171819202122232425262728293031
  1. #ifndef KEYS_H
  2. #define KEYS_H
  3. #include <array>
  4. #include "utils/Types.h"
  5. struct Keys final {
  6. int add(int glfwKey);
  7. bool isDown(uint key) const;
  8. uint getDownTime(uint key) const;
  9. void release(int glfwKey);
  10. void press(int glfwKey);
  11. void tick();
  12. private:
  13. uint searchKey(int glfwKey) const;
  14. uint getIndex(uint key) const;
  15. struct Key {
  16. Key();
  17. int glfwKey;
  18. bool down;
  19. uint downTime;
  20. };
  21. std::array<Key, 20> keys;
  22. };
  23. #endif