Keys.h 1.2 KB

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