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