Mercurial > sdl-ios-xcode
comparison src/video/cocoa/SDL_cocoakeys.h @ 2303:d87417504c75
First pass implementation of new SDL scancode concept, as discussed with
Christian Walther. Currently only implemented on Mac OS X for sanity
checking purposes.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 05 Feb 2008 07:19:23 +0000 |
parents | 4baee598306d |
children |
comparison
equal
deleted
inserted
replaced
2302:7ae1c419b626 | 2303:d87417504c75 |
---|---|
25 - Inside Macintosh: Text <http://developer.apple.com/documentation/mac/Text/Text-571.html> | 25 - Inside Macintosh: Text <http://developer.apple.com/documentation/mac/Text/Text-571.html> |
26 - Apple USB keyboard driver source <http://darwinsource.opendarwin.org/10.4.6.ppc/IOHIDFamily-172.8/IOHIDFamily/Cosmo_USB2ADB.c> | 26 - Apple USB keyboard driver source <http://darwinsource.opendarwin.org/10.4.6.ppc/IOHIDFamily-172.8/IOHIDFamily/Cosmo_USB2ADB.c> |
27 - experimentation on various ADB and USB ISO keyboards and one ADB ANSI keyboard | 27 - experimentation on various ADB and USB ISO keyboards and one ADB ANSI keyboard |
28 */ | 28 */ |
29 /* *INDENT-OFF* */ | 29 /* *INDENT-OFF* */ |
30 static SDLKey macToSDLKey[128] = { | 30 static SDL_scancode scancode_table[128] = { |
31 /* 0 */ SDLK_A, | 31 /* 0 */ SDL_SCANCODE_A, |
32 /* 1 */ SDLK_S, | 32 /* 1 */ SDL_SCANCODE_S, |
33 /* 2 */ SDLK_D, | 33 /* 2 */ SDL_SCANCODE_D, |
34 /* 3 */ SDLK_F, | 34 /* 3 */ SDL_SCANCODE_F, |
35 /* 4 */ SDLK_H, | 35 /* 4 */ SDL_SCANCODE_H, |
36 /* 5 */ SDLK_G, | 36 /* 5 */ SDL_SCANCODE_G, |
37 /* 6 */ SDLK_Z, | 37 /* 6 */ SDL_SCANCODE_Z, |
38 /* 7 */ SDLK_X, | 38 /* 7 */ SDL_SCANCODE_X, |
39 /* 8 */ SDLK_C, | 39 /* 8 */ SDL_SCANCODE_C, |
40 /* 9 */ SDLK_V, | 40 /* 9 */ SDL_SCANCODE_V, |
41 /* 10 */ SDLK_NONUSBACKSLASH, /* SDLK_NONUSBACKSLASH on ANSI and JIS keyboards (if this key would exist there), SDLK_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 /* 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.) */ |
42 /* 11 */ SDLK_B, | 42 /* 11 */ SDL_SCANCODE_B, |
43 /* 12 */ SDLK_Q, | 43 /* 12 */ SDL_SCANCODE_Q, |
44 /* 13 */ SDLK_W, | 44 /* 13 */ SDL_SCANCODE_W, |
45 /* 14 */ SDLK_E, | 45 /* 14 */ SDL_SCANCODE_E, |
46 /* 15 */ SDLK_R, | 46 /* 15 */ SDL_SCANCODE_R, |
47 /* 16 */ SDLK_Y, | 47 /* 16 */ SDL_SCANCODE_Y, |
48 /* 17 */ SDLK_T, | 48 /* 17 */ SDL_SCANCODE_T, |
49 /* 18 */ SDLK_1, | 49 /* 18 */ SDL_SCANCODE_1, |
50 /* 19 */ SDLK_2, | 50 /* 19 */ SDL_SCANCODE_2, |
51 /* 20 */ SDLK_3, | 51 /* 20 */ SDL_SCANCODE_3, |
52 /* 21 */ SDLK_4, | 52 /* 21 */ SDL_SCANCODE_4, |
53 /* 22 */ SDLK_6, | 53 /* 22 */ SDL_SCANCODE_6, |
54 /* 23 */ SDLK_5, | 54 /* 23 */ SDL_SCANCODE_5, |
55 /* 24 */ SDLK_EQUALS, | 55 /* 24 */ SDL_SCANCODE_EQUALS, |
56 /* 25 */ SDLK_9, | 56 /* 25 */ SDL_SCANCODE_9, |
57 /* 26 */ SDLK_7, | 57 /* 26 */ SDL_SCANCODE_7, |
58 /* 27 */ SDLK_HYPHENMINUS, | 58 /* 27 */ SDL_SCANCODE_HYPHENMINUS, |
59 /* 28 */ SDLK_8, | 59 /* 28 */ SDL_SCANCODE_8, |
60 /* 29 */ SDLK_0, | 60 /* 29 */ SDL_SCANCODE_0, |
61 /* 30 */ SDLK_RIGHTBRACKET, | 61 /* 30 */ SDL_SCANCODE_RIGHTBRACKET, |
62 /* 31 */ SDLK_O, | 62 /* 31 */ SDL_SCANCODE_O, |
63 /* 32 */ SDLK_U, | 63 /* 32 */ SDL_SCANCODE_U, |
64 /* 33 */ SDLK_LEFTBRACKET, | 64 /* 33 */ SDL_SCANCODE_LEFTBRACKET, |
65 /* 34 */ SDLK_I, | 65 /* 34 */ SDL_SCANCODE_I, |
66 /* 35 */ SDLK_P, | 66 /* 35 */ SDL_SCANCODE_P, |
67 /* 36 */ SDLK_RETURN, | 67 /* 36 */ SDL_SCANCODE_RETURN, |
68 /* 37 */ SDLK_L, | 68 /* 37 */ SDL_SCANCODE_L, |
69 /* 38 */ SDLK_J, | 69 /* 38 */ SDL_SCANCODE_J, |
70 /* 39 */ SDLK_APOSTROPHE, | 70 /* 39 */ SDL_SCANCODE_APOSTROPHE, |
71 /* 40 */ SDLK_K, | 71 /* 40 */ SDL_SCANCODE_K, |
72 /* 41 */ SDLK_SEMICOLON, | 72 /* 41 */ SDL_SCANCODE_SEMICOLON, |
73 /* 42 */ SDLK_BACKSLASH, | 73 /* 42 */ SDL_SCANCODE_BACKSLASH, |
74 /* 43 */ SDLK_COMMA, | 74 /* 43 */ SDL_SCANCODE_COMMA, |
75 /* 44 */ SDLK_SLASH, | 75 /* 44 */ SDL_SCANCODE_SLASH, |
76 /* 45 */ SDLK_N, | 76 /* 45 */ SDL_SCANCODE_N, |
77 /* 46 */ SDLK_M, | 77 /* 46 */ SDL_SCANCODE_M, |
78 /* 47 */ SDLK_PERIOD, | 78 /* 47 */ SDL_SCANCODE_PERIOD, |
79 /* 48 */ SDLK_TAB, | 79 /* 48 */ SDL_SCANCODE_TAB, |
80 /* 49 */ SDLK_SPACE, | 80 /* 49 */ SDL_SCANCODE_SPACE, |
81 /* 50 */ SDLK_GRAVE, /* SDLK_GRAVE on ANSI and JIS keyboards, SDLK_NONUSBACKSLASH on ISO (see comment about virtual key code 10 above) */ | 81 /* 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) */ |
82 /* 51 */ SDLK_BACKSPACE, | 82 /* 51 */ SDL_SCANCODE_BACKSPACE, |
83 /* 52 */ SDLK_KP_ENTER, /* keyboard enter on portables */ | 83 /* 52 */ SDL_SCANCODE_KP_ENTER, /* keyboard enter on portables */ |
84 /* 53 */ SDLK_ESCAPE, | 84 /* 53 */ SDL_SCANCODE_ESCAPE, |
85 /* 54 */ SDLK_RMETA, | 85 /* 54 */ SDL_SCANCODE_RGUI, |
86 /* 55 */ SDLK_LMETA, | 86 /* 55 */ SDL_SCANCODE_LGUI, |
87 /* 56 */ SDLK_LSHIFT, | 87 /* 56 */ SDL_SCANCODE_LSHIFT, |
88 /* 57 */ SDLK_CAPSLOCK, | 88 /* 57 */ SDL_SCANCODE_CAPSLOCK, |
89 /* 58 */ SDLK_LALT, | 89 /* 58 */ SDL_SCANCODE_LALT, |
90 /* 59 */ SDLK_LCTRL, | 90 /* 59 */ SDL_SCANCODE_LCTRL, |
91 /* 60 */ SDLK_RSHIFT, | 91 /* 60 */ SDL_SCANCODE_RSHIFT, |
92 /* 61 */ SDLK_RALT, | 92 /* 61 */ SDL_SCANCODE_RALT, |
93 /* 62 */ SDLK_RCTRL, | 93 /* 62 */ SDL_SCANCODE_RCTRL, |
94 /* 63 */ SDLK_NONE, /* fn on portables, acts as a hardware-level modifier already, so we don't generate events for it */ | 94 /* 63 */ SDL_SCANCODE_UNKNOWN, /* fn on portables, acts as a hardware-level modifier already, so we don't generate events for it */ |
95 /* 64 */ SDLK_UNKNOWN, /* unknown (unused?) */ | 95 /* 64 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ |
96 /* 65 */ SDLK_KP_PERIOD, | 96 /* 65 */ SDL_SCANCODE_KP_PERIOD, |
97 /* 66 */ SDLK_UNKNOWN, /* unknown (unused?) */ | 97 /* 66 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ |
98 /* 67 */ SDLK_KP_MULTIPLY, | 98 /* 67 */ SDL_SCANCODE_KP_MULTIPLY, |
99 /* 68 */ SDLK_UNKNOWN, /* unknown (unused?) */ | 99 /* 68 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ |
100 /* 69 */ SDLK_KP_PLUS, | 100 /* 69 */ SDL_SCANCODE_KP_PLUS, |
101 /* 70 */ SDLK_UNKNOWN, /* unknown (unused?) */ | 101 /* 70 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ |
102 /* 71 */ SDLK_KP_NUMLOCKCLEAR, | 102 /* 71 */ SDL_SCANCODE_NUMLOCKCLEAR, |
103 /* 72 */ SDLK_VOLUMEUP, | 103 /* 72 */ SDL_SCANCODE_VOLUMEUP, |
104 /* 73 */ SDLK_VOLUMEDOWN, | 104 /* 73 */ SDL_SCANCODE_VOLUMEDOWN, |
105 /* 74 */ SDLK_MUTE, | 105 /* 74 */ SDL_SCANCODE_MUTE, |
106 /* 75 */ SDLK_KP_DIVIDE, | 106 /* 75 */ SDL_SCANCODE_KP_DIVIDE, |
107 /* 76 */ SDLK_KP_ENTER, /* keypad enter on external keyboards, fn-return on portables */ | 107 /* 76 */ SDL_SCANCODE_KP_ENTER, /* keypad enter on external keyboards, fn-return on portables */ |
108 /* 77 */ SDLK_UNKNOWN, /* unknown (unused?) */ | 108 /* 77 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ |
109 /* 78 */ SDLK_KP_MINUS, | 109 /* 78 */ SDL_SCANCODE_KP_MINUS, |
110 /* 79 */ SDLK_UNKNOWN, /* unknown (unused?) */ | 110 /* 79 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ |
111 /* 80 */ SDLK_UNKNOWN, /* unknown (unused?) */ | 111 /* 80 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ |
112 /* 81 */ SDLK_KP_EQUALS, | 112 /* 81 */ SDL_SCANCODE_KP_EQUALS, |
113 /* 82 */ SDLK_KP_0, | 113 /* 82 */ SDL_SCANCODE_KP_0, |
114 /* 83 */ SDLK_KP_1, | 114 /* 83 */ SDL_SCANCODE_KP_1, |
115 /* 84 */ SDLK_KP_2, | 115 /* 84 */ SDL_SCANCODE_KP_2, |
116 /* 85 */ SDLK_KP_3, | 116 /* 85 */ SDL_SCANCODE_KP_3, |
117 /* 86 */ SDLK_KP_4, | 117 /* 86 */ SDL_SCANCODE_KP_4, |
118 /* 87 */ SDLK_KP_5, | 118 /* 87 */ SDL_SCANCODE_KP_5, |
119 /* 88 */ SDLK_KP_6, | 119 /* 88 */ SDL_SCANCODE_KP_6, |
120 /* 89 */ SDLK_KP_7, | 120 /* 89 */ SDL_SCANCODE_KP_7, |
121 /* 90 */ SDLK_UNKNOWN, /* unknown (unused?) */ | 121 /* 90 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ |
122 /* 91 */ SDLK_KP_8, | 122 /* 91 */ SDL_SCANCODE_KP_8, |
123 /* 92 */ SDLK_KP_9, | 123 /* 92 */ SDL_SCANCODE_KP_9, |
124 /* 93 */ SDLK_INTERNATIONAL3, /* Cosmo_USB2ADB.c says "Yen (JIS)" */ | 124 /* 93 */ SDL_SCANCODE_INTERNATIONAL3, /* Cosmo_USB2ADB.c says "Yen (JIS)" */ |
125 /* 94 */ SDLK_INTERNATIONAL1, /* Cosmo_USB2ADB.c says "Ro (JIS)" */ | 125 /* 94 */ SDL_SCANCODE_INTERNATIONAL1, /* Cosmo_USB2ADB.c says "Ro (JIS)" */ |
126 /* 95 */ SDLK_KP_COMMA, /* Cosmo_USB2ADB.c says ", JIS only" */ | 126 /* 95 */ SDL_SCANCODE_KP_COMMA, /* Cosmo_USB2ADB.c says ", JIS only" */ |
127 /* 96 */ SDLK_F5, | 127 /* 96 */ SDL_SCANCODE_F5, |
128 /* 97 */ SDLK_F6, | 128 /* 97 */ SDL_SCANCODE_F6, |
129 /* 98 */ SDLK_F7, | 129 /* 98 */ SDL_SCANCODE_F7, |
130 /* 99 */ SDLK_F3, | 130 /* 99 */ SDL_SCANCODE_F3, |
131 /* 100 */ SDLK_F8, | 131 /* 100 */ SDL_SCANCODE_F8, |
132 /* 101 */ SDLK_F9, | 132 /* 101 */ SDL_SCANCODE_F9, |
133 /* 102 */ SDLK_LANG2, /* Cosmo_USB2ADB.c says "Eisu" */ | 133 /* 102 */ SDL_SCANCODE_LANG2, /* Cosmo_USB2ADB.c says "Eisu" */ |
134 /* 103 */ SDLK_F11, | 134 /* 103 */ SDL_SCANCODE_F11, |
135 /* 104 */ SDLK_LANG1, /* Cosmo_USB2ADB.c says "Kana" */ | 135 /* 104 */ SDL_SCANCODE_LANG1, /* Cosmo_USB2ADB.c says "Kana" */ |
136 /* 105 */ SDLK_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 (SDLK_F13). I decided to use SDLK_PRINTSCREEN here nevertheless since SDL applications are more likely to assume the presence of a print screen key than an F13 key. */ | 136 /* 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. */ |
137 /* 106 */ SDLK_F16, | 137 /* 106 */ SDL_SCANCODE_F16, |
138 /* 107 */ SDLK_SCROLLLOCK, /* F14/scroll lock, see comment about F13/print screen above */ | 138 /* 107 */ SDL_SCANCODE_SCROLLLOCK, /* F14/scroll lock, see comment about F13/print screen above */ |
139 /* 108 */ SDLK_UNKNOWN, /* unknown (unused?) */ | 139 /* 108 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ |
140 /* 109 */ SDLK_F10, | 140 /* 109 */ SDL_SCANCODE_F10, |
141 /* 110 */ SDLK_APPLICATION, /* windows contextual menu key, fn-enter on portables */ | 141 /* 110 */ SDL_SCANCODE_APPLICATION, /* windows contextual menu key, fn-enter on portables */ |
142 /* 111 */ SDLK_F12, | 142 /* 111 */ SDL_SCANCODE_F12, |
143 /* 112 */ SDLK_UNKNOWN, /* unknown (unused?) */ | 143 /* 112 */ SDL_SCANCODE_UNKNOWN, /* unknown (unused?) */ |
144 /* 113 */ SDLK_PAUSE, /* F15/pause, see comment about F13/print screen above */ | 144 /* 113 */ SDL_SCANCODE_PAUSE, /* F15/pause, see comment about F13/print screen above */ |
145 /* 114 */ SDLK_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 /* 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 */ |
146 /* 115 */ SDLK_HOME, | 146 /* 115 */ SDL_SCANCODE_HOME, |
147 /* 116 */ SDLK_PAGEUP, | 147 /* 116 */ SDL_SCANCODE_PAGEUP, |
148 /* 117 */ SDLK_DELETE, | 148 /* 117 */ SDL_SCANCODE_DELETE, |
149 /* 118 */ SDLK_F4, | 149 /* 118 */ SDL_SCANCODE_F4, |
150 /* 119 */ SDLK_END, | 150 /* 119 */ SDL_SCANCODE_END, |
151 /* 120 */ SDLK_F2, | 151 /* 120 */ SDL_SCANCODE_F2, |
152 /* 121 */ SDLK_PAGEDOWN, | 152 /* 121 */ SDL_SCANCODE_PAGEDOWN, |
153 /* 122 */ SDLK_F1, | 153 /* 122 */ SDL_SCANCODE_F1, |
154 /* 123 */ SDLK_LEFT, | 154 /* 123 */ SDL_SCANCODE_LEFT, |
155 /* 124 */ SDLK_RIGHT, | 155 /* 124 */ SDL_SCANCODE_RIGHT, |
156 /* 125 */ SDLK_DOWN, | 156 /* 125 */ SDL_SCANCODE_DOWN, |
157 /* 126 */ SDLK_UP, | 157 /* 126 */ SDL_SCANCODE_UP, |
158 /* 127 */ SDLK_POWER | 158 /* 127 */ SDL_SCANCODE_POWER |
159 }; | 159 }; |
160 /* *INDENT-ON* */ | 160 /* *INDENT-ON* */ |