Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
1048 lines (1000 loc) · 33 KB

SDL_x11keyboard.c

File metadata and controls

1048 lines (1000 loc) · 33 KB
 
Jul 26, 2006
Jul 26, 2006
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2006 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Sam Lantinga
slouken@libsdl.org
*/
#include "SDL_config.h"
#include "SDL_x11video.h"
#include "../../events/SDL_keyboard_c.h"
Jan 8, 2008
Jan 8, 2008
28
29
30
31
#include <X11/keysym.h>
#include "imKStoUCS.h"
Jan 9, 2008
Jan 9, 2008
32
33
34
/*
KeyCode-to-SDLKey translation tables for various X servers. Which
one to use is decided in X11_InitKeyboard().
Jan 8, 2008
Jan 8, 2008
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
*/
static SDLKey macKeyCodeToSDLK[];
static SDLKey xorgLinuxKeyCodeToSDLK[];
static SDLKey *keyCodeToSDLKeyTables[] = {
xorgLinuxKeyCodeToSDLK,
macKeyCodeToSDLK,
NULL
};
/* *INDENT-OFF* */
/* These are just Mac virtual key codes + 8 (see SDL/src/video/cocoa/
SDL_cocoakeys.h for more info). Observed to work with Apple X11 on
Mac OS X 10.4. May also work on older Linux distributions on Mac
hardware.
*/
Jan 9, 2008
Jan 9, 2008
53
54
55
56
#define KeyCodeTableSize (258)
static SDLKey macKeyCodeToSDLK[KeyCodeTableSize] =
{
Jan 8, 2008
Jan 8, 2008
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
/* 0 */ SDLK_UNKNOWN,
/* 1 */ SDLK_UNKNOWN,
/* 2 */ SDLK_UNKNOWN,
/* 3 */ SDLK_UNKNOWN,
/* 4 */ SDLK_UNKNOWN,
/* 5 */ SDLK_UNKNOWN,
/* 6 */ SDLK_UNKNOWN,
/* 7 */ SDLK_UNKNOWN,
/* 8 */ SDLK_A,
/* 9 */ SDLK_S,
/* 10 */ SDLK_D,
/* 11 */ SDLK_F,
/* 12 */ SDLK_H,
/* 13 */ SDLK_G,
/* 14 */ SDLK_Z,
/* 15 */ SDLK_X,
/* 16 */ SDLK_C,
/* 17 */ SDLK_V,
/* 18 */ SDLK_GRAVE,
/* 19 */ SDLK_B,
/* 20 */ SDLK_Q,
/* 21 */ SDLK_W,
/* 22 */ SDLK_E,
/* 23 */ SDLK_R,
/* 24 */ SDLK_Y,
/* 25 */ SDLK_T,
/* 26 */ SDLK_1,
/* 27 */ SDLK_2,
/* 28 */ SDLK_3,
/* 29 */ SDLK_4,
/* 30 */ SDLK_6,
/* 31 */ SDLK_5,
/* 32 */ SDLK_EQUALS,
/* 33 */ SDLK_9,
/* 34 */ SDLK_7,
/* 35 */ SDLK_HYPHENMINUS,
/* 36 */ SDLK_8,
/* 37 */ SDLK_0,
/* 38 */ SDLK_RIGHTBRACKET,
/* 39 */ SDLK_O,
/* 40 */ SDLK_U,
/* 41 */ SDLK_LEFTBRACKET,
/* 42 */ SDLK_I,
/* 43 */ SDLK_P,
/* 44 */ SDLK_RETURN,
/* 45 */ SDLK_L,
/* 46 */ SDLK_J,
/* 47 */ SDLK_APOSTROPHE,
/* 48 */ SDLK_K,
/* 49 */ SDLK_SEMICOLON,
/* 50 */ SDLK_BACKSLASH,
/* 51 */ SDLK_COMMA,
/* 52 */ SDLK_SLASH,
/* 53 */ SDLK_N,
/* 54 */ SDLK_M,
/* 55 */ SDLK_PERIOD,
/* 56 */ SDLK_TAB,
/* 57 */ SDLK_SPACE,
/* 58 */ SDLK_NONUSBACKSLASH,
/* 59 */ SDLK_BACKSPACE,
/* 60 */ SDLK_KP_ENTER,
/* 61 */ SDLK_ESCAPE,
/* 62 */ SDLK_RMETA,
/* 63 */ SDLK_LMETA,
/* 64 */ SDLK_LSHIFT,
/* 65 */ SDLK_CAPSLOCK,
/* 66 */ SDLK_LALT,
/* 67 */ SDLK_LCTRL,
/* 68 */ SDLK_RSHIFT,
/* 69 */ SDLK_RALT,
/* 70 */ SDLK_RCTRL,
/* 71 */ SDLK_NONE,
/* 72 */ SDLK_UNKNOWN,
/* 73 */ SDLK_KP_PERIOD,
/* 74 */ SDLK_UNKNOWN,
/* 75 */ SDLK_KP_MULTIPLY,
/* 76 */ SDLK_UNKNOWN,
/* 77 */ SDLK_KP_PLUS,
/* 78 */ SDLK_UNKNOWN,
/* 79 */ SDLK_KP_NUMLOCKCLEAR,
/* 80 */ SDLK_VOLUMEUP,
/* 81 */ SDLK_VOLUMEDOWN,
/* 82 */ SDLK_MUTE,
/* 83 */ SDLK_KP_DIVIDE,
/* 84 */ SDLK_KP_ENTER,
/* 85 */ SDLK_UNKNOWN,
/* 86 */ SDLK_KP_MINUS,
/* 87 */ SDLK_UNKNOWN,
/* 88 */ SDLK_UNKNOWN,
/* 89 */ SDLK_KP_EQUALS,
/* 90 */ SDLK_KP_0,
/* 91 */ SDLK_KP_1,
/* 92 */ SDLK_KP_2,
/* 93 */ SDLK_KP_3,
/* 94 */ SDLK_KP_4,
/* 95 */ SDLK_KP_5,
/* 96 */ SDLK_KP_6,
/* 97 */ SDLK_KP_7,
/* 98 */ SDLK_UNKNOWN,
/* 99 */ SDLK_KP_8,
/* 100 */ SDLK_KP_9,
/* 101 */ SDLK_INTERNATIONAL3,
/* 102 */ SDLK_INTERNATIONAL1,
/* 103 */ SDLK_KP_COMMA,
/* 104 */ SDLK_F5,
/* 105 */ SDLK_F6,
/* 106 */ SDLK_F7,
/* 107 */ SDLK_F3,
/* 108 */ SDLK_F8,
/* 109 */ SDLK_F9,
/* 110 */ SDLK_LANG2,
/* 111 */ SDLK_F11,
/* 112 */ SDLK_LANG1,
/* 113 */ SDLK_PRINTSCREEN,
/* 114 */ SDLK_F16,
/* 115 */ SDLK_SCROLLLOCK,
/* 116 */ SDLK_UNKNOWN,
/* 117 */ SDLK_F10,
/* 118 */ SDLK_APPLICATION,
/* 119 */ SDLK_F12,
/* 120 */ SDLK_UNKNOWN,
/* 121 */ SDLK_PAUSE,
/* 122 */ SDLK_INSERT,
/* 123 */ SDLK_HOME,
/* 124 */ SDLK_PAGEUP,
/* 125 */ SDLK_DELETE,
/* 126 */ SDLK_F4,
/* 127 */ SDLK_END,
/* 128 */ SDLK_F2,
/* 129 */ SDLK_PAGEDOWN,
/* 130 */ SDLK_F1,
/* 131 */ SDLK_LEFT,
/* 132 */ SDLK_RIGHT,
/* 133 */ SDLK_DOWN,
/* 134 */ SDLK_UP,
/* 135 */ SDLK_POWER,
/* 136 */ SDLK_UNKNOWN, /* codes higher than 135 shouldn't occur as Mac virtual keycodes only go to 127 */
/* 137 */ SDLK_UNKNOWN,
/* 138 */ SDLK_UNKNOWN,
/* 139 */ SDLK_UNKNOWN,
/* 140 */ SDLK_UNKNOWN,
/* 141 */ SDLK_UNKNOWN,
/* 142 */ SDLK_UNKNOWN,
/* 143 */ SDLK_UNKNOWN,
/* 144 */ SDLK_UNKNOWN,
/* 145 */ SDLK_UNKNOWN,
/* 146 */ SDLK_UNKNOWN,
/* 147 */ SDLK_UNKNOWN,
/* 148 */ SDLK_UNKNOWN,
/* 149 */ SDLK_UNKNOWN,
/* 150 */ SDLK_UNKNOWN,
/* 151 */ SDLK_UNKNOWN,
/* 152 */ SDLK_UNKNOWN,
/* 153 */ SDLK_UNKNOWN,
/* 154 */ SDLK_UNKNOWN,
/* 155 */ SDLK_UNKNOWN,
/* 156 */ SDLK_UNKNOWN,
/* 157 */ SDLK_UNKNOWN,
/* 158 */ SDLK_UNKNOWN,
/* 159 */ SDLK_UNKNOWN,
/* 160 */ SDLK_UNKNOWN,
/* 161 */ SDLK_UNKNOWN,
/* 162 */ SDLK_UNKNOWN,
/* 163 */ SDLK_UNKNOWN,
/* 164 */ SDLK_UNKNOWN,
/* 165 */ SDLK_UNKNOWN,
/* 166 */ SDLK_UNKNOWN,
/* 167 */ SDLK_UNKNOWN,
/* 168 */ SDLK_UNKNOWN,
/* 169 */ SDLK_UNKNOWN,
/* 170 */ SDLK_UNKNOWN,
/* 171 */ SDLK_UNKNOWN,
/* 172 */ SDLK_UNKNOWN,
/* 173 */ SDLK_UNKNOWN,
/* 174 */ SDLK_UNKNOWN,
/* 175 */ SDLK_UNKNOWN,
/* 176 */ SDLK_UNKNOWN,
/* 177 */ SDLK_UNKNOWN,
/* 178 */ SDLK_UNKNOWN,
/* 179 */ SDLK_UNKNOWN,
/* 180 */ SDLK_UNKNOWN,
/* 181 */ SDLK_UNKNOWN,
/* 182 */ SDLK_UNKNOWN,
/* 183 */ SDLK_UNKNOWN,
/* 184 */ SDLK_UNKNOWN,
/* 185 */ SDLK_UNKNOWN,
/* 186 */ SDLK_UNKNOWN,
/* 187 */ SDLK_UNKNOWN,
/* 188 */ SDLK_UNKNOWN,
/* 189 */ SDLK_UNKNOWN,
/* 190 */ SDLK_UNKNOWN,
/* 191 */ SDLK_UNKNOWN,
/* 192 */ SDLK_UNKNOWN,
/* 193 */ SDLK_UNKNOWN,
/* 194 */ SDLK_UNKNOWN,
/* 195 */ SDLK_UNKNOWN,
/* 196 */ SDLK_UNKNOWN,
/* 197 */ SDLK_UNKNOWN,
/* 198 */ SDLK_UNKNOWN,
/* 199 */ SDLK_UNKNOWN,
/* 200 */ SDLK_UNKNOWN,
/* 201 */ SDLK_UNKNOWN,
/* 202 */ SDLK_UNKNOWN,
/* 203 */ SDLK_UNKNOWN,
/* 204 */ SDLK_UNKNOWN,
/* 205 */ SDLK_UNKNOWN,
/* 206 */ SDLK_UNKNOWN,
/* 207 */ SDLK_UNKNOWN,
/* 208 */ SDLK_UNKNOWN,
/* 209 */ SDLK_UNKNOWN,
/* 210 */ SDLK_UNKNOWN,
/* 211 */ SDLK_UNKNOWN,
/* 212 */ SDLK_UNKNOWN,
/* 213 */ SDLK_UNKNOWN,
/* 214 */ SDLK_UNKNOWN,
/* 215 */ SDLK_UNKNOWN,
/* 216 */ SDLK_UNKNOWN,
/* 217 */ SDLK_UNKNOWN,
/* 218 */ SDLK_UNKNOWN,
/* 219 */ SDLK_UNKNOWN,
/* 220 */ SDLK_UNKNOWN,
/* 221 */ SDLK_UNKNOWN,
/* 222 */ SDLK_UNKNOWN,
/* 223 */ SDLK_UNKNOWN,
/* 224 */ SDLK_UNKNOWN,
/* 225 */ SDLK_UNKNOWN,
/* 226 */ SDLK_UNKNOWN,
/* 227 */ SDLK_UNKNOWN,
/* 228 */ SDLK_UNKNOWN,
/* 229 */ SDLK_UNKNOWN,
/* 230 */ SDLK_UNKNOWN,
/* 231 */ SDLK_UNKNOWN,
/* 232 */ SDLK_UNKNOWN,
/* 233 */ SDLK_UNKNOWN,
/* 234 */ SDLK_UNKNOWN,
/* 235 */ SDLK_UNKNOWN,
/* 236 */ SDLK_UNKNOWN,
/* 237 */ SDLK_UNKNOWN,
/* 238 */ SDLK_UNKNOWN,
/* 239 */ SDLK_UNKNOWN,
/* 240 */ SDLK_UNKNOWN,
/* 241 */ SDLK_UNKNOWN,
/* 242 */ SDLK_UNKNOWN,
/* 243 */ SDLK_UNKNOWN,
/* 244 */ SDLK_UNKNOWN,
/* 245 */ SDLK_UNKNOWN,
/* 246 */ SDLK_UNKNOWN,
/* 247 */ SDLK_UNKNOWN,
/* 248 */ SDLK_UNKNOWN,
/* 249 */ SDLK_UNKNOWN,
/* 250 */ SDLK_UNKNOWN,
/* 251 */ SDLK_UNKNOWN,
/* 252 */ SDLK_UNKNOWN,
/* 253 */ SDLK_UNKNOWN,
/* 254 */ SDLK_UNKNOWN,
/* 255 */ SDLK_UNKNOWN
};
/* Found mostly by experimentation with X.org on Linux (Fedora Core 4 and
Ubuntu Dapper) on PC and PPC Mac hardware, some parts (especially about
the "multimedia"/"internet" keys) from various sources on the web.
*/
Jan 9, 2008
Jan 9, 2008
319
320
static SDLKey xorgLinuxKeyCodeToSDLK[KeyCodeTableSize] =
{
Jan 8, 2008
Jan 8, 2008
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
/* 0 */ SDLK_UNKNOWN,
/* 1 */ SDLK_UNKNOWN,
/* 2 */ SDLK_UNKNOWN,
/* 3 */ SDLK_UNKNOWN,
/* 4 */ SDLK_UNKNOWN,
/* 5 */ SDLK_UNKNOWN,
/* 6 */ SDLK_UNKNOWN,
/* 7 */ SDLK_UNKNOWN,
/* 8 */ SDLK_UNKNOWN,
/* 9 */ SDLK_ESCAPE,
/* 10 */ SDLK_1,
/* 11 */ SDLK_2,
/* 12 */ SDLK_3,
/* 13 */ SDLK_4,
/* 14 */ SDLK_5,
/* 15 */ SDLK_6,
/* 16 */ SDLK_7,
/* 17 */ SDLK_8,
/* 18 */ SDLK_9,
/* 19 */ SDLK_0,
/* 20 */ SDLK_HYPHENMINUS,
/* 21 */ SDLK_EQUALS,
/* 22 */ SDLK_BACKSPACE,
/* 23 */ SDLK_TAB,
/* 24 */ SDLK_Q,
/* 25 */ SDLK_W,
/* 26 */ SDLK_E,
/* 27 */ SDLK_R,
/* 28 */ SDLK_T,
/* 29 */ SDLK_Y,
/* 30 */ SDLK_U,
/* 31 */ SDLK_I,
/* 32 */ SDLK_O,
/* 33 */ SDLK_P,
/* 34 */ SDLK_LEFTBRACKET,
/* 35 */ SDLK_RIGHTBRACKET,
/* 36 */ SDLK_RETURN,
/* 37 */ SDLK_LCTRL,
/* 38 */ SDLK_A,
/* 39 */ SDLK_S,
/* 40 */ SDLK_D,
/* 41 */ SDLK_F,
/* 42 */ SDLK_G,
/* 43 */ SDLK_H,
/* 44 */ SDLK_J,
/* 45 */ SDLK_K,
/* 46 */ SDLK_L,
/* 47 */ SDLK_SEMICOLON,
/* 48 */ SDLK_APOSTROPHE,
/* 49 */ SDLK_GRAVE,
/* 50 */ SDLK_LSHIFT,
/* 51 */ SDLK_BACKSLASH,
/* 52 */ SDLK_Z,
/* 53 */ SDLK_X,
/* 54 */ SDLK_C,
/* 55 */ SDLK_V,
/* 56 */ SDLK_B,
/* 57 */ SDLK_N,
/* 58 */ SDLK_M,
/* 59 */ SDLK_COMMA,
/* 60 */ SDLK_PERIOD,
/* 61 */ SDLK_SLASH,
/* 62 */ SDLK_RSHIFT,
/* 63 */ SDLK_KP_MULTIPLY,
/* 64 */ SDLK_LALT,
/* 65 */ SDLK_SPACE,
/* 66 */ SDLK_CAPSLOCK,
/* 67 */ SDLK_F1,
/* 68 */ SDLK_F2,
/* 69 */ SDLK_F3,
/* 70 */ SDLK_F4,
/* 71 */ SDLK_F5,
/* 72 */ SDLK_F6,
/* 73 */ SDLK_F7,
/* 74 */ SDLK_F8,
/* 75 */ SDLK_F9,
/* 76 */ SDLK_F10,
/* 77 */ SDLK_KP_NUMLOCKCLEAR,
/* 78 */ SDLK_SCROLLLOCK,
/* 79 */ SDLK_KP_7,
/* 80 */ SDLK_KP_8,
/* 81 */ SDLK_KP_9,
/* 82 */ SDLK_KP_MINUS,
/* 83 */ SDLK_KP_4,
/* 84 */ SDLK_KP_5,
/* 85 */ SDLK_KP_6,
/* 86 */ SDLK_KP_PLUS,
/* 87 */ SDLK_KP_1,
/* 88 */ SDLK_KP_2,
/* 89 */ SDLK_KP_3,
/* 90 */ SDLK_KP_0,
/* 91 */ SDLK_KP_PERIOD,
/* 92 */ SDLK_SYSREQ,
/* 93 */ SDLK_MODE, /* is translated to XK_Mode_switch by my X server, but I have no keyboard that generates this code, so I'm not sure if this is correct */
/* 94 */ SDLK_NONUSBACKSLASH,
/* 95 */ SDLK_F11,
/* 96 */ SDLK_F12,
/* 97 */ SDLK_HOME,
/* 98 */ SDLK_UP,
/* 99 */ SDLK_PAGEUP,
/* 100 */ SDLK_LEFT,
/* 101 */ SDLK_BRIGHTNESSDOWN, /* on PowerBook G4 */
/* 102 */ SDLK_RIGHT,
/* 103 */ SDLK_END,
/* 104 */ SDLK_DOWN,
/* 105 */ SDLK_PAGEDOWN,
/* 106 */ SDLK_INSERT,
/* 107 */ SDLK_DELETE,
/* 108 */ SDLK_KP_ENTER,
/* 109 */ SDLK_RCTRL,
/* 110 */ SDLK_PAUSE,
/* 111 */ SDLK_PRINTSCREEN,
/* 112 */ SDLK_KP_DIVIDE,
/* 113 */ SDLK_RALT,
/* 114 */ SDLK_UNKNOWN,
/* 115 */ SDLK_LMETA,
/* 116 */ SDLK_RMETA,
/* 117 */ SDLK_APPLICATION,
/* 118 */ SDLK_F13,
/* 119 */ SDLK_F14,
/* 120 */ SDLK_F15,
/* 121 */ SDLK_F16,
/* 122 */ SDLK_F17,
/* 123 */ SDLK_UNKNOWN,
/* 124 */ SDLK_UNKNOWN, /* is translated to XK_ISO_Level3_Shift by my X server, but I have no keyboard that generates this code, so I don't know what the correct SDLK_* for it is */
/* 125 */ SDLK_UNKNOWN,
/* 126 */ SDLK_KP_EQUALS,
/* 127 */ SDLK_UNKNOWN,
/* 128 */ SDLK_UNKNOWN,
/* 129 */ SDLK_UNKNOWN,
/* 130 */ SDLK_UNKNOWN,
/* 131 */ SDLK_UNKNOWN,
/* 132 */ SDLK_UNKNOWN,
/* 133 */ SDLK_INTERNATIONAL3, /* Yen */
/* 134 */ SDLK_UNKNOWN,
/* 135 */ SDLK_AGAIN,
/* 136 */ SDLK_UNDO,
/* 137 */ SDLK_UNKNOWN,
/* 138 */ SDLK_UNKNOWN,
/* 139 */ SDLK_UNKNOWN,
/* 140 */ SDLK_UNKNOWN,
/* 141 */ SDLK_UNKNOWN,
/* 142 */ SDLK_UNKNOWN,
/* 143 */ SDLK_UNKNOWN,
/* 144 */ SDLK_AUDIOPREV,
/* 145 */ SDLK_UNKNOWN,
/* 146 */ SDLK_UNKNOWN,
/* 147 */ SDLK_UNKNOWN,
/* 148 */ SDLK_UNKNOWN,
/* 149 */ SDLK_UNKNOWN,
/* 150 */ SDLK_UNKNOWN,
/* 151 */ SDLK_UNKNOWN,
/* 152 */ SDLK_UNKNOWN,
/* 153 */ SDLK_AUDIONEXT,
/* 154 */ SDLK_UNKNOWN,
/* 155 */ SDLK_UNKNOWN,
/* 156 */ SDLK_UNKNOWN,
/* 157 */ SDLK_KP_EQUALS, /* on PowerBook G4 */
/* 158 */ SDLK_UNKNOWN,
/* 159 */ SDLK_UNKNOWN,
/* 160 */ SDLK_MUTE,
/* 161 */ SDLK_CALC,
/* 162 */ SDLK_AUDIOPLAY,
/* 163 */ SDLK_UNKNOWN,
/* 164 */ SDLK_AUDIOSTOP,
/* 165 */ SDLK_UNKNOWN,
/* 166 */ SDLK_UNKNOWN,
/* 167 */ SDLK_UNKNOWN,
/* 168 */ SDLK_UNKNOWN,
/* 169 */ SDLK_UNKNOWN,
/* 170 */ SDLK_UNKNOWN,
/* 171 */ SDLK_UNKNOWN,
/* 172 */ SDLK_UNKNOWN,
/* 173 */ SDLK_UNKNOWN,
/* 174 */ SDLK_VOLUMEDOWN,
/* 175 */ SDLK_UNKNOWN,
/* 176 */ SDLK_VOLUMEUP,
/* 177 */ SDLK_UNKNOWN,
/* 178 */ SDLK_WWW,
/* 179 */ SDLK_UNKNOWN,
/* 180 */ SDLK_UNKNOWN,
/* 181 */ SDLK_UNKNOWN,
/* 182 */ SDLK_UNKNOWN,
/* 183 */ SDLK_UNKNOWN,
/* 184 */ SDLK_UNKNOWN,
/* 185 */ SDLK_UNKNOWN,
/* 186 */ SDLK_UNKNOWN,
/* 187 */ SDLK_HELP,
/* 188 */ SDLK_UNKNOWN,
/* 189 */ SDLK_UNKNOWN,
/* 190 */ SDLK_UNKNOWN,
/* 191 */ SDLK_UNKNOWN,
/* 192 */ SDLK_UNKNOWN,
/* 193 */ SDLK_UNKNOWN,
/* 194 */ SDLK_UNKNOWN,
/* 195 */ SDLK_UNKNOWN,
/* 196 */ SDLK_UNKNOWN,
/* 197 */ SDLK_UNKNOWN,
/* 198 */ SDLK_UNKNOWN,
/* 199 */ SDLK_UNKNOWN,
/* 200 */ SDLK_UNKNOWN,
/* 201 */ SDLK_UNKNOWN,
/* 202 */ SDLK_UNKNOWN,
/* 203 */ SDLK_UNKNOWN,
/* 204 */ SDLK_EJECT, /* on PowerBook G4 */
/* 205 */ SDLK_UNKNOWN,
/* 206 */ SDLK_UNKNOWN,
/* 207 */ SDLK_UNKNOWN,
/* 208 */ SDLK_UNKNOWN,
/* 209 */ SDLK_UNKNOWN,
/* 210 */ SDLK_UNKNOWN,
/* 211 */ SDLK_UNKNOWN,
/* 212 */ SDLK_BRIGHTNESSUP, /* on PowerBook G4 */
/* 213 */ SDLK_UNKNOWN,
/* 214 */ SDLK_DISPLAYSWITCH, /* on PowerBook G4 */
/* 215 */ SDLK_KBDILLUMTOGGLE,
/* 216 */ SDLK_KBDILLUMDOWN,
/* 217 */ SDLK_KBDILLUMUP,
/* 218 */ SDLK_UNKNOWN,
/* 219 */ SDLK_UNKNOWN,
/* 220 */ SDLK_UNKNOWN,
/* 221 */ SDLK_UNKNOWN,
/* 222 */ SDLK_POWER,
/* 223 */ SDLK_SLEEP,
/* 224 */ SDLK_UNKNOWN,
/* 225 */ SDLK_UNKNOWN,
/* 226 */ SDLK_UNKNOWN,
/* 227 */ SDLK_UNKNOWN,
/* 228 */ SDLK_UNKNOWN,
/* 229 */ SDLK_SEARCH,
/* 230 */ SDLK_BOOKMARKS,
/* 231 */ SDLK_BROWSERRELOAD,
/* 232 */ SDLK_BROWSERSTOP,
/* 233 */ SDLK_BROWSERFORWARD,
/* 234 */ SDLK_BROWSERBACK,
/* 235 */ SDLK_COMPUTER,
/* 236 */ SDLK_EMAIL,
/* 237 */ SDLK_MEDIA,
/* 238 */ SDLK_UNKNOWN,
/* 239 */ SDLK_UNKNOWN,
/* 240 */ SDLK_UNKNOWN,
/* 241 */ SDLK_UNKNOWN,
/* 242 */ SDLK_UNKNOWN,
/* 243 */ SDLK_UNKNOWN,
/* 244 */ SDLK_UNKNOWN,
/* 245 */ SDLK_UNKNOWN,
/* 246 */ SDLK_UNKNOWN,
/* 247 */ SDLK_UNKNOWN,
/* 248 */ SDLK_UNKNOWN,
/* 249 */ SDLK_UNKNOWN,
/* 250 */ SDLK_UNKNOWN,
/* 251 */ SDLK_UNKNOWN,
/* 252 */ SDLK_UNKNOWN,
/* 253 */ SDLK_UNKNOWN,
/* 254 */ SDLK_UNKNOWN,
/* 255 */ SDLK_UNKNOWN
};
/*---------------------------------------------------------------------------*/
/* Used by X11_KeySymToSDLKey(). This is a hybrid of a KeySym-to-layout-key
mapping (needed in X11_GetLayoutKey()) and a fallback KeySym-to-physical-key
mapping under the assumption of a US keyboard layout (needed in
X11_InitKeyboard()). If for a given KeySym...
- the layout and physical codes are the same (must be an SDLK_ constant):
there is one entry,
- the layout and physical codes differ: there are two entries, with the
layout one first,
- there is only a physical code in the table (must be an SDLK_ constant):
it's marked by X11_KEY_PHYSICAL_ONLY_BIT (this is the case when the layout
key code is handled by KeySymToUcs4()),
- there is only a layout code in the table (can't be an SDLK_ constant):
recognizable by the absence of SDL_KEY_CAN_BE_PHYSICAL_BIT.
This list is sorted by KeySym to allow a binary search.
*/
#define X11_KEY_PHYSICAL_ONLY_BIT SDL_KEY_LAYOUT_SPECIAL_BIT
/* SDL_KEY_LAYOUT_SPECIAL_BIT cannot possibly occur in an SDLK_ constant, so we may repurpose that bit for our own use. */
static struct
{
KeySym sym;
SDLKey key;
Jan 9, 2008
Jan 9, 2008
602
603
} keySymToSDLKey[KeyCodeTableSize] =
{
Jan 8, 2008
Jan 8, 2008
604
/* 0x00xx */
Jan 9, 2008
Jan 9, 2008
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
{XK_space, SDLK_SPACE},
{XK_apostrophe, SDLK_APOSTROPHE | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_comma, SDLK_COMMA | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_minus, SDLK_HYPHENMINUS | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_period, SDLK_PERIOD | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_slash, SDLK_SLASH | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_0, SDLK_0 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_1, SDLK_1 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_2, SDLK_2 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_3, SDLK_3 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_4, SDLK_4 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_5, SDLK_5 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_6, SDLK_6 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_7, SDLK_7 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_8, SDLK_8 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_9, SDLK_9 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_semicolon, SDLK_SEMICOLON | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_less, SDLK_NONUSBACKSLASH | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_equal, SDLK_EQUALS | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_bracketleft, SDLK_LEFTBRACKET | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_backslash, SDLK_BACKSLASH | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_bracketright, SDLK_RIGHTBRACKET | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_grave, SDLK_GRAVE | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_a, SDLK_A | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_b, SDLK_B | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_c, SDLK_C | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_d, SDLK_D | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_e, SDLK_E | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_f, SDLK_F | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_g, SDLK_G | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_h, SDLK_H | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_i, SDLK_I | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_j, SDLK_J | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_k, SDLK_K | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_l, SDLK_L | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_m, SDLK_M | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_n, SDLK_N | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_o, SDLK_O | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_p, SDLK_P | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_q, SDLK_Q | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_r, SDLK_R | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_s, SDLK_S | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_t, SDLK_T | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_u, SDLK_U | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_v, SDLK_V | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_w, SDLK_W | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_x, SDLK_X | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_y, SDLK_Y | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_z, SDLK_Z | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_section, SDLK_NONUSBACKSLASH | X11_KEY_PHYSICAL_ONLY_BIT},
Jan 8, 2008
Jan 8, 2008
655
/* 0xFExx */
Jan 9, 2008
Jan 9, 2008
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
{XK_ISO_Level3_Shift, SDLK_RALT},
{XK_dead_grave, '`'},
{XK_dead_acute, 0xB4},
{XK_dead_circumflex, '^'},
{XK_dead_tilde, '~'},
{XK_dead_macron, 0xAF},
{XK_dead_breve, 0x2D8},
{XK_dead_abovedot, 0x2D9},
{XK_dead_diaeresis, 0xA8},
{XK_dead_abovering, 0x2DA},
{XK_dead_doubleacute, 0x2DD},
{XK_dead_caron, 0x2C7},
{XK_dead_cedilla, 0xB8},
{XK_dead_ogonek, 0x2DB},
{XK_dead_iota, 0x3B9},
{XK_dead_voiced_sound, 0x309B},
{XK_dead_semivoiced_sound, 0x309C},
{XK_dead_belowdot, 0xB7}, /* that's actually MIDDLE DOT,
but I haven't found a
non-combining DOT BELOW
XK_dead_hook, XK_dead_horn: I
haven't found non-combining
HOOK and HORN characters */
/* 0xFFxx */
{XK_BackSpace, SDLK_BACKSPACE},
{XK_Tab, SDLK_TAB},
{XK_Return, SDLK_RETURN},
{XK_Pause, SDLK_PAUSE},
{XK_Scroll_Lock, SDLK_SCROLLLOCK},
{XK_Escape, SDLK_ESCAPE},
{XK_Home, SDLK_HOME},
{XK_Left, SDLK_LEFT},
{XK_Up, SDLK_UP},
{XK_Right, SDLK_RIGHT},
{XK_Down, SDLK_DOWN},
{XK_Page_Up, SDLK_PAGEUP},
{XK_Page_Down, SDLK_PAGEDOWN},
{XK_End, SDLK_END},
{XK_Print, SDLK_PRINTSCREEN},
{XK_Insert, SDLK_INSERT},
{XK_Menu, SDLK_APPLICATION},
{XK_Break, SDLK_PAUSE},
{XK_Mode_switch, SDLK_MODE},
{XK_Num_Lock, SDLK_KP_NUMLOCKCLEAR},
{XK_KP_Enter, SDLK_KP_ENTER},
{XK_KP_Home, SDLK_KP_7 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_KP_Left, SDLK_KP_4 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_KP_Up, SDLK_KP_8 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_KP_Right, SDLK_KP_6 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_KP_Down, SDLK_KP_2 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_KP_Page_Up, SDLK_KP_9 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_KP_Page_Down, SDLK_KP_3 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_KP_End, SDLK_KP_1 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_KP_Begin, SDLK_KP_5 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_KP_Insert, SDLK_KP_0 | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_KP_Delete, SDLK_KP_PERIOD | X11_KEY_PHYSICAL_ONLY_BIT},
{XK_KP_Multiply, '*'},
{XK_KP_Multiply, SDLK_KP_MULTIPLY},
{XK_KP_Add, '+'},
{XK_KP_Add, SDLK_KP_PLUS},
{XK_KP_Separator, '.'},
{XK_KP_Separator, SDLK_KP_PERIOD},
{XK_KP_Subtract, '-'},
{XK_KP_Subtract, SDLK_KP_MINUS},
{XK_KP_Decimal, '.'},
{XK_KP_Decimal, SDLK_KP_PERIOD},
{XK_KP_Divide, '/'},
{XK_KP_Divide, SDLK_KP_DIVIDE},
{XK_KP_0, '0'},
{XK_KP_0, SDLK_KP_0},
{XK_KP_1, '1'},
{XK_KP_1, SDLK_KP_1},
{XK_KP_2, '2'},
{XK_KP_2, SDLK_KP_2},
{XK_KP_3, '3'},
{XK_KP_3, SDLK_KP_3},
{XK_KP_4, '4'},
{XK_KP_4, SDLK_KP_4},
{XK_KP_5, '5'},
{XK_KP_5, SDLK_KP_5},
{XK_KP_6, '6'},
{XK_KP_6, SDLK_KP_6},
{XK_KP_7, '7'},
{XK_KP_7, SDLK_KP_7},
{XK_KP_8, '8'},
{XK_KP_8, SDLK_KP_8},
{XK_KP_9, '9'},
{XK_KP_9, SDLK_KP_9},
{XK_KP_Equal, '='},
{XK_KP_Equal, SDLK_KP_EQUALS},
{XK_F1, SDLK_F1},
{XK_F2, SDLK_F2},
{XK_F3, SDLK_F3},
{XK_F4, SDLK_F4},
{XK_F5, SDLK_F5},
{XK_F6, SDLK_F6},
{XK_F7, SDLK_F7},
{XK_F8, SDLK_F8},
{XK_F9, SDLK_F9},
{XK_F10, SDLK_F10},
{XK_F11, SDLK_F11},
{XK_F12, SDLK_F12},
{XK_F13, SDLK_F13},
{XK_F14, SDLK_F14},
{XK_F15, SDLK_F15},
{XK_F16, SDLK_F16},
{XK_F17, SDLK_F17},
{XK_F18, SDLK_F18},
{XK_F19, SDLK_F19},
{XK_F20, SDLK_F20},
{XK_F21, SDLK_F21},
{XK_F22, SDLK_F22},
{XK_F23, SDLK_F23},
{XK_F24, SDLK_F24},
{XK_Shift_L, SDLK_LSHIFT},
{XK_Shift_R, SDLK_RSHIFT},
{XK_Control_L, SDLK_LCTRL},
{XK_Control_R, SDLK_RCTRL},
{XK_Caps_Lock, SDLK_CAPSLOCK},
{XK_Shift_Lock, SDLK_CAPSLOCK},
{XK_Meta_L, SDLK_LMETA},
{XK_Meta_R, SDLK_RMETA},
{XK_Alt_L, SDLK_LALT},
{XK_Alt_R, SDLK_RALT},
{XK_Super_L, SDLK_LMETA},
{XK_Super_R, SDLK_RMETA},
{XK_Hyper_L, SDLK_LMETA},
{XK_Hyper_R, SDLK_RMETA},
{XK_Delete, SDLK_DELETE},
{0x1000003, SDLK_KP_ENTER} /* keyboard enter on Mac OS X */
Jan 8, 2008
Jan 8, 2008
786
787
};
Jan 9, 2008
Jan 9, 2008
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
/* *INDENT-ON* */
/*
Used for two purposes: - by X11_GetLayoutKey(), with physical =
false, to convert a KeySym to the corresponding layout key code
(SDLK_ ones and some character ones - most character KeySyms are
handled by X11_KeySymToUcs4() after this function returns
SDLK_UNKNOWN for them). - by X11_InitKeyboard(), with physical =
true, to build a makeshift translation table based on the KeySyms
when none of the predefined KeyCode- to-SDLKey tables fits. This
is *not* correct anywhere but on a US layout, since the
translation table deals with physical key codes, while the X11
KeySym corresponds to our concept of a layout key code, but it's
better than nothing.
*/
Jan 8, 2008
Jan 8, 2008
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
static SDLKey
X11_KeySymToSDLKey(KeySym sym, SDL_bool physical)
{
/* Do a binary search for sym in the keySymToSDLKey table */
SDLKey key = SDLK_UNKNOWN;
int start = -1;
int end = SDL_arraysize(keySymToSDLKey);
int i;
/* Invariant: keySymToSDLKey[start].sym < sym <
keySymToSDLKey[end].sym (imagine ...[-1] = -inf and
...[arraysize] = inf, these entries needn't be there in reality
because they're never accessed) */
while (end > start + 1) {
i = (start + end) / 2;
if (keySymToSDLKey[i].sym == sym) {
/* found an entry, if it's the second of two back up to the first */
if (keySymToSDLKey[i - 1].sym == sym)
i--;
/* if there are two, the physical one is the second */
if (physical && keySymToSDLKey[i + 1].sym == sym)
i++;
key = keySymToSDLKey[i].key;
break;
} else if (keySymToSDLKey[i].sym < sym)
start = i;
else
end = i;
}
/* if we're being asked for a layout key code, but the table only
has a physical one, or vice versa, return SDLK_UNKNOWN) */
if (!physical && ((key & X11_KEY_PHYSICAL_ONLY_BIT) != 0)
|| physical && ((key & SDL_KEY_CAN_BE_PHYSICAL_BIT) == 0))
key = SDLK_UNKNOWN;
key &= ~X11_KEY_PHYSICAL_ONLY_BIT;
return key;
}
int
Jul 26, 2006
Jul 26, 2006
844
845
846
847
X11_InitKeyboard(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
SDL_Keyboard keyboard;
Jan 8, 2008
Jan 8, 2008
848
849
850
851
852
853
854
855
856
857
858
859
860
SDLKey **table;
SDLKey *foundTable;
int i;
int code;
SDLKey sdlkey;
/* A random collection of KeySym/SDLKey pairs that should be valid
in any keyboard layout (if this isn't the case on yours,
please adjust). Using XKeysymToKeycode on these KeySyms
creates a "fingerprint" of the X server's key-to-KeyCode
mapping which is then matched against all our predefined
KeyCodeToSDLK tables to find the right one (if any).
*/
Jan 9, 2008
Jan 9, 2008
861
862
/* *INDENT-ON* */
Jan 8, 2008
Jan 8, 2008
863
864
865
866
867
868
869
870
871
872
873
struct
{
KeySym sym;
SDLKey key;
} fingerprint[] = {
{
XK_Tab, SDLK_TAB}, {
XK_Return, SDLK_RETURN}, {
XK_Escape, SDLK_ESCAPE}, {
XK_space, SDLK_SPACE}
};
Jan 9, 2008
Jan 9, 2008
874
/* *INDENT-OFF* */
Jul 26, 2006
Jul 26, 2006
875
876
877
SDL_zero(keyboard);
data->keyboard = SDL_AddKeyboard(&keyboard, -1);
Jan 8, 2008
Jan 8, 2008
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
/* Determine which X11 KeyCode to SDL physical key code table to use */
foundTable = NULL;
table = keyCodeToSDLKeyTables;
while ((NULL == foundTable) && (NULL != (*table))) {
foundTable = *table;
for (i = 0; i < SDL_arraysize(fingerprint); i++) {
code = XKeysymToKeycode(data->display, fingerprint[i].sym);
if ((code != 0) && ((*table)[code] != fingerprint[i].key)) {
foundTable = NULL;
break;
}
}
table++;
}
if (NULL != foundTable) {
/* Found a suitable one among the predefined tables */
data->keyCodeToSDLKTable = foundTable;
} else {
/* No suitable table found - build a makeshift table based on
the KeySyms, assuming a US keyboard layout */
#if 1
fprintf(stderr,
"The key codes of your X server are unknown to SDL. Keys may not be recognized properly. To help get this fixed, report this to the SDL mailing list <sdl@libsdl.org> or to Christian Walther <cwalther@gmx.ch>.\n");
#endif
data->keyCodeToSDLKTable =
SDL_malloc(SDL_arraysize(xorgLinuxKeyCodeToSDLK));
if (data->keyCodeToSDLKTable == NULL) {
SDL_OutOfMemory();
return -1;
}
for (code = SDL_arraysize(xorgLinuxKeyCodeToSDLK); code >= 0; code--) {
data->keyCodeToSDLKTable[code] =
X11_KeySymToSDLKey(XKeycodeToKeysym(data->display, code, 0),
SDL_TRUE);
}
}
/* Set some non-default key names */
for (code = 0; code < SDL_arraysize(xorgLinuxKeyCodeToSDLK); code++) {
sdlkey = data->keyCodeToSDLKTable[code];
switch (sdlkey) {
/* The SDLK_*META keys are used as XK_Meta_* by some X
servers, as XK_Super_* by others */
case SDLK_LMETA:
case SDLK_RMETA:
switch (XKeycodeToKeysym(data->display, code, 0)) {
/* nothing to do for XK_Meta_* because that's already the default name */
case XK_Super_L:
SDL_SetKeyName(sdlkey, "left super");
break;
case XK_Super_R:
SDL_SetKeyName(sdlkey, "right super");
break;
}
break;
}
}
SDL_SetKeyName(SDLK_APPLICATION, "menu");
return 0;
}
SDLKey
X11_GetLayoutKey(_THIS, SDLKey physicalKey)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
int code = 0;
KeySym sym;
SDLKey layoutKey;
switch (physicalKey) {
case SDLK_UNKNOWN:
return physicalKey;
/* Shortcut handling of keypad numbers because on my PC their
primary KeySyms are not the numbers that I want but
XK_KP_Home, XK_KP_Up etc. The downside is that this gets us
latin numerals even on e.g. an Arabic layout. */
case SDLK_KP_1:
return '1';
case SDLK_KP_2:
return '2';
case SDLK_KP_3:
return '3';
case SDLK_KP_4:
return '4';
case SDLK_KP_5:
return '5';
case SDLK_KP_6:
return '6';
case SDLK_KP_7:
return '7';
case SDLK_KP_8:
return '8';
case SDLK_KP_9:
return '9';
case SDLK_KP_0:
return '0';
case SDLK_KP_PERIOD:
return '.';
default:
break; /* just to avoid a compiler warning */
}
/* Look up physicalKey to get an X11 KeyCode - linear search isn't
terribly efficient, this might have to be optimized. */
Jan 9, 2008
Jan 9, 2008
989
990
while ((code < SDL_arraysize(xorgLinuxKeyCodeToSDLK)) &&
(physicalKey != data->keyCodeToSDLKTable[code])) {
Jan 8, 2008
Jan 8, 2008
991
992
993
994
995
996
997
998
999
1000
code++;
}
if (code == SDL_arraysize(xorgLinuxKeyCodeToSDLK)) {
return physicalKey;
}
/* Get the corresponding KeySym - this is where the keyboard
layout comes into play */
sym = XKeycodeToKeysym(data->display, code, 0);