MOS
keyboard.hpp
1 #pragma once
2 
3 #include <unordered_set>
4 #include <vector>
5 
6 namespace mos::io {
7 
8 class [[deprecated("Use glfw or similar directly")]] Keyboard {
9 public:
10  Keyboard() = default;
11 
12  enum class Key : int {
13  Enter = 257,
14  Escape = 256,
15  Backspace = 259,
16  F1 = 290,
17  F2 = 291,
18  F3 = 292,
19  F4 = 293,
20  F5 = 294,
21  F6 = 295,
22  F7 = 296,
23  F8 = 297,
24  F9 = 298,
25  F10 = 299,
26  F11 = 300,
27  F12 = 301
28  };
29 
30  enum class Action : int {
31  Release = 0,
32  Press = 1,
33  Repeat = 2
34  };
35 
36  struct Event {
37  Key key;
38  Action action;
39 
40  bool operator==(const Event &event) const{
41  return key == event.key && action == event.action;
42  }
43  };
44 
45 private:
46  struct EventHash {
47  size_t operator()(const Event& e) const {
48  return ((std::hash<int>()(static_cast<int>(e.key)) ^ (std::hash<int>()(static_cast<int>(e.action)) << 1)) >> 1);
49  }
50  };
51 public:
52  using Events = std::unordered_set<Event, EventHash>;
53  using Codepoints = std::vector<unsigned int>;
54  Events events;
55  Codepoints codepoints;
56 };
57 }
Definition: gamepad.hpp:5