1 /*
2     DSDL
3     Copyright (C) 2025 Inochi2D Project <luna@foxgirls.gay>
4 
5     This software is provided 'as-is', without any express or implied
6     warranty.  In no event will the authors be held liable for any damages
7     arising from the use of this software.
8 
9     Permission is granted to anyone to use this software for any purpose,
10     including commercial applications, and to alter it and redistribute it
11     freely, subject to the following restrictions:
12 
13     1. The origin of this software must not be misrepresented; you must not
14         claim that you wrote the original software. If you use this software
15         in a product, an acknowledgment in the product documentation would be
16         appreciated but is not required.
17     2. Altered source versions must be plainly marked as such, and must not be
18         misrepresented as being the original software.
19     3. This notice may not be removed or altered from any source distribution.
20 
21     ==========================================================================
22 
23     Simple DirectMedia Layer
24     Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
25 
26     This software is provided 'as-is', without any express or implied
27     warranty.  In no event will the authors be held liable for any damages
28     arising from the use of this software.
29 
30     Permission is granted to anyone to use this software for any purpose,
31     including commercial applications, and to alter it and redistribute it
32     freely, subject to the following restrictions:
33 
34     1. The origin of this software must not be misrepresented; you must not
35         claim that you wrote the original software. If you use this software
36         in a product, an acknowledgment in the product documentation would be
37         appreciated but is not required.
38     2. Altered source versions must be plainly marked as such, and must not be
39         misrepresented as being the original software.
40     3. This notice may not be removed or altered from any source distribution.
41 */
42 
43 /**
44     SDL Keycodes
45 
46     See_Also:
47         $(LINK2 https://wiki.libsdl.org/SDL3/CategoryKeycode, SDL3 Keycode Documentation)
48     
49     Copyright: © 2025 Inochi2D Project, © 1997-2025 Sam Lantinga
50     License: Subject to the terms of the Zlib License, as written in the LICENSE file.
51     Authors: 
52         Luna Nielsen
53 */
54 module sdl.keycode;
55 import sdl.stdc;
56 import sdl.scancode;
57 
58 extern(C) nothrow @nogc:
59 
60 enum Uint32 SDLK_EXTENDED_MASK = (1u << 29);
61 enum Uint32 SDLK_SCANCODE_MASK = (1u << 30);
62 enum Uint32 SDL_SCANCODE_TO_KEYCODE(X) = (X | SDLK_SCANCODE_MASK);
63 
64 /**
65     The SDL virtual key representation.
66 
67     Values of this type are used to represent keyboard keys using the current
68     layout of the keyboard. These values include Unicode values representing
69     the unmodified character that would be generated by pressing the key, or an
70     `SDLK_*` constant for those keys that do not generate characters.
71 
72     A special exception is the number keys at the top of the keyboard which map
73     to SDLK_0...SDLK_9 on AZERTY layouts.
74 
75     Keys with the `SDLK_EXTENDED_MASK` bit set do not map to a scancode or
76     unicode code point.
77 */
78 enum SDL_Keycode : Uint32 {
79     SDLK_UNKNOWN =                0x00000000u,
80     SDLK_RETURN =                 0x0000000du,
81     SDLK_ESCAPE =                 0x0000001bu,
82     SDLK_BACKSPACE =              0x00000008u,
83     SDLK_TAB =                    0x00000009u,
84     SDLK_SPACE =                  0x00000020u,
85     SDLK_EXCLAIM =                0x00000021u,
86     SDLK_DBLAPOSTROPHE =          0x00000022u,
87     SDLK_HASH =                   0x00000023u,
88     SDLK_DOLLAR =                 0x00000024u,
89     SDLK_PERCENT =                0x00000025u,
90     SDLK_AMPERSAND =              0x00000026u,
91     SDLK_APOSTROPHE =             0x00000027u,
92     SDLK_LEFTPAREN =              0x00000028u,
93     SDLK_RIGHTPAREN =             0x00000029u,
94     SDLK_ASTERISK =               0x0000002au,
95     SDLK_PLUS =                   0x0000002bu,
96     SDLK_COMMA =                  0x0000002cu,
97     SDLK_MINUS =                  0x0000002du,
98     SDLK_PERIOD =                 0x0000002eu,
99     SDLK_SLASH =                  0x0000002fu,
100     SDLK_0 =                      0x00000030u,
101     SDLK_1 =                      0x00000031u,
102     SDLK_2 =                      0x00000032u,
103     SDLK_3 =                      0x00000033u,
104     SDLK_4 =                      0x00000034u,
105     SDLK_5 =                      0x00000035u,
106     SDLK_6 =                      0x00000036u,
107     SDLK_7 =                      0x00000037u,
108     SDLK_8 =                      0x00000038u,
109     SDLK_9 =                      0x00000039u,
110     SDLK_COLON =                  0x0000003au,
111     SDLK_SEMICOLON =              0x0000003bu,
112     SDLK_LESS =                   0x0000003cu,
113     SDLK_EQUALS =                 0x0000003du,
114     SDLK_GREATER =                0x0000003eu,
115     SDLK_QUESTION =               0x0000003fu,
116     SDLK_AT =                     0x00000040u,
117     SDLK_LEFTBRACKET =            0x0000005bu,
118     SDLK_BACKSLASH =              0x0000005cu,
119     SDLK_RIGHTBRACKET =           0x0000005du,
120     SDLK_CARET =                  0x0000005eu,
121     SDLK_UNDERSCORE =             0x0000005fu,
122     SDLK_GRAVE =                  0x00000060u,
123     SDLK_A =                      0x00000061u,
124     SDLK_B =                      0x00000062u,
125     SDLK_C =                      0x00000063u,
126     SDLK_D =                      0x00000064u,
127     SDLK_E =                      0x00000065u,
128     SDLK_F =                      0x00000066u,
129     SDLK_G =                      0x00000067u,
130     SDLK_H =                      0x00000068u,
131     SDLK_I =                      0x00000069u,
132     SDLK_J =                      0x0000006au,
133     SDLK_K =                      0x0000006bu,
134     SDLK_L =                      0x0000006cu,
135     SDLK_M =                      0x0000006du,
136     SDLK_N =                      0x0000006eu,
137     SDLK_O =                      0x0000006fu,
138     SDLK_P =                      0x00000070u,
139     SDLK_Q =                      0x00000071u,
140     SDLK_R =                      0x00000072u,
141     SDLK_S =                      0x00000073u,
142     SDLK_T =                      0x00000074u,
143     SDLK_U =                      0x00000075u,
144     SDLK_V =                      0x00000076u,
145     SDLK_W =                      0x00000077u,
146     SDLK_X =                      0x00000078u,
147     SDLK_Y =                      0x00000079u,
148     SDLK_Z =                      0x0000007au,
149     SDLK_LEFTBRACE =              0x0000007bu,
150     SDLK_PIPE =                   0x0000007cu,
151     SDLK_RIGHTBRACE =             0x0000007du,
152     SDLK_TILDE =                  0x0000007eu,
153     SDLK_DELETE =                 0x0000007fu,
154     SDLK_PLUSMINUS =              0x000000b1u,
155     SDLK_CAPSLOCK =               0x40000039u,
156     SDLK_F1 =                     0x4000003au,
157     SDLK_F2 =                     0x4000003bu,
158     SDLK_F3 =                     0x4000003cu,
159     SDLK_F4 =                     0x4000003du,
160     SDLK_F5 =                     0x4000003eu,
161     SDLK_F6 =                     0x4000003fu,
162     SDLK_F7 =                     0x40000040u,
163     SDLK_F8 =                     0x40000041u,
164     SDLK_F9 =                     0x40000042u,
165     SDLK_F10 =                    0x40000043u,
166     SDLK_F11 =                    0x40000044u,
167     SDLK_F12 =                    0x40000045u,
168     SDLK_PRINTSCREEN =            0x40000046u,
169     SDLK_SCROLLLOCK =             0x40000047u,
170     SDLK_PAUSE =                  0x40000048u,
171     SDLK_INSERT =                 0x40000049u,
172     SDLK_HOME =                   0x4000004au,
173     SDLK_PAGEUP =                 0x4000004bu,
174     SDLK_END =                    0x4000004du,
175     SDLK_PAGEDOWN =               0x4000004eu,
176     SDLK_RIGHT =                  0x4000004fu,
177     SDLK_LEFT =                   0x40000050u,
178     SDLK_DOWN =                   0x40000051u,
179     SDLK_UP =                     0x40000052u,
180     SDLK_NUMLOCKCLEAR =           0x40000053u,
181     SDLK_KP_DIVIDE =              0x40000054u,
182     SDLK_KP_MULTIPLY =            0x40000055u,
183     SDLK_KP_MINUS =               0x40000056u,
184     SDLK_KP_PLUS =                0x40000057u,
185     SDLK_KP_ENTER =               0x40000058u,
186     SDLK_KP_1 =                   0x40000059u,
187     SDLK_KP_2 =                   0x4000005au,
188     SDLK_KP_3 =                   0x4000005bu,
189     SDLK_KP_4 =                   0x4000005cu,
190     SDLK_KP_5 =                   0x4000005du,
191     SDLK_KP_6 =                   0x4000005eu,
192     SDLK_KP_7 =                   0x4000005fu,
193     SDLK_KP_8 =                   0x40000060u,
194     SDLK_KP_9 =                   0x40000061u,
195     SDLK_KP_0 =                   0x40000062u,
196     SDLK_KP_PERIOD =              0x40000063u,
197     SDLK_APPLICATION =            0x40000065u,
198     SDLK_POWER =                  0x40000066u,
199     SDLK_KP_EQUALS =              0x40000067u,
200     SDLK_F13 =                    0x40000068u,
201     SDLK_F14 =                    0x40000069u,
202     SDLK_F15 =                    0x4000006au,
203     SDLK_F16 =                    0x4000006bu,
204     SDLK_F17 =                    0x4000006cu,
205     SDLK_F18 =                    0x4000006du,
206     SDLK_F19 =                    0x4000006eu,
207     SDLK_F20 =                    0x4000006fu,
208     SDLK_F21 =                    0x40000070u,
209     SDLK_F22 =                    0x40000071u,
210     SDLK_F23 =                    0x40000072u,
211     SDLK_F24 =                    0x40000073u,
212     SDLK_EXECUTE =                0x40000074u,
213     SDLK_HELP =                   0x40000075u,
214     SDLK_MENU =                   0x40000076u,
215     SDLK_SELECT =                 0x40000077u,
216     SDLK_STOP =                   0x40000078u,
217     SDLK_AGAIN =                  0x40000079u,
218     SDLK_UNDO =                   0x4000007au,
219     SDLK_CUT =                    0x4000007bu,
220     SDLK_COPY =                   0x4000007cu,
221     SDLK_PASTE =                  0x4000007du,
222     SDLK_FIND =                   0x4000007eu,
223     SDLK_MUTE =                   0x4000007fu,
224     SDLK_VOLUMEUP =               0x40000080u,
225     SDLK_VOLUMEDOWN =             0x40000081u,
226     SDLK_KP_COMMA =               0x40000085u,
227     SDLK_KP_EQUALSAS400 =         0x40000086u,
228     SDLK_ALTERASE =               0x40000099u,
229     SDLK_SYSREQ =                 0x4000009au,
230     SDLK_CANCEL =                 0x4000009bu,
231     SDLK_CLEAR =                  0x4000009cu,
232     SDLK_PRIOR =                  0x4000009du,
233     SDLK_RETURN2 =                0x4000009eu,
234     SDLK_SEPARATOR =              0x4000009fu,
235     SDLK_OUT =                    0x400000a0u,
236     SDLK_OPER =                   0x400000a1u,
237     SDLK_CLEARAGAIN =             0x400000a2u,
238     SDLK_CRSEL =                  0x400000a3u,
239     SDLK_EXSEL =                  0x400000a4u,
240     SDLK_KP_00 =                  0x400000b0u,
241     SDLK_KP_000 =                 0x400000b1u,
242     SDLK_THOUSANDSSEPARATOR =     0x400000b2u,
243     SDLK_DECIMALSEPARATOR =       0x400000b3u,
244     SDLK_CURRENCYUNIT =           0x400000b4u,
245     SDLK_CURRENCYSUBUNIT =        0x400000b5u,
246     SDLK_KP_LEFTPAREN =           0x400000b6u,
247     SDLK_KP_RIGHTPAREN =          0x400000b7u,
248     SDLK_KP_LEFTBRACE =           0x400000b8u,
249     SDLK_KP_RIGHTBRACE =          0x400000b9u,
250     SDLK_KP_TAB =                 0x400000bau,
251     SDLK_KP_BACKSPACE =           0x400000bbu,
252     SDLK_KP_A =                   0x400000bcu,
253     SDLK_KP_B =                   0x400000bdu,
254     SDLK_KP_C =                   0x400000beu,
255     SDLK_KP_D =                   0x400000bfu,
256     SDLK_KP_E =                   0x400000c0u,
257     SDLK_KP_F =                   0x400000c1u,
258     SDLK_KP_XOR =                 0x400000c2u,
259     SDLK_KP_POWER =               0x400000c3u,
260     SDLK_KP_PERCENT =             0x400000c4u,
261     SDLK_KP_LESS =                0x400000c5u,
262     SDLK_KP_GREATER =             0x400000c6u,
263     SDLK_KP_AMPERSAND =           0x400000c7u,
264     SDLK_KP_DBLAMPERSAND =        0x400000c8u,
265     SDLK_KP_VERTICALBAR =         0x400000c9u,
266     SDLK_KP_DBLVERTICALBAR =      0x400000cau,
267     SDLK_KP_COLON =               0x400000cbu,
268     SDLK_KP_HASH =                0x400000ccu,
269     SDLK_KP_SPACE =               0x400000cdu,
270     SDLK_KP_AT =                  0x400000ceu,
271     SDLK_KP_EXCLAM =              0x400000cfu,
272     SDLK_KP_MEMSTORE =            0x400000d0u,
273     SDLK_KP_MEMRECALL =           0x400000d1u,
274     SDLK_KP_MEMCLEAR =            0x400000d2u,
275     SDLK_KP_MEMADD =              0x400000d3u,
276     SDLK_KP_MEMSUBTRACT =         0x400000d4u,
277     SDLK_KP_MEMMULTIPLY =         0x400000d5u,
278     SDLK_KP_MEMDIVIDE =           0x400000d6u,
279     SDLK_KP_PLUSMINUS =           0x400000d7u,
280     SDLK_KP_CLEAR =               0x400000d8u,
281     SDLK_KP_CLEARENTRY =          0x400000d9u,
282     SDLK_KP_BINARY =              0x400000dau,
283     SDLK_KP_OCTAL =               0x400000dbu,
284     SDLK_KP_DECIMAL =             0x400000dcu,
285     SDLK_KP_HEXADECIMAL =         0x400000ddu,
286     SDLK_LCTRL =                  0x400000e0u,
287     SDLK_LSHIFT =                 0x400000e1u,
288     SDLK_LALT =                   0x400000e2u,
289     SDLK_LGUI =                   0x400000e3u,
290     SDLK_RCTRL =                  0x400000e4u,
291     SDLK_RSHIFT =                 0x400000e5u,
292     SDLK_RALT =                   0x400000e6u,
293     SDLK_RGUI =                   0x400000e7u,
294     SDLK_MODE =                   0x40000101u,
295     SDLK_SLEEP =                  0x40000102u,
296     SDLK_WAKE =                   0x40000103u,
297     SDLK_CHANNEL_INCREMENT =      0x40000104u,
298     SDLK_CHANNEL_DECREMENT =      0x40000105u,
299     SDLK_MEDIA_PLAY =             0x40000106u,
300     SDLK_MEDIA_PAUSE =            0x40000107u,
301     SDLK_MEDIA_RECORD =           0x40000108u,
302     SDLK_MEDIA_FAST_FORWARD =     0x40000109u,
303     SDLK_MEDIA_REWIND =           0x4000010au,
304     SDLK_MEDIA_NEXT_TRACK =       0x4000010bu,
305     SDLK_MEDIA_PREVIOUS_TRACK =   0x4000010cu,
306     SDLK_MEDIA_STOP =             0x4000010du,
307     SDLK_MEDIA_EJECT =            0x4000010eu,
308     SDLK_MEDIA_PLAY_PAUSE =       0x4000010fu,
309     SDLK_MEDIA_SELECT =           0x40000110u,
310     SDLK_AC_NEW =                 0x40000111u,
311     SDLK_AC_OPEN =                0x40000112u,
312     SDLK_AC_CLOSE =               0x40000113u,
313     SDLK_AC_EXIT =                0x40000114u,
314     SDLK_AC_SAVE =                0x40000115u,
315     SDLK_AC_PRINT =               0x40000116u,
316     SDLK_AC_PROPERTIES =          0x40000117u,
317     SDLK_AC_SEARCH =              0x40000118u,
318     SDLK_AC_HOME =                0x40000119u,
319     SDLK_AC_BACK =                0x4000011au,
320     SDLK_AC_FORWARD =             0x4000011bu,
321     SDLK_AC_STOP =                0x4000011cu,
322     SDLK_AC_REFRESH =             0x4000011du,
323     SDLK_AC_BOOKMARKS =           0x4000011eu,
324     SDLK_SOFTLEFT =               0x4000011fu,
325     SDLK_SOFTRIGHT =              0x40000120u,
326     SDLK_CALL =                   0x40000121u,
327     SDLK_ENDCALL =                0x40000122u,
328     SDLK_LEFT_TAB =               0x20000001u,
329     SDLK_LEVEL5_SHIFT =           0x20000002u,
330     SDLK_MULTI_KEY_COMPOSE =      0x20000003u,
331     SDLK_LMETA =                  0x20000004u,
332     SDLK_RMETA =                  0x20000005u,
333     SDLK_LHYPER =                 0x20000006u,
334     SDLK_RHYPER =                 0x20000007u,
335 }
336 
337 /**
338     Valid key modifiers (possibly OR'd together).
339 */
340 enum SDL_Keymod : Uint16 {
341 
342     KMOD_NONE =   0x0000u, /**< no modifier is applicable. */
343     KMOD_LSHIFT = 0x0001u, /**< the left Shift key is down. */
344     KMOD_RSHIFT = 0x0002u, /**< the right Shift key is down. */
345     KMOD_LEVEL5 = 0x0004u, /**< the Level 5 Shift key is down. */
346     KMOD_LCTRL =  0x0040u, /**< the left Ctrl (Control) key is down. */
347     KMOD_RCTRL =  0x0080u, /**< the right Ctrl (Control) key is down. */
348     KMOD_LALT =   0x0100u, /**< the left Alt key is down. */
349     KMOD_RALT =   0x0200u, /**< the right Alt key is down. */
350     KMOD_LGUI =   0x0400u, /**< the left GUI key (often the Windows key) is down. */
351     KMOD_RGUI =   0x0800u, /**< the right GUI key (often the Windows key) is down. */
352     KMOD_NUM =    0x1000u, /**< the Num Lock key (may be located on an extended keypad) is down. */
353     KMOD_CAPS =   0x2000u, /**< the Caps Lock key is down. */
354     KMOD_MODE =   0x4000u, /**< the !AltGr key is down. */
355     KMOD_SCROLL = 0x8000u, /**< the Scroll Lock key is down. */
356     KMOD_CTRL =   (KMOD_LCTRL | KMOD_RCTRL),   /**< Any Ctrl key is down. */
357     KMOD_SHIFT =  (KMOD_LSHIFT | KMOD_RSHIFT), /**< Any Shift key is down. */
358     KMOD_ALT =    (KMOD_LALT | KMOD_RALT),     /**< Any Alt key is down. */
359     KMOD_GUI =    (KMOD_LGUI | KMOD_RGUI),     /**< Any GUI key is down. */
360 }