1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2021 Sam Lantinga <slouken@libsdl.org>
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/* Mac virtual key code to SDL scancode mapping table
23 Sources:
24 - Inside Macintosh: Text <http://developer.apple.com/documentation/mac/Text/Text-571.html>
25 - Apple USB keyboard driver source <http://darwinsource.opendarwin.org/10.4.6.ppc/IOHIDFamily-172.8/IOHIDFamily/Cosmo_USB2ADB.c>
26 - experimentation on various ADB and USB ISO keyboards and one ADB ANSI keyboard
27*/
28/* *INDENT-OFF* */
29static const SDL_Scancode darwin_scancode_table[] = {
30 /* 0 */ SDL_SCANCODE_A,
31 /* 1 */ SDL_SCANCODE_S,
32 /* 2 */ SDL_SCANCODE_D,
33 /* 3 */ SDL_SCANCODE_F,
34 /* 4 */ SDL_SCANCODE_H,
35 /* 5 */ SDL_SCANCODE_G,
36 /* 6 */ SDL_SCANCODE_Z,
37 /* 7 */ SDL_SCANCODE_X,
38 /* 8 */ SDL_SCANCODE_C,
39 /* 9 */ SDL_SCANCODE_V,
40 /* 10 */ SDL_SCANCODE_NONUSBACKSLASH, /* SDL_SCANCODE_NONUSBACKSLASH on ANSI and JIS keyboards (if this key would exist there), SDL_SCANCODE_GRAVE on ISO. (The USB keyboard driver actually translates these usage codes to different virtual key codes depending on whether the keyboard is ISO/ANSI/JIS. That's why you have to help it identify the keyboard type when you plug in a PC USB keyboard. It's a historical thing - ADB keyboards are wired this way.) */
41 /* 11 */ SDL_SCANCODE_B,
42 /* 12 */ SDL_SCANCODE_Q,
43 /* 13 */ SDL_SCANCODE_W,
44 /* 14 */ SDL_SCANCODE_E,
45 /* 15 */ SDL_SCANCODE_R,
46 /* 16 */ SDL_SCANCODE_Y,
47 /* 17 */ SDL_SCANCODE_T,
48 /* 18 */ SDL_SCANCODE_1,
49 /* 19 */ SDL_SCANCODE_2,
50 /* 20 */ SDL_SCANCODE_3,
51 /* 21 */ SDL_SCANCODE_4,
52 /* 22 */ SDL_SCANCODE_6,
53 /* 23 */ SDL_SCANCODE_5,
54 /* 24 */ SDL_SCANCODE_EQUALS,
55 /* 25 */ SDL_SCANCODE_9,
56 /* 26 */ SDL_SCANCODE_7,
57 /* 27 */ SDL_SCANCODE_MINUS,
58 /* 28 */ SDL_SCANCODE_8,
59 /* 29 */ SDL_SCANCODE_0,
60 /* 30 */ SDL_SCANCODE_RIGHTBRACKET,
61 /* 31 */ SDL_SCANCODE_O,
62 /* 32 */ SDL_SCANCODE_U,
63 /* 33 */ SDL_SCANCODE_LEFTBRACKET,
64 /* 34 */ SDL_SCANCODE_I,
65 /* 35 */ SDL_SCANCODE_P,
66 /* 36 */ SDL_SCANCODE_RETURN,
67 /* 37 */ SDL_SCANCODE_L,
68 /* 38 */ SDL_SCANCODE_J,
69 /* 39 */ SDL_SCANCODE_APOSTROPHE,
70 /* 40 */ SDL_SCANCODE_K,
71 /* 41 */ SDL_SCANCODE_SEMICOLON,
72 /* 42 */ SDL_SCANCODE_BACKSLASH,
73 /* 43 */ SDL_SCANCODE_COMMA,
74 /* 44 */ SDL_SCANCODE_SLASH,
75 /* 45 */ SDL_SCANCODE_N,
76 /* 46 */ SDL_SCANCODE_M,
77 /* 47 */ SDL_SCANCODE_PERIOD,
78 /* 48 */ SDL_SCANCODE_TAB,
79 /* 49 */ SDL_SCANCODE_SPACE,
80 /* 50 */ SDL_SCANCODE_GRAVE, /* SDL_SCANCODE_GRAVE on ANSI and JIS keyboards, SDL_SCANCODE_NONUSBACKSLASH on ISO (see comment about virtual key code 10 above) */
81 /* 51 */ SDL_SCANCODE_BACKSPACE,
82 /* 52 */ SDL_SCANCODE_KP_ENTER, /* keyboard enter on portables */
83 /* 53 */ SDL_SCANCODE_ESCAPE,
84 /* 54 */ SDL_SCANCODE_RGUI,
85 /* 55 */ SDL_SCANCODE_LGUI,
86 /* 56 */ SDL_SCANCODE_LSHIFT,
87 /* 57 */ SDL_SCANCODE_CAPSLOCK,
88 /* 58 */ SDL_SCANCODE_LALT,
89 /* 59 */ SDL_SCANCODE_LCTRL,
90 /* 60 */ SDL_SCANCODE_RSHIFT,
91 /* 61 */ SDL_SCANCODE_RALT,
92 /* 62 */ SDL_SCANCODE_RCTRL,
93 /* 63 */ SDL_SCANCODE_RGUI, /* fn on portables, acts as a hardware-level modifier already, so we don't generate events for it, also XK_Meta_R */
94 /* 64 */ SDL_SCANCODE_F17,
95 /* 65 */ SDL_SCANCODE_KP_PERIOD,
96 /* 66 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
97 /* 67 */ SDL_SCANCODE_KP_MULTIPLY,
98 /* 68 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
99 /* 69 */ SDL_SCANCODE_KP_PLUS,
100 /* 70 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
101 /* 71 */ SDL_SCANCODE_NUMLOCKCLEAR,
102 /* 72 */ SDL_SCANCODE_VOLUMEUP,
103 /* 73 */ SDL_SCANCODE_VOLUMEDOWN,
104 /* 74 */ SDL_SCANCODE_MUTE,
105 /* 75 */ SDL_SCANCODE_KP_DIVIDE,
106 /* 76 */ SDL_SCANCODE_KP_ENTER, /* keypad enter on external keyboards, fn-return on portables */
107 /* 77 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
108 /* 78 */ SDL_SCANCODE_KP_MINUS,
109 /* 79 */ SDL_SCANCODE_F18,
110 /* 80 */ SDL_SCANCODE_F19,
111 /* 81 */ SDL_SCANCODE_KP_EQUALS,
112 /* 82 */ SDL_SCANCODE_KP_0,
113 /* 83 */ SDL_SCANCODE_KP_1,
114 /* 84 */ SDL_SCANCODE_KP_2,
115 /* 85 */ SDL_SCANCODE_KP_3,
116 /* 86 */ SDL_SCANCODE_KP_4,
117 /* 87 */ SDL_SCANCODE_KP_5,
118 /* 88 */ SDL_SCANCODE_KP_6,
119 /* 89 */ SDL_SCANCODE_KP_7,
120 /* 90 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
121 /* 91 */ SDL_SCANCODE_KP_8,
122 /* 92 */ SDL_SCANCODE_KP_9,
123 /* 93 */ SDL_SCANCODE_INTERNATIONAL3, /* Cosmo_USB2ADB.c says "Yen (JIS)" */
124 /* 94 */ SDL_SCANCODE_INTERNATIONAL1, /* Cosmo_USB2ADB.c says "Ro (JIS)" */
125 /* 95 */ SDL_SCANCODE_KP_COMMA, /* Cosmo_USB2ADB.c says ", JIS only" */
126 /* 96 */ SDL_SCANCODE_F5,
127 /* 97 */ SDL_SCANCODE_F6,
128 /* 98 */ SDL_SCANCODE_F7,
129 /* 99 */ SDL_SCANCODE_F3,
130 /* 100 */ SDL_SCANCODE_F8,
131 /* 101 */ SDL_SCANCODE_F9,
132 /* 102 */ SDL_SCANCODE_LANG2, /* Cosmo_USB2ADB.c says "Eisu" */
133 /* 103 */ SDL_SCANCODE_F11,
134 /* 104 */ SDL_SCANCODE_LANG1, /* Cosmo_USB2ADB.c says "Kana" */
135 /* 105 */ SDL_SCANCODE_PRINTSCREEN, /* On ADB keyboards, this key is labeled "F13/print screen". Problem: USB has different usage codes for these two functions. On Apple USB keyboards, the key is labeled "F13" and sends the F13 usage code (SDL_SCANCODE_F13). I decided to use SDL_SCANCODE_PRINTSCREEN here nevertheless since SDL applications are more likely to assume the presence of a print screen key than an F13 key. */
136 /* 106 */ SDL_SCANCODE_F16,
137 /* 107 */ SDL_SCANCODE_SCROLLLOCK, /* F14/scroll lock, see comment about F13/print screen above */
138 /* 108 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
139 /* 109 */ SDL_SCANCODE_F10,
140 /* 110 */ SDL_SCANCODE_APPLICATION, /* windows contextual menu key, fn-enter on portables */
141 /* 111 */ SDL_SCANCODE_F12,
142 /* 112 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */
143 /* 113 */ SDL_SCANCODE_PAUSE, /* F15/pause, see comment about F13/print screen above */
144 /* 114 */ SDL_SCANCODE_INSERT, /* the key is actually labeled "help" on Apple keyboards, and works as such in Mac OS, but it sends the "insert" usage code even on Apple USB keyboards */
145 /* 115 */ SDL_SCANCODE_HOME,
146 /* 116 */ SDL_SCANCODE_PAGEUP,
147 /* 117 */ SDL_SCANCODE_DELETE,
148 /* 118 */ SDL_SCANCODE_F4,
149 /* 119 */ SDL_SCANCODE_END,
150 /* 120 */ SDL_SCANCODE_F2,
151 /* 121 */ SDL_SCANCODE_PAGEDOWN,
152 /* 122 */ SDL_SCANCODE_F1,
153 /* 123 */ SDL_SCANCODE_LEFT,
154 /* 124 */ SDL_SCANCODE_RIGHT,
155 /* 125 */ SDL_SCANCODE_DOWN,
156 /* 126 */ SDL_SCANCODE_UP,
157 /* 127 */ SDL_SCANCODE_POWER
158};
159/* *INDENT-ON* */
160