MouseButtons.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef MOUSEBUTTONS_H
  2. #define MOUSEBUTTONS_H
  3. #include <iostream>
  4. #include <array>
  5. #include "common/utils/Types.h"
  6. class MouseButtons final {
  7. public:
  8. class MouseButton final {
  9. public:
  10. friend class MouseButtons;
  11. bool isDown() const;
  12. bool isReleased() const;
  13. u32 getDownTime() const;
  14. private:
  15. MouseButton();
  16. MouseButton(const MouseButton&) = delete;
  17. MouseButton(MouseButton&&) = delete;
  18. MouseButton& operator=(const MouseButton&) = delete;
  19. MouseButton& operator=(MouseButton&&) = delete;
  20. int glfwButton;
  21. bool down;
  22. bool shouldRelease;
  23. u32 downTime;
  24. };
  25. private:
  26. MouseButton buttons[3];
  27. public:
  28. MouseButtons();
  29. double getLastX() const;
  30. double getLastY() const;
  31. double getX() const;
  32. double getY() const;
  33. const MouseButton& primary;
  34. const MouseButton& secondary;
  35. const MouseButton& middle;
  36. void release(int button);
  37. void press(int button);
  38. void move(double x, double y);
  39. void tick();
  40. private:
  41. MouseButtons(const MouseButtons&) = delete;
  42. MouseButtons& operator=(const MouseButtons&) = delete;
  43. MouseButtons(MouseButtons&&) = delete;
  44. MouseButtons& operator=(MouseButtons&&) = delete;
  45. double lastX;
  46. double lastY;
  47. double x;
  48. double y;
  49. bool updateLast;
  50. };
  51. std::ostream& operator<<(std::ostream& os, const MouseButtons::MouseButton& m);
  52. #endif