input_code.h
1 /*
2 ** UICore
3 ** Copyright (c) 1997-2015 The UICore Team
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 ** Note: Some of the libraries UICore may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Magnus Norddahl
27 */
28 
29 #pragma once
30 
31 // Keyboard & mouse platform independence support.
32 
33 #if defined(WIN32)
34 #include <windows.h>
35 #elif defined(__APPLE__) || defined(__ANDROID__)
36 // No headers for Apple
37 #else
38 #include <X11/keysym.h>
39 #endif
40 
41 namespace uicore
42 {
43  enum InputCode
44  {
53 
87 
88  joystick_button = 0, // "id_offset" set
89  joystick_hat = 0, // "id_offset" set
90 
91 #if defined(WIN32)
92 
93  keycode_backspace = VK_BACK,
94  keycode_tab = VK_TAB,
95  keycode_clear = VK_CLEAR,
96  keycode_return = VK_RETURN,
97  keycode_shift = VK_SHIFT,
98  keycode_control = VK_CONTROL,
99  keycode_menu = VK_MENU,
100  keycode_pause = VK_PAUSE,
101  keycode_escape = VK_ESCAPE,
102 
103 #if !defined(__CYGWIN__) && !defined(__MINGW32__)
104 
105  keycode_kanji = VK_KANJI,
106  keycode_convert = VK_CONVERT,
107  keycode_nonconvert = VK_NONCONVERT,
108 #endif
109 
110  keycode_space = VK_SPACE,
111  keycode_prior = VK_PRIOR,
112  keycode_next = VK_NEXT,
113  keycode_end = VK_END,
114  keycode_home = VK_HOME,
115  keycode_left = VK_LEFT,
116  keycode_up = VK_UP,
117  keycode_right = VK_RIGHT,
118  keycode_down = VK_DOWN,
119  keycode_select = VK_SELECT,
120  keycode_print = VK_PRINT,
121  keycode_execute = VK_EXECUTE,
122  keycode_insert = VK_INSERT,
123  keycode_delete = VK_DELETE,
124  keycode_help = VK_HELP,
125  keycode_0 = '0',
126  keycode_1 = '1',
127  keycode_2 = '2',
128  keycode_3 = '3',
129  keycode_4 = '4',
130  keycode_5 = '5',
131  keycode_6 = '6',
132  keycode_7 = '7',
133  keycode_8 = '8',
134  keycode_9 = '9',
135  keycode_a = 'A',
136  keycode_b = 'B',
137  keycode_c = 'C',
138  keycode_d = 'D',
139  keycode_e = 'E',
140  keycode_f = 'F',
141  keycode_g = 'G',
142  keycode_h = 'H',
143  keycode_i = 'I',
144  keycode_j = 'J',
145  keycode_k = 'K',
146  keycode_l = 'L',
147  keycode_m = 'M',
148  keycode_n = 'N',
149  keycode_o = 'O',
150  keycode_p = 'P',
151  keycode_q = 'Q',
152  keycode_r = 'R',
153  keycode_s = 'S',
154  keycode_t = 'T',
155  keycode_u = 'U',
156  keycode_v = 'V',
157  keycode_w = 'W',
158  keycode_x = 'X',
159  keycode_y = 'Y',
160  keycode_z = 'Z',
161  keycode_lwin = VK_LWIN,
162  keycode_rwin = VK_RWIN,
163  keycode_apps = VK_APPS,
164  keycode_numpad0 = VK_NUMPAD0,
165  keycode_numpad1 = VK_NUMPAD1,
166  keycode_numpad2 = VK_NUMPAD2,
167  keycode_numpad3 = VK_NUMPAD3,
168  keycode_numpad4 = VK_NUMPAD4,
169  keycode_numpad5 = VK_NUMPAD5,
170  keycode_numpad6 = VK_NUMPAD6,
171  keycode_numpad7 = VK_NUMPAD7,
172  keycode_numpad8 = VK_NUMPAD8,
173  keycode_numpad9 = VK_NUMPAD9,
175  keycode_multiply = VK_MULTIPLY,
176  keycode_add = VK_ADD,
177  keycode_separator = VK_SEPARATOR,
178  keycode_subtract = VK_SUBTRACT,
179  keycode_decimal = VK_DECIMAL,
180  keycode_divide = VK_DIVIDE,
181  keycode_f1 = VK_F1,
182  keycode_f2 = VK_F2,
183  keycode_f3 = VK_F3,
184  keycode_f4 = VK_F4,
185  keycode_f5 = VK_F5,
186  keycode_f6 = VK_F6,
187  keycode_f7 = VK_F7,
188  keycode_f8 = VK_F8,
189  keycode_f9 = VK_F9,
190  keycode_f10 = VK_F10,
191  keycode_f11 = VK_F11,
192  keycode_f12 = VK_F12,
193  keycode_f13 = VK_F13,
194  keycode_f14 = VK_F14,
195  keycode_f15 = VK_F15,
196  keycode_f16 = VK_F16,
197  keycode_f17 = VK_F17,
198  keycode_f18 = VK_F18,
199  keycode_f19 = VK_F19,
200  keycode_f20 = VK_F20,
201  keycode_f21 = VK_F21,
202  keycode_f22 = VK_F22,
203  keycode_f23 = VK_F23,
204  keycode_f24 = VK_F24,
205  keycode_numlock = VK_NUMLOCK,
206  keycode_scroll = VK_SCROLL,
207  keycode_lshift = VK_LSHIFT,
208  keycode_rshift = VK_RSHIFT,
209  keycode_lcontrol = VK_LCONTROL,
210  keycode_rcontrol = VK_RCONTROL,
211  keycode_lmenu = VK_LMENU,
212  keycode_rmenu = VK_RMENU,
213 
214 #elif defined(__APPLE__) || defined(__ANDROID__)
215 
216  // Seems like this platform dont have keysyms, or their docs suck so much I
217  // can't find it.
218  //
219  // To solve this matter I've made my own virtual key numbering. If a key
220  // pressed does not match any of these, then it will return the actual
221  // MacOSX keycode in the high order word (keycode + 0x10000000).
222  //
223  // Naturally this require that they dont use keycode values above 0xffff,
224  // but if they do complain to Apple for their crappy keyboard support.
225  // Already kinda annoyed that the keys for typing { and } are alt+shift+8 and
226  // alt+shift+9, plus that backslash is alt+shift+7. How hostile is that!?!?
227  // Oh well what can you expect from a company that write "Designed by Apple
228  // in California" with big letters when you open your box that the powerbook
229  // came in. Yes it shows thats its designed in California!!
230  //
231  // (No offence to California though. Been there once and loved the place.)
232 
234  keycode_tab=11,
235  keycode_clear=12,
236  keycode_return=13,
237  keycode_shift=14,
238  keycode_control=15,
239  keycode_menu=16,
240  keycode_pause=17,
241  keycode_kanji=18,
242  keycode_escape=19,
243  keycode_convert=20,
244  keycode_nonconvert=21,
245  keycode_space=22,
246  keycode_prior=23,
247  keycode_next=24,
248  keycode_end=25,
249  keycode_home=26,
250  keycode_left=27,
251  keycode_up=28,
252  keycode_right=29,
253  keycode_down=30,
254  keycode_select=31,
255  keycode_print=32,
256  keycode_execute=33,
257  keycode_insert=34,
258  keycode_delete=35,
259  keycode_help=36,
260  keycode_0=37,
261  keycode_1=38,
262  keycode_2=39,
263  keycode_3=40,
264  keycode_4=41,
265  keycode_5=42,
266  keycode_6=43,
267  keycode_7=44,
268  keycode_8=45,
269  keycode_9=46,
270  keycode_a=47,
271  keycode_b=48,
272  keycode_c=49,
273  keycode_d=50,
274  keycode_e=51,
275  keycode_f=52,
276  keycode_g=53,
277  keycode_h=54,
278  keycode_i=55,
279  keycode_j=56,
280  keycode_k=57,
281  keycode_l=58,
282  keycode_m=59,
283  keycode_n=60,
284  keycode_o=61,
285  keycode_p=62,
286  keycode_q=63,
287  keycode_r=64,
288  keycode_s=65,
289  keycode_t=66,
290  keycode_u=67,
291  keycode_v=68,
292  keycode_w=69,
293  keycode_x=70,
294  keycode_y=71,
295  keycode_z=72,
296  keycode_lwin=73,
297  keycode_rwin=74,
298  keycode_apps=75,
299  keycode_numpad0=76,
300  keycode_numpad1=77,
301  keycode_numpad2=78,
302  keycode_numpad3=79,
303  keycode_numpad4=80,
304  keycode_numpad5=81,
305  keycode_numpad6=82,
306  keycode_numpad7=83,
307  keycode_numpad8=84,
308  keycode_numpad9=85,
309  keycode_numpad_enter=keycode_return,
310  keycode_multiply=86,
311  keycode_add=87,
312  keycode_separator=88,
313  keycode_subtract=89,
314  keycode_decimal=90,
315  keycode_divide=91,
316  keycode_f1=92,
317  keycode_f2=93,
318  keycode_f3=94,
319  keycode_f4=95,
320  keycode_f5=96,
321  keycode_f6=97,
322  keycode_f7=98,
323  keycode_f8=99,
324  keycode_f9=100,
325  keycode_f10=101,
326  keycode_f11=102,
327  keycode_f12=103,
328  keycode_f13=104,
329  keycode_f14=105,
330  keycode_f15=106,
331  keycode_f16=107,
332  keycode_f17=108,
333  keycode_f18=109,
334  keycode_f19=110,
335  keycode_f20=111,
336  keycode_f21=112,
337  keycode_f22=113,
338  keycode_f23=114,
339  keycode_f24=115,
340  keycode_numlock=116,
341  keycode_scroll=117,
342  keycode_lshift=118,
343  keycode_rshift=119,
344  keycode_lcontrol=120,
345  keycode_rcontrol=121,
346  keycode_lmenu=122,
347  keycode_rmenu=123,
348  keycode_count=124,
349 
350 #else
351 
352  keycode_backspace=XK_BackSpace,
353  keycode_tab=XK_Tab,
354  keycode_clear=XK_Clear,
355  keycode_return=XK_Return,
356  keycode_shift=XK_Shift_L,
357  keycode_control=XK_Control_L,
358  keycode_menu=XK_Menu, // there is no XK_Alt, only XK_Alt_L and XK_Alt_R. Maybe remove this key? -- mbn 30 sep 2003
359  keycode_pause=XK_Pause,
360  keycode_kanji=XK_Kanji,
361  keycode_escape=XK_Escape,
362  keycode_convert=XK_Henkan_Mode,
363  keycode_nonconvert=XK_Muhenkan,
364  keycode_space=XK_space,
365  keycode_prior=XK_Prior,
366  keycode_next=XK_Next,
367  keycode_end=XK_End,
368  keycode_home=XK_Home,
369  keycode_left=XK_Left,
370  keycode_up=XK_Up,
371  keycode_right=XK_Right,
372  keycode_down=XK_Down,
373  keycode_select=XK_Select,
374  keycode_print=XK_Print,
375  keycode_execute=XK_Execute,
376  keycode_insert=XK_Insert,
377  keycode_delete=XK_Delete,
378  keycode_help=XK_Help,
379  keycode_0=XK_0,
380  keycode_1=XK_1,
381  keycode_2=XK_2,
382  keycode_3=XK_3,
383  keycode_4=XK_4,
384  keycode_5=XK_5,
385  keycode_6=XK_6,
386  keycode_7=XK_7,
387  keycode_8=XK_8,
388  keycode_9=XK_9,
389  keycode_a=XK_a,
390  keycode_b=XK_b,
391  keycode_c=XK_c,
392  keycode_d=XK_d,
393  keycode_e=XK_e,
394  keycode_f=XK_f,
395  keycode_g=XK_g,
396  keycode_h=XK_h,
397  keycode_i=XK_i,
398  keycode_j=XK_j,
399  keycode_k=XK_k,
400  keycode_l=XK_l,
401  keycode_m=XK_m,
402  keycode_n=XK_n,
403  keycode_o=XK_o,
404  keycode_p=XK_p,
405  keycode_q=XK_q,
406  keycode_r=XK_r,
407  keycode_s=XK_s,
408  keycode_t=XK_t,
409  keycode_u=XK_u,
410  keycode_v=XK_v,
411  keycode_w=XK_w,
412  keycode_x=XK_x,
413  keycode_y=XK_y,
414  keycode_z=XK_z,
415  keycode_lwin=XK_Super_L,
416  keycode_rwin=XK_Multi_key,
417  keycode_apps=XK_Menu,
418  keycode_numpad0=XK_KP_0,
419  keycode_numpad1=XK_KP_1,
420  keycode_numpad2=XK_KP_2,
421  keycode_numpad3=XK_KP_3,
422  keycode_numpad4=XK_KP_4,
423  keycode_numpad5=XK_KP_5,
424  keycode_numpad6=XK_KP_6,
425  keycode_numpad7=XK_KP_7,
426  keycode_numpad8=XK_KP_8,
427  keycode_numpad9=XK_KP_9,
428  keycode_numpad_enter=XK_KP_Enter,
429  keycode_multiply=XK_KP_Multiply,
430  keycode_add=XK_KP_Add,
431  keycode_separator=XK_KP_Separator,
432  keycode_subtract=XK_KP_Subtract,
433  keycode_decimal=XK_KP_Decimal,
434  keycode_divide=XK_KP_Divide,
435  keycode_f1=XK_F1,
436  keycode_f2=XK_F2,
437  keycode_f3=XK_F3,
438  keycode_f4=XK_F4,
439  keycode_f5=XK_F5,
440  keycode_f6=XK_F6,
441  keycode_f7=XK_F7,
442  keycode_f8=XK_F8,
443  keycode_f9=XK_F9,
444  keycode_f10=XK_F10,
445  keycode_f11=XK_F11,
446  keycode_f12=XK_F12,
447  keycode_f13=XK_F13,
448  keycode_f14=XK_F14,
449  keycode_f15=XK_F15,
450  keycode_f16=XK_F16,
451  keycode_f17=XK_F17,
452  keycode_f18=XK_F18,
453  keycode_f19=XK_F19,
454  keycode_f20=XK_F20,
455  keycode_f21=XK_F21,
456  keycode_f22=XK_F22,
457  keycode_f23=XK_F23,
458  keycode_f24=XK_F24,
459  keycode_numlock=XK_Num_Lock,
460  keycode_scroll=XK_Scroll_Lock,
461  keycode_lshift=XK_Shift_L,
462  keycode_rshift=XK_Shift_R,
463  keycode_lcontrol=XK_Control_L,
464  keycode_rcontrol=XK_Control_R,
465  keycode_lmenu=XK_Meta_L,
466  keycode_rmenu=XK_Meta_R,
467 
468 #endif
469 
473 
475  };
476 }
Definition: input_code.h:451
Definition: input_code.h:408
Definition: input_code.h:65
Definition: input_code.h:74
Definition: input_code.h:378
Definition: input_code.h:454
Definition: input_code.h:377
Definition: input_code.h:386
Definition: input_code.h:426
Definition: input_code.h:363
Definition: input_code.h:50
Definition: input_code.h:437
Definition: input_code.h:69
Definition: input_code.h:362
Definition: input_code.h:60
Definition: input_code.h:457
Definition: input_code.h:379
Definition: input_code.h:358
Definition: input_code.h:361
Definition: input_code.h:373
Definition: input_code.h:439
Definition: input_code.h:428
Definition: input_code.h:385
Definition: input_code.h:79
Definition: input_code.h:49
Definition: input_code.h:356
Definition: input_code.h:369
Definition: input_code.h:387
Definition: input_code.h:55
Definition: input_code.h:425
Definition: input_code.h:63
Definition: input_code.h:417
Definition: input_code.h:420
Definition: input_code.h:470
Definition: input_code.h:415
Definition: input_code.h:83
Definition: input_code.h:427
Definition: input_code.h:446
Definition: input_code.h:438
Definition: input_code.h:59
Definition: input_code.h:472
Definition: input_code.h:456
Definition: input_code.h:392
Definition: input_code.h:422
Definition: input_code.h:452
Definition: input_code.h:382
Definition: input_code.h:453
Definition: input_code.h:353
Definition: input_code.h:445
Definition: input_code.h:463
Definition: input_code.h:409
Definition: input_code.h:364
Definition: input_code.h:395
Definition: input_code.h:418
Definition: input_code.h:471
Definition: input_code.h:474
Definition: input_code.h:414
Definition: input_code.h:368
Definition: input_code.h:413
Definition: input_code.h:430
Definition: input_code.h:82
Definition: input_code.h:67
Definition: input_code.h:86
Definition: input_code.h:57
Definition: input_code.h:375
Definition: input_code.h:394
Definition: input_code.h:400
Definition: input_code.h:366
Definition: input_code.h:406
Definition: input_code.h:424
Definition: input_code.h:405
Definition: input_code.h:58
Definition: input_code.h:56
Definition: input_code.h:81
Definition: input_code.h:433
Definition: input_code.h:435
Definition: input_code.h:442
Definition: input_code.h:449
Definition: input_code.h:404
Definition: input_code.h:397
Definition: input_code.h:447
Definition: input_code.h:431
Definition: input_code.h:402
Definition: input_code.h:429
Definition: input_code.h:84
Definition: input_code.h:64
Definition: input_code.h:444
Definition: input_code.h:88
Definition: input_code.h:441
Definition: input_code.h:380
Definition: input_code.h:73
Definition: input_code.h:61
Definition: input_code.h:54
Definition: input_code.h:48
Definition: input_code.h:432
Definition: input_code.h:393
Definition: input_code.h:419
Definition: input_code.h:389
Definition: input_code.h:450
Definition: input_code.h:365
Definition: input_code.h:354
Definition: input_code.h:77
Definition: input_code.h:75
Definition: input_code.h:68
Definition: input_code.h:376
Definition: input_code.h:399
Definition: input_code.h:461
Definition: input_code.h:359
Definition: input_code.h:66
Definition: input_code.h:51
Definition: input_code.h:411
Definition: input_code.h:412
Definition: input_code.h:421
Definition: input_code.h:370
Definition: input_code.h:357
Definition: input_code.h:47
Definition: input_code.h:367
Definition: input_code.h:464
Definition: input_code.h:89
Definition: input_code.h:360
Definition: input_code.h:459
Definition: input_code.h:401
Definition: input_code.h:388
Definition: input_code.h:72
Definition: input_code.h:466
Definition: input_code.h:436
InputCode
Definition: input_code.h:43
Definition: input_code.h:62
Definition: input_code.h:355
Definition: input_code.h:76
Definition: input_code.h:407
Definition: input_code.h:465
Definition: input_code.h:448
Definition: input_code.h:443
Definition: input_code.h:372
Definition: input_code.h:410
Definition: input_code.h:423
Definition: input_code.h:78
Definition: input_code.h:70
Definition: input_code.h:381
Definition: input_code.h:391
Definition: input_code.h:80
Definition: input_code.h:383
Definition: input_code.h:398
Definition: input_code.h:455
Definition: input_code.h:416
Definition: input_code.h:462
Definition: input_code.h:434
Definition: input_code.h:384
Definition: input_code.h:85
Definition: Application/application.h:35
Definition: input_code.h:440
Definition: input_code.h:45
Definition: input_code.h:403
Definition: input_code.h:460
Definition: input_code.h:52
Definition: input_code.h:374
Definition: input_code.h:390
Definition: input_code.h:371
Definition: input_code.h:71
Definition: input_code.h:396
Definition: input_code.h:352
Definition: input_code.h:46
Definition: input_code.h:458