comparison include/SDL_compat.h @ 2268:4baee598306d

Date: Thu, 05 Jul 2007 14:02:33 -0700 From: Sam Lantinga Subject: SDL 1.3 keyboard plan After lots of discussion with Christian, this is what we came up with: > So, to sum up... > SDLK_* become the physical keys, starting at > (1<<21) > We create a macro SDLK_INDEX(X) > We have two functions SDL_GetLayoutKey(SDLKey) and SDL_GetKeyName() > SDL_GetLayoutKey maps to UCS4 for printable characters, and SDLK* for non-printable characters > and does so based on the OS's current keyboard layout > SDL_GetKeyName() handles both SDLK_* and UCS4, converting UCS4 to UTF-8 and converting SDLK_* into our names, which are UTF-8 for printable characters. > WASD folks use SDLK_*, and 'I' folks use SDL_GetLayoutKey(SDLK_*) Here is the patch he came up with, and his e-mail about it: Date: Fri, 17 Aug 2007 19:50:28 +0200 From: Christian Walther Subject: Re: SDL 1.3 keyboard plan > Sounds great, go ahead and send me a patch. Here goes! Thanks for having a look. Don't hesitate to comment if anything does not conform to your ideas. One caveat: Committing this now may break compilability of some video drivers - specifically, if they use any of the SDLK_* codes that were obsoleted and moved into SDL_compat.h. I only tried Cocoa (which did break, but is already fixed) and X11 (which didn't, but then its key handling is #iffed out). If that's a problem, it may need to go into a branch. -Christian
author Sam Lantinga <slouken@libsdl.org>
date Sun, 19 Aug 2007 14:52:52 +0000
parents c785543d1843
children dbc6d1893869
comparison
equal deleted inserted replaced
2267:c785543d1843 2268:4baee598306d
127 SDL_GRAB_OFF = 0, 127 SDL_GRAB_OFF = 0,
128 SDL_GRAB_ON = 1 128 SDL_GRAB_ON = 1
129 } SDL_GrabMode; 129 } SDL_GrabMode;
130 130
131 struct SDL_SysWMinfo; 131 struct SDL_SysWMinfo;
132
133 /* Key codes
134 Note that the correspondences defined here are approximate at best because
135 the meaning of the event structure field that carries these values has
136 changed: in SDL 1.2, it referred to the key's label in the current keyboard
137 layout, whereas now it refers to a specific physical key on the keyboard,
138 regardless of the keyboard layout setting.
139 To get comparable behavior to SDL 1.2, code that uses any of the codes below
140 in ways like "if (somekey == SDLK_EXCLAIM)" should be changed to the
141 equivalent of "if (SDL_GetLayoutKey(somekey) == '!')".
142 */
143
144 /* These key constants were renamed for clarity or consistence. */
145 #define SDLK_QUOTE SDLK_APOSTROPHE
146 #define SDLK_MINUS SDLK_HYPHENMINUS
147 #define SDLK_BACKQUOTE SDLK_GRAVE
148 #define SDLK_a SDLK_A
149 #define SDLK_b SDLK_B
150 #define SDLK_c SDLK_C
151 #define SDLK_d SDLK_D
152 #define SDLK_e SDLK_E
153 #define SDLK_f SDLK_F
154 #define SDLK_g SDLK_G
155 #define SDLK_h SDLK_H
156 #define SDLK_i SDLK_I
157 #define SDLK_j SDLK_J
158 #define SDLK_k SDLK_K
159 #define SDLK_l SDLK_L
160 #define SDLK_m SDLK_M
161 #define SDLK_n SDLK_N
162 #define SDLK_o SDLK_O
163 #define SDLK_p SDLK_P
164 #define SDLK_q SDLK_Q
165 #define SDLK_r SDLK_R
166 #define SDLK_s SDLK_S
167 #define SDLK_t SDLK_T
168 #define SDLK_u SDLK_U
169 #define SDLK_v SDLK_V
170 #define SDLK_w SDLK_W
171 #define SDLK_x SDLK_X
172 #define SDLK_y SDLK_Y
173 #define SDLK_z SDLK_Z
174 #define SDLK_KP0 SDLK_KP_0
175 #define SDLK_KP1 SDLK_KP_1
176 #define SDLK_KP2 SDLK_KP_2
177 #define SDLK_KP3 SDLK_KP_3
178 #define SDLK_KP4 SDLK_KP_4
179 #define SDLK_KP5 SDLK_KP_5
180 #define SDLK_KP6 SDLK_KP_6
181 #define SDLK_KP7 SDLK_KP_7
182 #define SDLK_KP8 SDLK_KP_8
183 #define SDLK_KP9 SDLK_KP_9
184 #define SDLK_NUMLOCK SDLK_KP_NUMLOCKCLEAR
185 #define SDLK_SCROLLOCK SDLK_SCROLLLOCK
186 #define SDLK_PRINT SDLK_PRINTSCREEN
187
188 /* These key constants are obsoleted the new keyboard handling, their definitions here correspond to how they appear on a US keyboard. */
189 #define SDLK_EXCLAIM SDLK_1
190 #define SDLK_QUOTEDBL SDLK_APOSTROPHE
191 #define SDLK_HASH SDLK_3
192 #define SDLK_DOLLAR SDLK_4
193 #define SDLK_AMPERSAND SDLK_7
194 #define SDLK_LEFTPAREN SDLK_9
195 #define SDLK_RIGHTPAREN SDLK_0
196 #define SDLK_ASTERISK SDLK_8
197 #define SDLK_PLUS SDLK_EQUALS
198 #define SDLK_COLON SDLK_SEMICOLON
199 #define SDLK_LESS SDLK_COMMA
200 #define SDLK_GREATER SDLK_PERIOD
201 #define SDLK_QUESTION SDLK_SLASH
202 #define SDLK_AT SDLK_2
203 #define SDLK_CARET SDLK_6
204 #define SDLK_UNDERSCORE SDLK_HYPHENMINUS
205
206 /* These keys don't appear in the USB specification (or at least not under those names). I'm unsure if the following assignments make sense or if these codes should be defined as actual additional SDLK_ constants. */
207 #define SDLK_LSUPER SDLK_LMETA
208 #define SDLK_RSUPER SDLK_RMETA
209 #define SDLK_COMPOSE SDLK_APPLICATION
210 #define SDLK_BREAK SDLK_STOP
211 #define SDLK_EURO SDLK_2
212
132 213
133 #define SDL_SetModuleHandle(x) 214 #define SDL_SetModuleHandle(x)
134 #define SDL_AllocSurface SDL_CreateRGBSurface 215 #define SDL_AllocSurface SDL_CreateRGBSurface
135 216
136 extern DECLSPEC const SDL_version *SDLCALL SDL_Linked_Version(void); 217 extern DECLSPEC const SDL_version *SDLCALL SDL_Linked_Version(void);