Nui Engine
A game engine framework
Loading...
Searching...
No Matches
KeyCode.h
1#pragma once
2#include "Core/Common/NuiWin.h"
3#include "Core/Common/Types.h"
4
5namespace Nui::Input
6{
7 enum class KeyCode : U64
8 {
9 None = 0,
10
11 LeftArrow = VK_LEFT,
12 RightArrow = VK_RIGHT,
13 UpArrow = VK_UP,
14 DownArrow = VK_DOWN,
15 PageUp = VK_PRIOR,
16 PageDown = VK_NEXT,
17 Home = VK_HOME,
18 End = VK_END,
19 Insert = VK_INSERT,
20 Delete = VK_DELETE,
21 Backspace = VK_BACK,
22 Space = VK_SPACE,
23 Enter = VK_RETURN,
24 Escape = VK_ESCAPE,
25 LeftCtrl = VK_LCONTROL,
26 LeftShift = VK_LSHIFT,
27 LeftAlt = VK_LMENU,
28 LeftSuper = VK_LWIN,
29 RightCtrl = VK_RCONTROL,
30 RightShift = VK_RSHIFT,
31 RightAlt = VK_RMENU,
32 RightSuper = VK_RWIN,
33 Menu = VK_APPS,
34
35 Num0 = '0',
36 Num1 = '1',
37 Num2 = '2',
38 Num3 = '3',
39 Num4 = '4',
40 Num5 = '5',
41 Num6 = '6',
42 Num7 = '7',
43 Num8 = '8',
44 Num9 = '9',
45
46 A = 'A',
47 B = 'B',
48 C = 'C',
49 D = 'D',
50 E = 'E',
51 F = 'F',
52 G = 'G',
53 H = 'H',
54 I = 'I',
55 J = 'J',
56 K = 'K',
57 L = 'L',
58 M = 'M',
59 N = 'N',
60 O = 'O',
61 P = 'P',
62 Q = 'Q',
63 R = 'R',
64 S = 'S',
65 T = 'T',
66 U = 'U',
67 V = 'V',
68 W = 'W',
69 X = 'X',
70 Y = 'Y',
71 Z = 'Z',
72
73 F1 = VK_F1,
74 F2 = VK_F2,
75 F3 = VK_F3,
76 F4 = VK_F4,
77 F5 = VK_F5,
78 F6 = VK_F6,
79 F7 = VK_F7,
80 F8 = VK_F8,
81 F9 = VK_F9,
82 F10 = VK_F10,
83 F11 = VK_F11,
84 F12 = VK_F12,
85 F13 = VK_F13,
86 F14 = VK_F14,
87 F15 = VK_F15,
88 F16 = VK_F16,
89 F17 = VK_F17,
90 F18 = VK_F18,
91 F19 = VK_F19,
92 F20 = VK_F20,
93 F21 = VK_F21,
94 F22 = VK_F22,
95 F23 = VK_F23,
96 F24 = VK_F24,
97
98 Apostrophe = VK_OEM_7,
99 Comma = VK_OEM_COMMA,
100 Minus = VK_OEM_MINUS,
101 Period = VK_OEM_PERIOD,
102 Slash = VK_OEM_2,
103 Semicolon = VK_OEM_1,
104 Equal = VK_OEM_PLUS,
105 LBracket = VK_OEM_4,
106 RBracket = VK_OEM_6,
107 Backslash = VK_OEM_5,
108 GraveAccent = VK_OEM_3,
109 CapsLock = VK_CAPITAL,
110 ScrollLock = VK_SCROLL,
111 NumLock = VK_NUMLOCK,
112 PrintScreen = VK_SNAPSHOT,
113
114 NumPad0 = VK_NUMPAD0,
115 NumPad1 = VK_NUMPAD1,
116 NumPad2 = VK_NUMPAD2,
117 NumPad3 = VK_NUMPAD3,
118 NumPad4 = VK_NUMPAD4,
119 NumPad5 = VK_NUMPAD5,
120 NumPad6 = VK_NUMPAD6,
121 NumPad7 = VK_NUMPAD7,
122 NumPad8 = VK_NUMPAD8,
123 NumPad9 = VK_NUMPAD9,
124 NumPadDecimal = VK_DECIMAL,
125 NumPadDivide = VK_DIVIDE,
126 NumPadMultiply = VK_MULTIPLY,
127 NumPadSubtract = VK_SUBTRACT,
128 NumPadAdd = VK_ADD,
129
130 KEYCODE_COUNT
131 };
132
133 enum Modifier : U64
134 {
135 MOD_None = 0,
136
137 MOD_LShift = 1 << 0,
138 MOD_RShift = 1 << 1,
139 MOD_LControl = 1 << 2,
140 MOD_RControl = 1 << 3,
141 MOD_LAlt = 1 << 4,
142 MOD_RAlt = 1 << 5,
143 MOD_LSuper = 1 << 6,
144 MOD_RSuper = 1 << 7,
145 };
146
147 inline constexpr U64 ConvertKeyCodeToArrayIndex(KeyCode keyCode)
148 {
149 switch (keyCode)
150 {
151 case KeyCode::LeftArrow: return 0;
152 case KeyCode::RightArrow: return 1;
153 case KeyCode::UpArrow: return 2;
154 case KeyCode::DownArrow: return 3;
155 case KeyCode::PageUp: return 4;
156 case KeyCode::PageDown: return 5;
157 case KeyCode::Home: return 6;
158 case KeyCode::End: return 7;
159 case KeyCode::Insert: return 8;
160 case KeyCode::Delete: return 9;
161 case KeyCode::Backspace: return 10;
162 case KeyCode::Space: return 11;
163 case KeyCode::Enter: return 12;
164 case KeyCode::Escape: return 13;
165 case KeyCode::LeftCtrl: return 14;
166 case KeyCode::LeftShift: return 15;
167 case KeyCode::LeftAlt: return 16;
168 case KeyCode::LeftSuper: return 17;
169 case KeyCode::RightCtrl: return 18;
170 case KeyCode::RightShift: return 19;
171 case KeyCode::RightAlt: return 20;
172 case KeyCode::RightSuper: return 21;
173 case KeyCode::Menu: return 22;
174 case KeyCode::Num0: return 23;
175 case KeyCode::Num1: return 24;
176 case KeyCode::Num2: return 25;
177 case KeyCode::Num3: return 26;
178 case KeyCode::Num4: return 27;
179 case KeyCode::Num5: return 28;
180 case KeyCode::Num6: return 29;
181 case KeyCode::Num7: return 30;
182 case KeyCode::Num8: return 31;
183 case KeyCode::Num9: return 32;
184 case KeyCode::A: return 33;
185 case KeyCode::B: return 34;
186 case KeyCode::C: return 35;
187 case KeyCode::D: return 36;
188 case KeyCode::E: return 37;
189 case KeyCode::F: return 38;
190 case KeyCode::G: return 39;
191 case KeyCode::H: return 40;
192 case KeyCode::I: return 41;
193 case KeyCode::J: return 42;
194 case KeyCode::K: return 43;
195 case KeyCode::L: return 44;
196 case KeyCode::M: return 45;
197 case KeyCode::N: return 46;
198 case KeyCode::O: return 47;
199 case KeyCode::P: return 48;
200 case KeyCode::Q: return 49;
201 case KeyCode::R: return 50;
202 case KeyCode::S: return 51;
203 case KeyCode::T: return 52;
204 case KeyCode::U: return 53;
205 case KeyCode::V: return 54;
206 case KeyCode::W: return 55;
207 case KeyCode::X: return 56;
208 case KeyCode::Y: return 57;
209 case KeyCode::Z: return 58;
210 case KeyCode::F1: return 59;
211 case KeyCode::F2: return 60;
212 case KeyCode::F3: return 61;
213 case KeyCode::F4: return 62;
214 case KeyCode::F5: return 63;
215 case KeyCode::F6: return 64;
216 case KeyCode::F7: return 65;
217 case KeyCode::F8: return 66;
218 case KeyCode::F9: return 67;
219 case KeyCode::F10: return 68;
220 case KeyCode::F11: return 69;
221 case KeyCode::F12: return 70;
222 case KeyCode::F13: return 71;
223 case KeyCode::F14: return 72;
224 case KeyCode::F15: return 73;
225 case KeyCode::F16: return 74;
226 case KeyCode::F17: return 75;
227 case KeyCode::F18: return 76;
228 case KeyCode::F19: return 77;
229 case KeyCode::F20: return 78;
230 case KeyCode::F21: return 79;
231 case KeyCode::F22: return 80;
232 case KeyCode::F23: return 81;
233 case KeyCode::F24: return 82;
234 case KeyCode::Apostrophe: return 83;
235 case KeyCode::Comma: return 84;
236 case KeyCode::Minus: return 85;
237 case KeyCode::Period: return 86;
238 case KeyCode::Slash: return 87;
239 case KeyCode::Semicolon: return 88;
240 case KeyCode::Equal: return 89;
241 case KeyCode::LBracket: return 90;
242 case KeyCode::RBracket: return 91;
243 case KeyCode::Backslash: return 92;
244 case KeyCode::GraveAccent: return 93;
245 case KeyCode::CapsLock: return 94;
246 case KeyCode::ScrollLock: return 95;
247 case KeyCode::NumLock: return 96;
248 case KeyCode::PrintScreen: return 97;
249 case KeyCode::NumPad0: return 98;
250 case KeyCode::NumPad1: return 99;
251 case KeyCode::NumPad2: return 100;
252 case KeyCode::NumPad3: return 101;
253 case KeyCode::NumPad4: return 102;
254 case KeyCode::NumPad5: return 103;
255 case KeyCode::NumPad6: return 104;
256 case KeyCode::NumPad7: return 105;
257 case KeyCode::NumPad8: return 106;
258 case KeyCode::NumPad9: return 107;
259 case KeyCode::NumPadDecimal: return 108;
260 case KeyCode::NumPadDivide: return 109;
261 case KeyCode::NumPadMultiply: return 110;
262 case KeyCode::NumPadSubtract: return 111;
263 case KeyCode::NumPadAdd: return 112;
264 case KeyCode::KEYCODE_COUNT: return 113;
265 }
266
267 // Return out of bounds index
268 return ConvertKeyCodeToArrayIndex(KeyCode::KEYCODE_COUNT) + 1;
269 }
270
271}