123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #ifndef MOUSEBUTTONS_H
- #define MOUSEBUTTONS_H
- #include <iostream>
- #include <array>
- #include "common/utils/Types.h"
- class MouseButtons final {
- public:
- class MouseButton final {
- public:
- friend class MouseButtons;
- bool isDown() const;
- bool isReleased() const;
- u32 getDownTime() const;
- private:
- MouseButton();
- MouseButton(const MouseButton&) = delete;
- MouseButton(MouseButton&&) = delete;
- MouseButton& operator=(const MouseButton&) = delete;
- MouseButton& operator=(MouseButton&&) = delete;
- int glfwButton;
- bool down;
- bool shouldRelease;
- u32 downTime;
- };
- private:
- MouseButton buttons[3];
- public:
- MouseButtons();
- double getLastX() const;
- double getLastY() const;
- double getX() const;
- double getY() const;
- const MouseButton& primary;
- const MouseButton& secondary;
- const MouseButton& middle;
- void release(int button);
- void press(int button);
- void move(double x, double y);
- void tick();
- private:
- MouseButtons(const MouseButtons&) = delete;
- MouseButtons& operator=(const MouseButtons&) = delete;
- MouseButtons(MouseButtons&&) = delete;
- MouseButtons& operator=(MouseButtons&&) = delete;
- double lastX;
- double lastY;
- double x;
- double y;
- bool updateLast;
- };
- std::ostream& operator<<(std::ostream& os, const MouseButtons::MouseButton& m);
- #endif
|