Keys.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #ifndef KEYS_H
  2. #define KEYS_H
  3. #include <iostream>
  4. #include <array>
  5. #include "common/utils/Types.h"
  6. #include "GameClient.h"
  7. class Keys
  8. {
  9. public:
  10. class Key
  11. {
  12. public:
  13. friend class Keys;
  14. bool isDown() const;
  15. bool isReleased() const;
  16. u32 getDownTime() const;
  17. private:
  18. Key() = default;
  19. Key(const Key&) = delete;
  20. Key(Key&&) = delete;
  21. Key& operator=(const Key&) = delete;
  22. Key& operator=(Key&&) = delete;
  23. int glfwKey;
  24. bool down;
  25. bool shouldRelease;
  26. u32 downTime;
  27. };
  28. private:
  29. Key keys[4];
  30. public:
  31. Keys();
  32. const Key& left;
  33. const Key& right;
  34. const Key& up;
  35. const Key& down;
  36. void release(int key);
  37. void press(int key);
  38. void tick();
  39. private:
  40. Keys(const Keys&) = delete;
  41. Keys& operator=(const Keys&) = delete;
  42. Keys(Key&&) = delete;
  43. Keys& operator=(Keys&&) = delete;
  44. };
  45. std::ostream& operator<<(std::ostream& os, const Keys::Key& m);
  46. #endif