1 /**
2 * Defines the Keyboard input device.
3 */
4 module dash.utility.input.keyboard;
5 import dash.utility.input.inputsystem;
6 
7 import gfm.sdl2;
8 
9 version( DashUseSDL2 )
10     /// Defines the Mouse input device.
11     alias Keyboard = InputSystem!( KeyboardButtonsSDL, void );
12 else
13     /// Defines the Mouse input device.
14     alias Keyboard = InputSystem!( KeyboardButtonsWin, void );
15 
16 package:
17 /**
18  * Virtual key codes.
19  *
20  * From: http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
21  */
22 enum KeyboardButtonsWin: uint
23 {
24     Cancel      = 0x03, /// Control-break
25     //Unused    = 0x07,
26     Backspace   = 0x08, /// Backspace key
27     Tab         = 0x09, /// Tab key
28     //Reserved  = 0x0A-0x0B,
29     Clear       = 0x0C, /// Clear key
30     Return      = 0x0D, /// Enter key
31     //Undefined = 0x0E-0x0F
32     Shift       = 0x10, /// Shift key
33     Control     = 0x11, /// Control key
34     Alt         = 0x12, /// Menu/alt key
35     Pause       = 0x13, /// Pause key
36     CapsLock    = 0x14, /// Capital/Caps Lock key
37     //Who Cares = 0x15-0x1A,
38     Escape      = 0x1B, /// Escape key
39     //Who Cares = 0x1C-0x1F
40     Space       = 0x20, /// Space bar
41     PageUp      = 0x21, /// Page Up/Prior key
42     PageDown    = 0x22, /// Page Down/Next key
43     End         = 0x23, /// End key
44     Home        = 0x24, /// Home key
45     Left        = 0x25, /// Left arrow key
46     Up          = 0x26, /// Up arrow key
47     Right       = 0x27, /// Right arrow key
48     Down        = 0x28, /// Down arrow key
49     Select      = 0x29, /// Select key
50     Print       = 0x2A, /// Print key
51     Execute     = 0x2B, /// Execute key
52     PrintScreen = 0x2C, /// Print Screen/Snapshot key
53     Insert      = 0x2D, /// Insert key
54     Delete      = 0x2E, /// Delete key
55     Help        = 0x2F, /// Help key
56     Keyboard0   = 0x30, /// 0 key
57     Keyboard1   = 0x31, /// 1 key
58     Keyboard2   = 0x32, /// 2 key
59     Keyboard3   = 0x33, /// 3 key
60     Keyboard4   = 0x34, /// 4 key
61     Keyboard5   = 0x35, /// 5 key
62     Keyboard6   = 0x36, /// 6 key
63     Keyboard7   = 0x37, /// 7 key
64     Keyboard8   = 0x38, /// 8 key
65     Keyboard9   = 0x39, /// 9 key
66     //Unused    = 0x3A-0x40
67     A           = 0x41, /// A key
68     B           = 0x42, /// B key
69     C           = 0x43, /// C key
70     D           = 0x44, /// D key
71     E           = 0x45, /// E key
72     F           = 0x46, /// F key
73     G           = 0x47, /// G key
74     H           = 0x48, /// H key
75     I           = 0x49, /// I key
76     J           = 0x4A, /// J key
77     K           = 0x4B, /// K key
78     L           = 0x4C, /// L key
79     M           = 0x4D, /// M key
80     N           = 0x4E, /// N key
81     O           = 0x4F, /// O key
82     P           = 0x50, /// P key
83     Q           = 0x51, /// Q key
84     R           = 0x52, /// R key
85     S           = 0x53, /// S key
86     T           = 0x54, /// T key
87     U           = 0x55, /// U key
88     V           = 0x56, /// V key
89     W           = 0x57, /// W key
90     X           = 0x58, /// X key
91     Y           = 0x59, /// Y key
92     Z           = 0x5A, /// Z key
93     WindowsLeft = 0x5B, /// Left windows key
94     WindowsRight= 0x5C, /// Right windows key
95     Apps        = 0x5D, /// Applications key
96     //Reserved  = 0x5E
97     Sleep       = 0x5F, /// Sleep key
98     Numpad0     = 0x60, /// 0 key
99     Numpad1     = 0x61, /// 1 key
100     Numpad2     = 0x62, /// 2 key
101     Numpad3     = 0x63, /// 3 key
102     Numpad4     = 0x64, /// 4 key
103     Numpad5     = 0x65, /// 5 key
104     Numpad6     = 0x66, /// 6 key
105     Numpad7     = 0x67, /// 7 key
106     Numpad8     = 0x68, /// 8 key
107     Numpad9     = 0x69, /// 9 key
108     Multiply    = 0x6A, /// Multiply key
109     Add         = 0x6B, /// Addition key
110     Separator   = 0x6C, /// Seperator key
111     Subtract    = 0x6D, /// Subtraction key
112     Decimal     = 0x6E, /// Decimal key
113     Divide      = 0x6F, /// Division key
114     F1          = 0x70, /// Function 1 key
115     F2          = 0x71, /// Function 2 key
116     F3          = 0x72, /// Function 3 key
117     F4          = 0x73, /// Function 4 key
118     F5          = 0x74, /// Function 5 key
119     F6          = 0x75, /// Function 6 key
120     F7          = 0x76, /// Function 7 key
121     F8          = 0x77, /// Function 8 key
122     F9          = 0x78, /// Function 9 key
123     F10         = 0x79, /// Function 10 key
124     F11         = 0x7A, /// Function 11 key
125     F12         = 0x7B, /// Function 12 key
126     F13         = 0x7C, /// Function 13 key
127     F14         = 0x7D, /// Function 14 key
128     F15         = 0x7E, /// Function 15 key
129     F16         = 0x7F, /// Function 16 key
130     F17         = 0x80, /// Function 17 key
131     F18         = 0x81, /// Function 18 key
132     F19         = 0x82, /// Function 19 key
133     F20         = 0x83, /// Function 20 key
134     F21         = 0x84, /// Function 21 key
135     F22         = 0x85, /// Function 22 key
136     F23         = 0x86, /// Function 23 key
137     F24         = 0x87, /// Function 24 key
138     //Unused    = 0x88-0x8F,
139     NumLock     = 0x90, /// Num Lock key
140     ScrollLock  = 0x91, /// Scroll Lock key
141     //OEM       = 0x92-0x96,
142     //Unused    = 0x97-0x9F,
143     ShiftLeft   = 0xA0, /// Left shift key
144     ShiftRight  = 0xA1, /// Right shift key
145     ControlLeft = 0xA2, /// Left control key
146     ControlRight= 0xA3, /// Right control key
147     AltLeft     = 0xA4, /// Left Alt key
148     AltRight    = 0xA5, /// Right Alt key
149     END,
150 }
151 
152 enum KeyboardButtonsSDL: uint
153 {
154     Cancel      = SDLK_CANCEL, /// Control-break
155     //Unused    = 0x07,
156     Backspace   = SDLK_BACKSPACE, /// Backspace key
157     Tab         = SDLK_TAB, /// Tab key
158     //Reserved  = 0x0A-0x0B,
159     Clear       = SDLK_CLEAR, /// Clear key
160     Return      = SDLK_RETURN, /// Enter key
161     //Undefined = 0x0E-0x0F
162     // * See Left/Right Shift, Ctrl, Alt below *
163     //Shift       = SDLK_LSHIFT, /// Shift key
164     //Control     = SDLK_LCTRL, /// Control key
165     //Alt         = SDLK_LALT, /// Menu/alt key
166     //
167     Pause       = SDLK_PAUSE, /// Pause key
168     CapsLock    = SDLK_CAPSLOCK,
169     //Who Cares = 0x15-0x1A,
170     Escape      = SDLK_ESCAPE,
171     //Who Cares = 0x1C-0x1F
172     Space       = SDLK_SPACE, /// Space bar
173     PageUp      = SDLK_PAGEUP, /// Page Up/Prior key
174     PageDown    = SDLK_PAGEDOWN, /// Page Down/Next key
175     End         = SDLK_END, /// End key
176     Home        = SDLK_HOME, /// Home key
177     Left        = SDLK_LEFT, /// Left arrow key
178     Up          = SDLK_UP, /// Up arrow key
179     Right       = SDLK_RIGHT, /// Right arrow key
180     Down        = SDLK_DOWN, /// Down arrow key
181     Select      = SDLK_SELECT, /// Select key
182     Print       = SDLK_PRINTSCREEN, /// Print key
183     PrintScreen = SDLK_PRINTSCREEN, /// Print Screen/Snapshot key
184     Execute     = SDLK_EXECUTE, /// Execute key
185     Insert      = SDLK_INSERT, /// Insert key
186     Delete      = SDLK_DELETE, /// Delete key
187     Help        = SDLK_HELP, /// Help key
188     Keyboard0   = SDLK_0, /// 0 key
189     Keyboard1   = SDLK_1, /// 1 key
190     Keyboard2   = SDLK_2, /// 2 key
191     Keyboard3   = SDLK_3, /// 3 key
192     Keyboard4   = SDLK_4, /// 4 key
193     Keyboard5   = SDLK_5, /// 5 key
194     Keyboard6   = SDLK_6, /// 6 key
195     Keyboard7   = SDLK_7, /// 7 key
196     Keyboard8   = SDLK_8, /// 8 key
197     Keyboard9   = SDLK_9, /// 9 key
198     //Unused    = 0x3A-0x40
199     A           = SDLK_a, /// A key
200     B           = SDLK_b, /// B key
201     C           = SDLK_c, /// C key
202     D           = SDLK_d, /// D key
203     E           = SDLK_e, /// E key
204     F           = SDLK_f, /// F key
205     G           = SDLK_g, /// G key
206     H           = SDLK_h, /// H key
207     I           = SDLK_i, /// I key
208     J           = SDLK_j, /// J key
209     K           = SDLK_k, /// K key
210     L           = SDLK_l, /// L key
211     M           = SDLK_m, /// M key
212     N           = SDLK_n, /// N key
213     O           = SDLK_o, /// O key
214     P           = SDLK_p, /// P key
215     Q           = SDLK_q, /// Q key
216     R           = SDLK_r, /// R key
217     S           = SDLK_s, /// S key
218     T           = SDLK_t, /// T key
219     U           = SDLK_u, /// U key
220     V           = SDLK_v, /// V key
221     W           = SDLK_w, /// W key
222     X           = SDLK_x, /// X key
223     Y           = SDLK_y, /// Y key
224     Z           = SDLK_z, /// Z key
225     GuiLeft     = SDLK_LGUI, /// Left GUI key
226     GuiRight    = SDLK_RGUI, /// Right GUI key
227     Apps        = SDLK_APPLICATION, /// Applications key
228     //Reserved  = 0x5E
229     Sleep       = SDLK_SLEEP, /// Sleep key
230     Numpad0     = SDLK_KP_0, /// 0 key
231     Numpad1     = SDLK_KP_1, /// 1 key
232     Numpad2     = SDLK_KP_2, /// 2 key
233     Numpad3     = SDLK_KP_3, /// 3 key
234     Numpad4     = SDLK_KP_4, /// 4 key
235     Numpad5     = SDLK_KP_5, /// 5 key
236     Numpad6     = SDLK_KP_6, /// 6 key
237     Numpad7     = SDLK_KP_7, /// 7 key
238     Numpad8     = SDLK_KP_8, /// 8 key
239     Numpad9     = SDLK_KP_9, /// 9 key
240     // * Unused *
241     //Multiply    = 0x6A, /// Multiply key
242     //Add         = 0x6B, /// Addition key
243     //Separator   = 0x6C, /// Seperator key
244     //Subtract    = 0x6D, /// Subtraction key
245     //Decimal     = 0x6E, /// Decimal key
246     //Divide      = 0x6F, /// Division key
247     F1          = SDLK_F1, /// Function 1 key
248     F2          = SDLK_F2, /// Function 2 key
249     F3          = SDLK_F3, /// Function 3 key
250     F4          = SDLK_F4, /// Function 4 key
251     F5          = SDLK_F5, /// Function 5 key
252     F6          = SDLK_F6, /// Function 6 key
253     F7          = SDLK_F7, /// Function 7 key
254     F8          = SDLK_F8, /// Function 8 key
255     F9          = SDLK_F9, /// Function 9 key
256     F10         = SDLK_F10, /// Function 10 key
257     F11         = SDLK_F11, /// Function 11 key
258     F12         = SDLK_F12, /// Function 12 key
259     F13         = SDLK_F13, /// Function 13 key
260     F14         = SDLK_F14, /// Function 14 key
261     F15         = SDLK_F15, /// Function 15 key
262     F16         = SDLK_F16, /// Function 16 key
263     F17         = SDLK_F17, /// Function 17 key
264     F18         = SDLK_F18, /// Function 18 key
265     F19         = SDLK_F19, /// Function 19 key
266     F20         = SDLK_F20, /// Function 20 key
267     F21         = SDLK_F21, /// Function 21 key
268     F22         = SDLK_F22, /// Function 22 key
269     F23         = SDLK_F23, /// Function 23 key
270     F24         = SDLK_F24, /// Function 24 key
271     //Unused    = 0x88-0x8F,
272     NumLock     = SDLK_NUMLOCKCLEAR, /// Num Lock key
273     ScrollLock  = SDLK_SCROLLLOCK, /// Scroll Lock key
274     //OEM       = 0x92-0x96,
275     //Unused    = 0x97-0x9F,
276     ShiftLeft   = SDLK_LSHIFT, /// Left shift key
277     ShiftRight  = SDLK_LSHIFT, /// Right shift key
278     ControlLeft = SDLK_LCTRL, /// Left control key
279     ControlRight= SDLK_RCTRL, /// Right control key
280     AltLeft     = SDLK_LALT, /// Left Alt key
281     AltRight    = SDLK_RALT, /// Right Alt key
282     END,
283 }