Keys.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef KEYS_H
  2. #define KEYS_H
  3. #include <iostream>
  4. #include <array>
  5. #include "common/utils/Types.h"
  6. class Keys final {
  7. public:
  8. class Key final {
  9. public:
  10. friend class Keys;
  11. bool isDown() const;
  12. bool isReleased() const;
  13. uint getDownTime() const;
  14. private:
  15. Key();
  16. Key(const Key&) = delete;
  17. Key(Key&&) = delete;
  18. Key& operator=(const Key&) = delete;
  19. Key& operator=(Key&&) = delete;
  20. int glfwKey;
  21. bool down;
  22. bool shouldRelease;
  23. uint downTime;
  24. };
  25. private:
  26. Key keys[18];
  27. public:
  28. Keys();
  29. const Key& left;
  30. const Key& right;
  31. const Key& up;
  32. const Key& down;
  33. const Key& jump;
  34. const Key& sneak;
  35. const Key& camLeft;
  36. const Key& camRight;
  37. const Key& camUp;
  38. const Key& camDown;
  39. const Key& test;
  40. const Key& test2;
  41. const Key& test3;
  42. const Key& test4;
  43. const Key& test5;
  44. const Key& test6;
  45. const Key& factor;
  46. const Key& kdTree;
  47. void release(int key);
  48. void press(int key);
  49. void tick();
  50. private:
  51. Keys(const Keys&) = delete;
  52. Keys& operator=(const Keys&) = delete;
  53. Keys(Key&&) = delete;
  54. Keys& operator=(Keys&&) = delete;
  55. };
  56. std::ostream& operator<<(std::ostream& os, const Keys::Key& k);
  57. #endif