Brenta Engine 1.2
Loading...
Searching...
No Matches
key.hpp
1// SPDX-License-Identifier: MIT
2// Author: Giovanni Santini
3// Mail: giovanni.santini@proton.me
4// Github: @San7o
5
6#pragma once
7
8#include <bitset>
9
10namespace brenta
11{
12
13enum class Key : int
14{
15 None,
16 Unknown,
17
18 // Printable keys
19 Space,
20 Apostrophe,
21 Comma,
22 Minus,
23 Period,
24 Slash,
25 D0,
26 D1,
27 D2,
28 D3,
29 D4,
30 D5,
31 D6,
32 D7,
33 D8,
34 D9,
35 Semicolon,
36 Equal,
37 A,
38 B,
39 C,
40 D,
41 E,
42 F,
43 G,
44 H,
45 I,
46 J,
47 K,
48 L,
49 M,
50 N,
51 O,
52 P,
53 Q,
54 R,
55 S,
56 T,
57 U,
58 V,
59 W,
60 X,
61 Y,
62 Z,
63 LeftBracket,
64 Backslash,
65 RightBracket,
66 GraveAccent,
67 World1,
68 World2,
69
70 // Function keys
71 Escape,
72 Enter,
73 Tab,
74 Backspace,
75 Insert,
76 Delete,
77 Right,
78 Left,
79 Down,
80 Up,
81 PageUp,
82 PageDown,
83 Home,
84 End,
85 CapsLock,
86 ScrollLock,
87 NumLock,
88 PrintScreen,
89 Pause,
90 F1,
91 F2,
92 F3,
93 F4,
94 F5,
95 F6,
96 F7,
97 F8,
98 F9,
99 F10,
100 F11,
101 F12,
102 F13,
103 F14,
104 F15,
105 F16,
106 F17,
107 F18,
108 F19,
109 F20,
110 F21,
111 F22,
112 F23,
113 F24,
114 F25,
115
116 // Keypad
117 KP0,
118 KP1,
119 KP2,
120 KP3,
121 KP4,
122 KP5,
123 KP6,
124 KP7,
125 KP8,
126 KP9,
127 KPDecimal,
128 KPDivide,
129 KPMultiply,
130 KPSubtract,
131 KPAdd,
132 KPEnter,
133 KPEqual,
134
135 // Modifiers
136 LeftShift,
137 LeftControl,
138 LeftAlt,
139 LeftSuper,
140 RightShift,
141 RightControl,
142 RightAlt,
143 RightSuper,
144 Menu,
145
146 Last = Menu
147};
148
149enum class KeyAction
150{
151 Release,
152 Press,
153 Repeat,
154 Unknown,
155};
156
158{
159public:
160
161 enum class Mod : std::size_t
162 {
163 Shift,
164 Control,
165 Alt,
166 Super,
167 CapsLock,
168 NumLock,
169 };
170
171 KeyMods() = default;
172
173 inline bool shift() const
174 { return this->mods.test((std::size_t) Mod::Shift); }
175 inline bool control() const
176 { return this->mods.test((std::size_t) Mod::Control); }
177 inline bool alt() const
178 { return this->mods.test((std::size_t) Mod::Alt); }
179 inline bool super() const
180 { return this->mods.test((std::size_t) Mod::Super); }
181 inline bool caps_lock() const
182 { return this->mods.test((std::size_t) Mod::CapsLock); }
183 inline bool num_lock() const
184 { return this->mods.test((std::size_t) Mod::NumLock); }
185
186 inline KeyMods &set_shift()
187 { this->mods.set((std::size_t) Mod::Shift); return *this; }
188 inline KeyMods &set_control()
189 { this->mods.set((std::size_t) Mod::Control); return *this; }
190 inline KeyMods &set_alt()
191 { this->mods.set((std::size_t) Mod::Alt); return *this; }
192 inline KeyMods &set_super()
193 { this->mods.set((std::size_t) Mod::Super); return *this; }
194 inline KeyMods &set_caps_lock()
195 { this->mods.set((std::size_t) Mod::CapsLock); return *this; }
196 inline KeyMods &set_num_lock()
197 { this->mods.set((std::size_t) Mod::NumLock); return *this; }
198
199private:
200
201 std::bitset<8> mods;
202};
203
204} // namespace brenta