SDL  2.0
SDL_x11keyboard.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2020 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 #include "../../SDL_internal.h"
22 
23 #if SDL_VIDEO_DRIVER_X11
24 
25 #include "SDL_x11video.h"
26 
27 #include "../../events/SDL_keyboard_c.h"
28 #include "../../events/scancodes_darwin.h"
29 #include "../../events/scancodes_xfree86.h"
30 
31 #include <X11/keysym.h>
32 #include <X11/XKBlib.h>
33 
34 #include "imKStoUCS.h"
35 
36 #ifdef X_HAVE_UTF8_STRING
37 #include <locale.h>
38 #endif
39 
40 /* *INDENT-OFF* */
41 static const struct {
42  KeySym keysym;
43  SDL_Scancode scancode;
44 } KeySymToSDLScancode[] = {
45  { XK_Return, SDL_SCANCODE_RETURN },
46  { XK_Escape, SDL_SCANCODE_ESCAPE },
47  { XK_BackSpace, SDL_SCANCODE_BACKSPACE },
48  { XK_Tab, SDL_SCANCODE_TAB },
49  { XK_Caps_Lock, SDL_SCANCODE_CAPSLOCK },
50  { XK_F1, SDL_SCANCODE_F1 },
51  { XK_F2, SDL_SCANCODE_F2 },
52  { XK_F3, SDL_SCANCODE_F3 },
53  { XK_F4, SDL_SCANCODE_F4 },
54  { XK_F5, SDL_SCANCODE_F5 },
55  { XK_F6, SDL_SCANCODE_F6 },
56  { XK_F7, SDL_SCANCODE_F7 },
57  { XK_F8, SDL_SCANCODE_F8 },
58  { XK_F9, SDL_SCANCODE_F9 },
59  { XK_F10, SDL_SCANCODE_F10 },
60  { XK_F11, SDL_SCANCODE_F11 },
61  { XK_F12, SDL_SCANCODE_F12 },
62  { XK_Print, SDL_SCANCODE_PRINTSCREEN },
63  { XK_Scroll_Lock, SDL_SCANCODE_SCROLLLOCK },
64  { XK_Pause, SDL_SCANCODE_PAUSE },
65  { XK_Insert, SDL_SCANCODE_INSERT },
66  { XK_Home, SDL_SCANCODE_HOME },
67  { XK_Prior, SDL_SCANCODE_PAGEUP },
68  { XK_Delete, SDL_SCANCODE_DELETE },
69  { XK_End, SDL_SCANCODE_END },
70  { XK_Next, SDL_SCANCODE_PAGEDOWN },
71  { XK_Right, SDL_SCANCODE_RIGHT },
72  { XK_Left, SDL_SCANCODE_LEFT },
73  { XK_Down, SDL_SCANCODE_DOWN },
74  { XK_Up, SDL_SCANCODE_UP },
75  { XK_Num_Lock, SDL_SCANCODE_NUMLOCKCLEAR },
76  { XK_KP_Divide, SDL_SCANCODE_KP_DIVIDE },
77  { XK_KP_Multiply, SDL_SCANCODE_KP_MULTIPLY },
78  { XK_KP_Subtract, SDL_SCANCODE_KP_MINUS },
79  { XK_KP_Add, SDL_SCANCODE_KP_PLUS },
80  { XK_KP_Enter, SDL_SCANCODE_KP_ENTER },
81  { XK_KP_Delete, SDL_SCANCODE_KP_PERIOD },
82  { XK_KP_End, SDL_SCANCODE_KP_1 },
83  { XK_KP_Down, SDL_SCANCODE_KP_2 },
84  { XK_KP_Next, SDL_SCANCODE_KP_3 },
85  { XK_KP_Left, SDL_SCANCODE_KP_4 },
86  { XK_KP_Begin, SDL_SCANCODE_KP_5 },
87  { XK_KP_Right, SDL_SCANCODE_KP_6 },
88  { XK_KP_Home, SDL_SCANCODE_KP_7 },
89  { XK_KP_Up, SDL_SCANCODE_KP_8 },
90  { XK_KP_Prior, SDL_SCANCODE_KP_9 },
91  { XK_KP_Insert, SDL_SCANCODE_KP_0 },
92  { XK_KP_Decimal, SDL_SCANCODE_KP_PERIOD },
93  { XK_KP_1, SDL_SCANCODE_KP_1 },
94  { XK_KP_2, SDL_SCANCODE_KP_2 },
95  { XK_KP_3, SDL_SCANCODE_KP_3 },
96  { XK_KP_4, SDL_SCANCODE_KP_4 },
97  { XK_KP_5, SDL_SCANCODE_KP_5 },
98  { XK_KP_6, SDL_SCANCODE_KP_6 },
99  { XK_KP_7, SDL_SCANCODE_KP_7 },
100  { XK_KP_8, SDL_SCANCODE_KP_8 },
101  { XK_KP_9, SDL_SCANCODE_KP_9 },
102  { XK_KP_0, SDL_SCANCODE_KP_0 },
103  { XK_KP_Decimal, SDL_SCANCODE_KP_PERIOD },
104  { XK_Hyper_R, SDL_SCANCODE_APPLICATION },
105  { XK_KP_Equal, SDL_SCANCODE_KP_EQUALS },
106  { XK_F13, SDL_SCANCODE_F13 },
107  { XK_F14, SDL_SCANCODE_F14 },
108  { XK_F15, SDL_SCANCODE_F15 },
109  { XK_F16, SDL_SCANCODE_F16 },
110  { XK_F17, SDL_SCANCODE_F17 },
111  { XK_F18, SDL_SCANCODE_F18 },
112  { XK_F19, SDL_SCANCODE_F19 },
113  { XK_F20, SDL_SCANCODE_F20 },
114  { XK_F21, SDL_SCANCODE_F21 },
115  { XK_F22, SDL_SCANCODE_F22 },
116  { XK_F23, SDL_SCANCODE_F23 },
117  { XK_F24, SDL_SCANCODE_F24 },
118  { XK_Execute, SDL_SCANCODE_EXECUTE },
119  { XK_Help, SDL_SCANCODE_HELP },
120  { XK_Menu, SDL_SCANCODE_MENU },
121  { XK_Select, SDL_SCANCODE_SELECT },
122  { XK_Cancel, SDL_SCANCODE_STOP },
123  { XK_Redo, SDL_SCANCODE_AGAIN },
124  { XK_Undo, SDL_SCANCODE_UNDO },
125  { XK_Find, SDL_SCANCODE_FIND },
126  { XK_KP_Separator, SDL_SCANCODE_KP_COMMA },
127  { XK_Sys_Req, SDL_SCANCODE_SYSREQ },
128  { XK_Control_L, SDL_SCANCODE_LCTRL },
129  { XK_Shift_L, SDL_SCANCODE_LSHIFT },
130  { XK_Alt_L, SDL_SCANCODE_LALT },
131  { XK_Meta_L, SDL_SCANCODE_LGUI },
132  { XK_Super_L, SDL_SCANCODE_LGUI },
133  { XK_Control_R, SDL_SCANCODE_RCTRL },
134  { XK_Shift_R, SDL_SCANCODE_RSHIFT },
135  { XK_Alt_R, SDL_SCANCODE_RALT },
136  { XK_ISO_Level3_Shift, SDL_SCANCODE_RALT },
137  { XK_Meta_R, SDL_SCANCODE_RGUI },
138  { XK_Super_R, SDL_SCANCODE_RGUI },
139  { XK_Mode_switch, SDL_SCANCODE_MODE },
140  { XK_period, SDL_SCANCODE_PERIOD },
141  { XK_comma, SDL_SCANCODE_COMMA },
142  { XK_slash, SDL_SCANCODE_SLASH },
143  { XK_backslash, SDL_SCANCODE_BACKSLASH },
144  { XK_minus, SDL_SCANCODE_MINUS },
145  { XK_equal, SDL_SCANCODE_EQUALS },
146  { XK_space, SDL_SCANCODE_SPACE },
147  { XK_grave, SDL_SCANCODE_GRAVE },
148  { XK_apostrophe, SDL_SCANCODE_APOSTROPHE },
149  { XK_bracketleft, SDL_SCANCODE_LEFTBRACKET },
150  { XK_bracketright, SDL_SCANCODE_RIGHTBRACKET },
151 };
152 
153 static const struct
154 {
155  SDL_Scancode const *table;
156  int table_size;
157 } scancode_set[] = {
162 };
163 /* *INDENT-OFF* */
164 
165 /* This function only works for keyboards in US QWERTY layout */
166 static SDL_Scancode
167 X11_KeyCodeToSDLScancode(_THIS, KeyCode keycode)
168 {
169  KeySym keysym;
170  int i;
171 
172  keysym = X11_KeyCodeToSym(_this, keycode, 0);
173  if (keysym == NoSymbol) {
174  return SDL_SCANCODE_UNKNOWN;
175  }
176 
177  if (keysym >= XK_a && keysym <= XK_z) {
178  return SDL_SCANCODE_A + (keysym - XK_a);
179  }
180  if (keysym >= XK_A && keysym <= XK_Z) {
181  return SDL_SCANCODE_A + (keysym - XK_A);
182  }
183 
184  if (keysym == XK_0) {
185  return SDL_SCANCODE_0;
186  }
187  if (keysym >= XK_1 && keysym <= XK_9) {
188  return SDL_SCANCODE_1 + (keysym - XK_1);
189  }
190 
191  for (i = 0; i < SDL_arraysize(KeySymToSDLScancode); ++i) {
192  if (keysym == KeySymToSDLScancode[i].keysym) {
193  return KeySymToSDLScancode[i].scancode;
194  }
195  }
196  return SDL_SCANCODE_UNKNOWN;
197 }
198 
199 static Uint32
200 X11_KeyCodeToUcs4(_THIS, KeyCode keycode, unsigned char group)
201 {
202  KeySym keysym = X11_KeyCodeToSym(_this, keycode, group);
203 
204  if (keysym == NoSymbol) {
205  return 0;
206  }
207 
208  return X11_KeySymToUcs4(keysym);
209 }
210 
211 KeySym
212 X11_KeyCodeToSym(_THIS, KeyCode keycode, unsigned char group)
213 {
215  KeySym keysym;
216 
218  if (data->xkb) {
219  int num_groups = XkbKeyNumGroups(data->xkb, keycode);
220  unsigned char info = XkbKeyGroupInfo(data->xkb, keycode);
221 
222  if (num_groups && group >= num_groups) {
223 
224  int action = XkbOutOfRangeGroupAction(info);
225 
226  if (action == XkbRedirectIntoRange) {
227  if ((group = XkbOutOfRangeGroupNumber(info)) >= num_groups) {
228  group = 0;
229  }
230  } else if (action == XkbClampIntoRange) {
231  group = num_groups - 1;
232  } else {
233  group %= num_groups;
234  }
235  }
236  keysym = X11_XkbKeycodeToKeysym(data->display, keycode, group, 0);
237  } else {
238  keysym = X11_XKeycodeToKeysym(data->display, keycode, 0);
239  }
240 #else
241  keysym = X11_XKeycodeToKeysym(data->display, keycode, 0);
242 #endif
243 
244  return keysym;
245 }
246 
247 int
249 {
251  int i = 0;
252  int j = 0;
253  int min_keycode, max_keycode;
254  struct {
255  SDL_Scancode scancode;
256  KeySym keysym;
257  int value;
258  } fingerprint[] = {
259  { SDL_SCANCODE_HOME, XK_Home, 0 },
260  { SDL_SCANCODE_PAGEUP, XK_Prior, 0 },
261  { SDL_SCANCODE_UP, XK_Up, 0 },
262  { SDL_SCANCODE_LEFT, XK_Left, 0 },
263  { SDL_SCANCODE_DELETE, XK_Delete, 0 },
264  { SDL_SCANCODE_KP_ENTER, XK_KP_Enter, 0 },
265  };
266  int best_distance;
267  int best_index;
268  int distance;
269  Bool xkb_repeat = 0;
270  XKeyboardState values = { .global_auto_repeat = AutoRepeatModeOff };
271 
272  X11_XGetKeyboardControl(data->display, &values);
273  if (values.global_auto_repeat != AutoRepeatModeOn)
274  X11_XAutoRepeatOn(data->display);
275 
276 #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
277  {
278  int xkb_major = XkbMajorVersion;
279  int xkb_minor = XkbMinorVersion;
280 
281  if (X11_XkbQueryExtension(data->display, NULL, NULL, NULL, &xkb_major, &xkb_minor)) {
282  data->xkb = X11_XkbGetMap(data->display, XkbAllClientInfoMask, XkbUseCoreKbd);
283  }
284 
285  /* This will remove KeyRelease events for held keys */
286  X11_XkbSetDetectableAutoRepeat(data->display, True, &xkb_repeat);
287  }
288 #endif
289 
290  /* Open a connection to the X input manager */
291 #ifdef X_HAVE_UTF8_STRING
292  if (SDL_X11_HAVE_UTF8) {
293  /* Set the locale, and call XSetLocaleModifiers before XOpenIM so that
294  Compose keys will work correctly. */
295  char *prev_locale = setlocale(LC_ALL, NULL);
296  char *prev_xmods = X11_XSetLocaleModifiers(NULL);
297  const char *new_xmods = "";
298  const char *env_xmods = SDL_getenv("XMODIFIERS");
299  SDL_bool has_dbus_ime_support = SDL_FALSE;
300 
301  if (prev_locale) {
302  prev_locale = SDL_strdup(prev_locale);
303  }
304 
305  if (prev_xmods) {
306  prev_xmods = SDL_strdup(prev_xmods);
307  }
308 
309  /* IBus resends some key events that were filtered by XFilterEvents
310  when it is used via XIM which causes issues. Prevent this by forcing
311  @im=none if XMODIFIERS contains @im=ibus. IBus can still be used via
312  the DBus implementation, which also has support for pre-editing. */
313  if (env_xmods && SDL_strstr(env_xmods, "@im=ibus") != NULL) {
314  has_dbus_ime_support = SDL_TRUE;
315  }
316  if (env_xmods && SDL_strstr(env_xmods, "@im=fcitx") != NULL) {
317  has_dbus_ime_support = SDL_TRUE;
318  }
319  if (has_dbus_ime_support || !xkb_repeat) {
320  new_xmods = "@im=none";
321  }
322 
323  setlocale(LC_ALL, "");
324  X11_XSetLocaleModifiers(new_xmods);
325 
326  data->im = X11_XOpenIM(data->display, NULL, data->classname, data->classname);
327 
328  /* Reset the locale + X locale modifiers back to how they were,
329  locale first because the X locale modifiers depend on it. */
330  setlocale(LC_ALL, prev_locale);
331  X11_XSetLocaleModifiers(prev_xmods);
332 
333  if (prev_locale) {
334  SDL_free(prev_locale);
335  }
336 
337  if (prev_xmods) {
338  SDL_free(prev_xmods);
339  }
340  }
341 #endif
342  /* Try to determine which scancodes are being used based on fingerprint */
343  best_distance = SDL_arraysize(fingerprint) + 1;
344  best_index = -1;
345  X11_XDisplayKeycodes(data->display, &min_keycode, &max_keycode);
346  for (i = 0; i < SDL_arraysize(fingerprint); ++i) {
347  fingerprint[i].value =
348  X11_XKeysymToKeycode(data->display, fingerprint[i].keysym) -
349  min_keycode;
350  }
351  for (i = 0; i < SDL_arraysize(scancode_set); ++i) {
352  /* Make sure the scancode set isn't too big */
353  if ((max_keycode - min_keycode + 1) <= scancode_set[i].table_size) {
354  continue;
355  }
356  distance = 0;
357  for (j = 0; j < SDL_arraysize(fingerprint); ++j) {
358  if (fingerprint[j].value < 0
359  || fingerprint[j].value >= scancode_set[i].table_size) {
360  distance += 1;
361  } else if (scancode_set[i].table[fingerprint[j].value] != fingerprint[j].scancode) {
362  distance += 1;
363  }
364  }
365  if (distance < best_distance) {
366  best_distance = distance;
367  best_index = i;
368  }
369  }
370  if (best_index >= 0 && best_distance <= 2) {
371 #ifdef DEBUG_KEYBOARD
372  printf("Using scancode set %d, min_keycode = %d, max_keycode = %d, table_size = %d\n", best_index, min_keycode, max_keycode, scancode_set[best_index].table_size);
373 #endif
374  SDL_memcpy(&data->key_layout[min_keycode], scancode_set[best_index].table,
375  sizeof(SDL_Scancode) * scancode_set[best_index].table_size);
376  } else {
378 
379  printf
380  ("Keyboard layout unknown, please report the following to the SDL forums/mailing list (https://discourse.libsdl.org/):\n");
381 
382  /* Determine key_layout - only works on US QWERTY layout */
383  SDL_GetDefaultKeymap(keymap);
384  for (i = min_keycode; i <= max_keycode; ++i) {
385  KeySym sym;
386  sym = X11_KeyCodeToSym(_this, (KeyCode) i, 0);
387  if (sym != NoSymbol) {
388  SDL_Scancode scancode;
389  printf("code = %d, sym = 0x%X (%s) ", i - min_keycode,
390  (unsigned int) sym, X11_XKeysymToString(sym));
391  scancode = X11_KeyCodeToSDLScancode(_this, i);
392  data->key_layout[i] = scancode;
393  if (scancode == SDL_SCANCODE_UNKNOWN) {
394  printf("scancode not found\n");
395  } else {
396  printf("scancode = %d (%s)\n", scancode, SDL_GetScancodeName(scancode));
397  }
398  }
399  }
400  }
401 
403 
405 
406 #ifdef SDL_USE_IME
407  SDL_IME_Init();
408 #endif
409 
410  return 0;
411 }
412 
413 void
415 {
417  int i;
418  SDL_Scancode scancode;
420  unsigned char group = 0;
421 
422  SDL_GetDefaultKeymap(keymap);
423 
424 #if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
425  if (data->xkb) {
426  XkbStateRec state;
427  X11_XkbGetUpdatedMap(data->display, XkbAllClientInfoMask, data->xkb);
428 
429  if (X11_XkbGetState(data->display, XkbUseCoreKbd, &state) == Success) {
430  group = state.group;
431  }
432  }
433 #endif
434 
435 
436  for (i = 0; i < SDL_arraysize(data->key_layout); i++) {
437  Uint32 key;
438 
439  /* Make sure this is a valid scancode */
440  scancode = data->key_layout[i];
441  if (scancode == SDL_SCANCODE_UNKNOWN) {
442  continue;
443  }
444 
445  /* See if there is a UCS keycode for this scancode */
446  key = X11_KeyCodeToUcs4(_this, (KeyCode)i, group);
447  if (key) {
448  keymap[scancode] = key;
449  } else {
450  SDL_Scancode keyScancode = X11_KeyCodeToSDLScancode(_this, (KeyCode)i);
451 
452  switch (keyScancode) {
453  case SDL_SCANCODE_RETURN:
454  keymap[scancode] = SDLK_RETURN;
455  break;
456  case SDL_SCANCODE_ESCAPE:
457  keymap[scancode] = SDLK_ESCAPE;
458  break;
460  keymap[scancode] = SDLK_BACKSPACE;
461  break;
462  case SDL_SCANCODE_TAB:
463  keymap[scancode] = SDLK_TAB;
464  break;
465  case SDL_SCANCODE_DELETE:
466  keymap[scancode] = SDLK_DELETE;
467  break;
468  default:
469  keymap[scancode] = SDL_SCANCODE_TO_KEYCODE(keyScancode);
470  break;
471  }
472  }
473  }
474  SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
475 }
476 
477 void
479 {
481 
483  if (data->xkb) {
484  X11_XkbFreeKeyboard(data->xkb, 0, True);
485  data->xkb = NULL;
486  }
487 #endif
488 
489 #ifdef SDL_USE_IME
490  SDL_IME_Quit();
491 #endif
492 }
493 
494 static void
495 X11_ResetXIM(_THIS)
496 {
497 #ifdef X_HAVE_UTF8_STRING
498  SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata;
499  int i;
500 
501  if (videodata && videodata->windowlist) {
502  for (i = 0; i < videodata->numwindows; ++i) {
503  SDL_WindowData *data = videodata->windowlist[i];
504  if (data && data->ic) {
505  /* Clear any partially entered dead keys */
506  char *contents = X11_Xutf8ResetIC(data->ic);
507  if (contents) {
508  X11_XFree(contents);
509  }
510  }
511  }
512  }
513 #endif
514 }
515 
516 void
518 {
519  X11_ResetXIM(_this);
520 }
521 
522 void
524 {
525  X11_ResetXIM(_this);
526 #ifdef SDL_USE_IME
527  SDL_IME_Reset();
528 #endif
529 }
530 
531 void
533 {
534  if (!rect) {
535  SDL_InvalidParamError("rect");
536  return;
537  }
538 
539 #ifdef SDL_USE_IME
541 #endif
542 }
543 
544 #endif /* SDL_VIDEO_DRIVER_X11 */
545 
546 /* vi: set ts=4 sw=4 expandtab: */
#define _THIS
#define SDL_GetScancodeName
#define SDL_getenv
#define SDL_free
#define SDL_strdup
#define SDL_strstr
#define SDL_memcpy
#define SDL_InvalidParamError(param)
Definition: SDL_error.h:90
void SDL_IME_Reset(void)
Definition: SDL_ime.c:123
void SDL_IME_UpdateTextRect(SDL_Rect *rect)
Definition: SDL_ime.c:139
SDL_bool SDL_IME_Init(void)
Definition: SDL_ime.c:86
void SDL_IME_Quit(void)
Definition: SDL_ime.c:109
void SDL_SetScancodeName(SDL_Scancode scancode, const char *name)
Definition: SDL_keyboard.c:620
void SDL_GetDefaultKeymap(SDL_Keycode *keymap)
Definition: SDL_keyboard.c:592
void SDL_SetKeymap(int start, SDL_Keycode *keys, int length)
Definition: SDL_keyboard.c:598
@ SDLK_BACKSPACE
Definition: SDL_keycode.h:56
@ SDLK_TAB
Definition: SDL_keycode.h:57
@ SDLK_ESCAPE
Definition: SDL_keycode.h:55
@ SDLK_DELETE
Definition: SDL_keycode.h:150
@ SDLK_RETURN
Definition: SDL_keycode.h:54
#define SDL_SCANCODE_TO_KEYCODE(X)
Definition: SDL_keycode.h:48
Sint32 SDL_Keycode
The SDL virtual key representation.
Definition: SDL_keycode.h:45
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
GLsizei GLsizei GLfloat distance
GLenum GLsizei GLsizei GLint * values
GLboolean GLuint group
GLsizei const GLfloat * value
GLenum GLsizei GLenum GLenum const void * table
SDL_Scancode
The SDL keyboard scancode representation.
Definition: SDL_scancode.h:44
@ SDL_SCANCODE_END
Definition: SDL_scancode.h:174
@ SDL_SCANCODE_BACKSLASH
Definition: SDL_scancode.h:102
@ SDL_SCANCODE_ESCAPE
Definition: SDL_scancode.h:93
@ SDL_SCANCODE_F15
Definition: SDL_scancode.h:217
@ SDL_SCANCODE_F12
Definition: SDL_scancode.h:164
@ SDL_SCANCODE_KP_PLUS
Definition: SDL_scancode.h:186
@ SDL_SCANCODE_F4
Definition: SDL_scancode.h:156
@ SDL_SCANCODE_RIGHTBRACKET
Definition: SDL_scancode.h:101
@ SDL_SCANCODE_CAPSLOCK
Definition: SDL_scancode.h:151
@ SDL_SCANCODE_F2
Definition: SDL_scancode.h:154
@ SDL_SCANCODE_KP_MINUS
Definition: SDL_scancode.h:185
@ SDL_SCANCODE_F6
Definition: SDL_scancode.h:158
@ SDL_SCANCODE_KP_0
Definition: SDL_scancode.h:197
@ SDL_SCANCODE_F11
Definition: SDL_scancode.h:163
@ SDL_SCANCODE_COMMA
Definition: SDL_scancode.h:147
@ SDL_SCANCODE_KP_PERIOD
Definition: SDL_scancode.h:198
@ SDL_SCANCODE_F24
Definition: SDL_scancode.h:226
@ SDL_SCANCODE_APOSTROPHE
Definition: SDL_scancode.h:129
@ SDL_SCANCODE_KP_COMMA
Definition: SDL_scancode.h:245
@ SDL_SCANCODE_RGUI
Definition: SDL_scancode.h:335
@ SDL_SCANCODE_DELETE
Definition: SDL_scancode.h:173
@ SDL_SCANCODE_F10
Definition: SDL_scancode.h:162
@ SDL_SCANCODE_F3
Definition: SDL_scancode.h:155
@ SDL_SCANCODE_SLASH
Definition: SDL_scancode.h:149
@ SDL_SCANCODE_F1
Definition: SDL_scancode.h:153
@ SDL_SCANCODE_KP_EQUALS
Definition: SDL_scancode.h:214
@ SDL_SCANCODE_F21
Definition: SDL_scancode.h:223
@ SDL_SCANCODE_KP_6
Definition: SDL_scancode.h:193
@ SDL_SCANCODE_KP_7
Definition: SDL_scancode.h:194
@ SDL_SCANCODE_KP_9
Definition: SDL_scancode.h:196
@ SDL_SCANCODE_NUMLOCKCLEAR
Definition: SDL_scancode.h:181
@ SDL_SCANCODE_PRINTSCREEN
Definition: SDL_scancode.h:166
@ SDL_SCANCODE_KP_3
Definition: SDL_scancode.h:190
@ SDL_SCANCODE_SCROLLLOCK
Definition: SDL_scancode.h:167
@ SDL_SCANCODE_PAUSE
Definition: SDL_scancode.h:168
@ SDL_SCANCODE_RETURN
Definition: SDL_scancode.h:92
@ SDL_SCANCODE_HELP
Definition: SDL_scancode.h:228
@ SDL_SCANCODE_PAGEDOWN
Definition: SDL_scancode.h:175
@ SDL_SCANCODE_LSHIFT
Definition: SDL_scancode.h:329
@ SDL_SCANCODE_TAB
Definition: SDL_scancode.h:95
@ SDL_SCANCODE_STOP
Definition: SDL_scancode.h:231
@ SDL_SCANCODE_LCTRL
Definition: SDL_scancode.h:328
@ SDL_SCANCODE_F16
Definition: SDL_scancode.h:218
@ SDL_SCANCODE_F22
Definition: SDL_scancode.h:224
@ SDL_SCANCODE_UNKNOWN
Definition: SDL_scancode.h:45
@ SDL_SCANCODE_LGUI
Definition: SDL_scancode.h:331
@ SDL_SCANCODE_0
Definition: SDL_scancode.h:90
@ SDL_SCANCODE_LEFTBRACKET
Definition: SDL_scancode.h:100
@ SDL_SCANCODE_F19
Definition: SDL_scancode.h:221
@ SDL_SCANCODE_EXECUTE
Definition: SDL_scancode.h:227
@ SDL_SCANCODE_GRAVE
Definition: SDL_scancode.h:130
@ SDL_SCANCODE_MENU
Definition: SDL_scancode.h:229
@ SDL_SCANCODE_RALT
Definition: SDL_scancode.h:334
@ SDL_SCANCODE_SYSREQ
Definition: SDL_scancode.h:269
@ SDL_SCANCODE_F17
Definition: SDL_scancode.h:219
@ SDL_SCANCODE_KP_ENTER
Definition: SDL_scancode.h:187
@ SDL_SCANCODE_FIND
Definition: SDL_scancode.h:237
@ SDL_SCANCODE_PAGEUP
Definition: SDL_scancode.h:172
@ SDL_SCANCODE_F23
Definition: SDL_scancode.h:225
@ SDL_SCANCODE_PERIOD
Definition: SDL_scancode.h:148
@ SDL_SCANCODE_KP_1
Definition: SDL_scancode.h:188
@ SDL_SCANCODE_DOWN
Definition: SDL_scancode.h:178
@ SDL_SCANCODE_RIGHT
Definition: SDL_scancode.h:176
@ SDL_SCANCODE_F7
Definition: SDL_scancode.h:159
@ SDL_SCANCODE_MINUS
Definition: SDL_scancode.h:98
@ SDL_SCANCODE_A
Definition: SDL_scancode.h:54
@ SDL_SCANCODE_MODE
Definition: SDL_scancode.h:337
@ SDL_SCANCODE_KP_2
Definition: SDL_scancode.h:189
@ SDL_SCANCODE_AGAIN
Definition: SDL_scancode.h:232
@ SDL_SCANCODE_KP_MULTIPLY
Definition: SDL_scancode.h:184
@ SDL_SCANCODE_F9
Definition: SDL_scancode.h:161
@ SDL_SCANCODE_F5
Definition: SDL_scancode.h:157
@ SDL_NUM_SCANCODES
Definition: SDL_scancode.h:407
@ SDL_SCANCODE_UP
Definition: SDL_scancode.h:179
@ SDL_SCANCODE_LEFT
Definition: SDL_scancode.h:177
@ SDL_SCANCODE_SELECT
Definition: SDL_scancode.h:230
@ SDL_SCANCODE_APPLICATION
Definition: SDL_scancode.h:210
@ SDL_SCANCODE_KP_4
Definition: SDL_scancode.h:191
@ SDL_SCANCODE_HOME
Definition: SDL_scancode.h:171
@ SDL_SCANCODE_F14
Definition: SDL_scancode.h:216
@ SDL_SCANCODE_F8
Definition: SDL_scancode.h:160
@ SDL_SCANCODE_LALT
Definition: SDL_scancode.h:330
@ SDL_SCANCODE_KP_8
Definition: SDL_scancode.h:195
@ SDL_SCANCODE_RCTRL
Definition: SDL_scancode.h:332
@ SDL_SCANCODE_F20
Definition: SDL_scancode.h:222
@ SDL_SCANCODE_KP_5
Definition: SDL_scancode.h:192
@ SDL_SCANCODE_UNDO
Definition: SDL_scancode.h:233
@ SDL_SCANCODE_KP_DIVIDE
Definition: SDL_scancode.h:183
@ SDL_SCANCODE_F18
Definition: SDL_scancode.h:220
@ SDL_SCANCODE_F13
Definition: SDL_scancode.h:215
@ SDL_SCANCODE_BACKSPACE
Definition: SDL_scancode.h:94
@ SDL_SCANCODE_EQUALS
Definition: SDL_scancode.h:99
@ SDL_SCANCODE_SPACE
Definition: SDL_scancode.h:96
@ SDL_SCANCODE_RSHIFT
Definition: SDL_scancode.h:333
@ SDL_SCANCODE_INSERT
Definition: SDL_scancode.h:169
@ SDL_SCANCODE_1
Definition: SDL_scancode.h:81
SDL_bool
Definition: SDL_stdinc.h:168
@ SDL_TRUE
Definition: SDL_stdinc.h:170
@ SDL_FALSE
Definition: SDL_stdinc.h:169
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:121
uint32_t Uint32
Definition: SDL_stdinc.h:209
static SDL_VideoDevice * _this
Definition: SDL_video.c:126
struct xkb_state * state
void X11_QuitKeyboard(_THIS)
int X11_InitKeyboard(_THIS)
void X11_UpdateKeymap(_THIS)
void X11_SetTextInputRect(_THIS, SDL_Rect *rect)
KeySym X11_KeyCodeToSym(_THIS, KeyCode, unsigned char group)
void X11_StopTextInput(_THIS)
void X11_StartTextInput(_THIS)
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
Definition: SDL_x11sym.h:50
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int int in j)
Definition: SDL_x11sym.h:50
#define NULL
Definition: begin_code.h:163
GLuint64 key
Definition: gl2ext.h:2192
unsigned int X11_KeySymToUcs4(KeySym keysym)
#define SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM
Definition: SDL_config.h:381
set set set set set set set macro pixldst1 abits if abits op else op endif endm macro pixldst2 abits if abits op else op endif endm macro pixldst4 abits if abits op else op endif endm macro pixldst0 abits op endm macro pixldst3 mem_operand op endm macro pixldst30 mem_operand op endm macro pixldst abits if abits elseif abits elseif abits elseif abits elseif abits pixldst0 abits else pixldst0 abits pixldst0 abits pixldst0 abits pixldst0 abits endif elseif abits else pixldst0 abits pixldst0 abits endif elseif abits else error unsupported bpp *numpix else pixst endif endm macro pixld1_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl mov asr adds SRC_WIDTH_FIXED bpl add asl else error unsupported endif endm macro pixld2_s mem_operand if mov asr add asl add asl mov asr sub UNIT_X add asl mov asr add asl add asl mov asr add UNIT_X add asl else pixld1_s mem_operand pixld1_s mem_operand endif endm macro pixld0_s mem_operand if asr adds SRC_WIDTH_FIXED bpl add asl elseif asr adds SRC_WIDTH_FIXED bpl add asl endif endm macro pixld_s_internal mem_operand if mem_operand pixld2_s mem_operand pixdeinterleave basereg elseif mem_operand elseif mem_operand elseif mem_operand elseif mem_operand pixld0_s mem_operand else pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else pixld0_s mem_operand pixld0_s mem_operand endif elseif mem_operand else error unsupported mem_operand if bpp mem_operand endif endm macro vuzp8 reg2 vuzp d d &reg2 endm macro vzip8 reg2 vzip d d &reg2 endm macro pixdeinterleave basereg basereg basereg basereg basereg endif endm macro pixinterleave basereg basereg basereg basereg basereg endif endm macro PF boost_increment endif if endif PF tst PF addne PF subne PF cmp ORIG_W if endif if endif if endif PF subge ORIG_W PF subges if endif if endif if endif endif endm macro cache_preload_simple endif if dst_r_bpp pld[DST_R, #(PREFETCH_DISTANCE_SIMPLE *dst_r_bpp/8)] endif if mask_bpp pld if[MASK, #(PREFETCH_DISTANCE_SIMPLE *mask_bpp/8)] endif endif endm macro fetch_mask_pixblock pixld mask_basereg pixblock_size MASK endm macro ensure_destination_ptr_alignment process_pixblock_tail_head if beq irp skip1(dst_w_bpp<=(lowbit *8)) &&((lowbit *8)<(pixblock_size *dst_w_bpp)) .if lowbit< 16 tst DST_R
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF base if bpp PF set rept prefetch_distance PF set OFFSET endr endif endm macro preload_leading_step2 base if bpp ifc DST PF PF else if bpp lsl PF PF lsl PF PF lsl PF PF PF else PF lsl PF lsl PF lsl PF endif SIZE macro preload_middle scratch_holds_offset if bpp if else PF PF endif endif endif endm macro preload_trailing base if bpp if bpp *pix_per_block PF PF lsl PF PF PF PF PF else PF lsl PF lsl PF PF PF PF PF base if bpp if narrow_case &&bpp<=dst_w_bpp) PF bic, WK0, base, #31 PF pld,[WK0] PF add, WK1, base, X, LSL #bpp_shift PF sub, WK1, WK1, #1 PF bic, WK1, WK1, #31 PF cmp, WK1, WK0 PF beq, 90f PF pld,[WK1]90:.else PF bic, WK0, base, #31 PF pld,[WK0] PF add, WK1, base, X, lsl #bpp_shift PF sub, WK1, WK1, #1 PF bic, WK1, WK1, #31 PF cmp, WK1, WK0 PF beq, 92f91:PF add, WK0, WK0, #32 PF cmp, WK0, WK1 PF pld,[WK0] PF bne, 91b92:.endif .endif.endm.macro conditional_process1_helper cond, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx process_head cond, numbytes, firstreg, unaligned_src, unaligned_mask, 0 .if decrementx sub &cond X, X, #8 *numbytes/dst_w_bpp .endif process_tail cond, numbytes, firstreg .if !((flags) &FLAG_PROCESS_DOES_STORE) pixst cond, numbytes, firstreg, DST .endif.endm.macro conditional_process1 cond, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx .if(flags) &FLAG_BRANCH_OVER .ifc cond, mi bpl 100f .endif .ifc cond, cs bcc 100f .endif .ifc cond, ne beq 100f .endif conditional_process1_helper, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx100:.else conditional_process1_helper cond, process_head, process_tail, numbytes, firstreg, unaligned_src, unaligned_mask, decrementx .endif.endm.macro conditional_process2 test, cond1, cond2, process_head, process_tail, numbytes1, numbytes2, firstreg1, firstreg2, unaligned_src, unaligned_mask, decrementx .if(flags) &(FLAG_DST_READWRITE|FLAG_BRANCH_OVER|FLAG_PROCESS_CORRUPTS_PSR|FLAG_PROCESS_DOES_STORE) test conditional_process1 cond1, process_head, process_tail, numbytes1, firstreg1, unaligned_src, unaligned_mask, decrementx .if(flags) &FLAG_PROCESS_CORRUPTS_PSR test .endif conditional_process1 cond2, process_head, process_tail, numbytes2, firstreg2, unaligned_src, unaligned_mask, decrementx .else test process_head cond1, numbytes1, firstreg1, unaligned_src, unaligned_mask, 0 process_head cond2, numbytes2, firstreg2, unaligned_src, unaligned_mask, 0 .if decrementx sub &cond1 X, X, #8 *numbytes1/dst_w_bpp sub &cond2 X, X, #8 *numbytes2/dst_w_bpp .endif process_tail cond1, numbytes1, firstreg1 process_tail cond2, numbytes2, firstreg2 pixst cond1, numbytes1, firstreg1, DST pixst cond2, numbytes2, firstreg2, DST .endif.endm.macro test_bits_1_0_ptr .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 movs SCRATCH, X, lsl #32-1 .else movs SCRATCH, WK0, lsl #32-1 .endif.endm.macro test_bits_3_2_ptr .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 movs SCRATCH, X, lsl #32-3 .else movs SCRATCH, WK0, lsl #32-3 .endif.endm.macro leading_15bytes process_head, process_tail .set DECREMENT_X, 1 .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 .set DECREMENT_X, 0 sub X, X, WK0, lsr #dst_bpp_shift str X,[sp, #LINE_SAVED_REG_COUNT *4] mov X, WK0 .endif .if dst_w_bpp==8 conditional_process2 test_bits_1_0_ptr, mi, cs, process_head, process_tail, 1, 2, 1, 2, 1, 1, DECREMENT_X .elseif dst_w_bpp==16 test_bits_1_0_ptr conditional_process1 cs, process_head, process_tail, 2, 2, 1, 1, DECREMENT_X .endif conditional_process2 test_bits_3_2_ptr, mi, cs, process_head, process_tail, 4, 8, 1, 2, 1, 1, DECREMENT_X .if(flags) &FLAG_PROCESS_CORRUPTS_WK0 ldr X,[sp, #LINE_SAVED_REG_COUNT *4] .endif.endm.macro test_bits_3_2_pix movs SCRATCH, X, lsl #dst_bpp_shift+32-3.endm.macro test_bits_1_0_pix .if dst_w_bpp==8 movs SCRATCH, X, lsl #dst_bpp_shift+32-1 .else movs SCRATCH, X, lsr #1 .endif.endm.macro trailing_15bytes process_head, process_tail, unaligned_src, unaligned_mask conditional_process2 test_bits_3_2_pix, cs, mi, process_head, process_tail, 8, 4, 0, 2, unaligned_src, unaligned_mask, 0 .if dst_w_bpp==16 test_bits_1_0_pix conditional_process1 cs, process_head, process_tail, 2, 0, unaligned_src, unaligned_mask, 0 .elseif dst_w_bpp==8 conditional_process2 test_bits_1_0_pix, cs, mi, process_head, process_tail, 2, 1, 0, 1, unaligned_src, unaligned_mask, 0 .endif.endm.macro wide_case_inner_loop process_head, process_tail, unaligned_src, unaligned_mask, dst_alignment110:.set SUBBLOCK, 0 .rept pix_per_block *dst_w_bpp/128 process_head, 16, 0, unaligned_src, unaligned_mask, 1 .if(src_bpp > 0) &&(mask_bpp==0) &&((flags) &FLAG_PROCESS_PRESERVES_SCRATCH) preload_middle src_bpp, SRC, 1 .elseif(src_bpp==0) &&(mask_bpp > 0) &&((flags) &FLAG_PROCESS_PRESERVES_SCRATCH) preload_middle mask_bpp, MASK, 1 .else preload_middle src_bpp, SRC, 0 preload_middle mask_bpp, MASK, 0 .endif .if(dst_r_bpp > 0) &&((SUBBLOCK % 2)==0) &&(((flags) &FLAG_NO_PRELOAD_DST)==0) PF pld,[DST, #32 *prefetch_distance - dst_alignment] .endif process_tail, 16, 0 .if !((flags) &FLAG_PROCESS_DOES_STORE) pixst, 16, 0, DST .endif .set SUBBLOCK, SUBBLOCK+1 .endr subs X, X, #pix_per_block bhs 110b.endm.macro wide_case_inner_loop_and_trailing_pixels process_head, process_tail, process_inner_loop, exit_label, unaligned_src, unaligned_mask .if dst_r_bpp > tst bne process_inner_loop DST_PRELOAD_BIAS endif preload_trailing SRC preload_trailing MASK DST endif add medium_case_inner_loop_and_trailing_pixels unaligned_mask endm macro medium_case_inner_loop_and_trailing_pixels DST endif subs bhs tst beq exit_label trailing_15bytes unaligned_mask endm macro narrow_case_inner_loop_and_trailing_pixels unaligned_mask tst conditional_process1 trailing_15bytes unaligned_mask endm macro switch_on_alignment action
static const SDL_Scancode darwin_scancode_table[]
static const SDL_Scancode xvnc_scancode_table[]
static const SDL_Scancode xfree86_scancode_table[]
static const SDL_Scancode xfree86_scancode_table2[]
A rectangle, with the origin at the upper left (integer).
Definition: SDL_rect.h:78
SDL_WindowData ** windowlist
Definition: SDL_x11video.h:83
SDL_Rect rect
Definition: testrelative.c:27