Keys.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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[15];
  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. void release(int key);
  45. void press(int key);
  46. void tick();
  47. private:
  48. Keys(const Keys&) = delete;
  49. Keys& operator=(const Keys&) = delete;
  50. Keys(Key&&) = delete;
  51. Keys& operator=(Keys&&) = delete;
  52. };
  53. std::ostream& operator<<(std::ostream& os, const Keys::Key& k);
  54. #endif