MOS
mouse.hpp
1 #pragma once
2 
3 #include <glm/glm.hpp>
4 #include <unordered_set>
5 #include <array>
6 
7 namespace mos::io {
8 
9 class [[deprecated("Use glfw or similar directly")]] Mouse {
10 public:
11  Mouse();
12  enum class Button : int {
13  Button_1 = 0,
14  Button_2 = 1,
15  Button_3 = 2,
16  Button_4 = 3,
17  Button_5 = 4,
18  Button_6 = 5,
19  Button_7 = 6,
20  Button_8 = 7
21  };
22 
23  enum class Action : int {
24  Release = 0,
25  Press = 1,
26  Repeat = 2
27  };
28 
29  struct Event {
30  Button button;
31  Action action;
32 
33  bool operator==(const Event &event) const{
34  return button == event.button && action == event.action;
35  }
36 
37  };
38 
39 private:
40  struct EventHash {
41  size_t operator()(const Event& e) const {
42  return ((std::hash<int>()(static_cast<int>(e.button)) ^ (std::hash<int>()(static_cast<int>(e.action)) << 1)) >> 1);
43  }
44  };
45 public:
46  using Events = std::unordered_set<Event, EventHash>;
47 
48  glm::dvec2 position{};
49  glm::dvec2 old_position{};
50  Events events;
51  std::array<bool, 3> buttons{false, false, false};
52 };
53 }
54 
55 
Definition: gamepad.hpp:5