X11 scancode mapping cleanup

* Consolidated scancode mapping tables into a single location for all backends
* Verified that the xfree86_scancode_table2 is largely identical to the Linux scancode table
* Updated the Linux scancode table with the latest kernel keycodes (still unmapped)
* Route X11 keysym -> scancode mapping through the linux scancode table (which a few hand-written exceptions), which will allow mappings to automatically get picked up as they are added in the Linux scancode table
* Disabled verbose reporting of missing keysym mappings, we have enough data for now
This commit is contained in:
Sam Lantinga 2022-10-13 22:40:24 -07:00
parent f5afb7d11a
commit 99f2a50394
13 changed files with 2251 additions and 1157 deletions

View file

@ -345,6 +345,11 @@ typedef enum
* \name Usage page 0x0C
*
* These values are mapped from usage page 0x0C (USB consumer page).
* See https://usb.org/sites/default/files/hut1_2.pdf
*
* There are way more keys in the spec than we can represent in the
* current scancode range, so pick the ones that commonly come up in
* real world usage.
*/
/* @{ */

View file

@ -42,7 +42,7 @@
#include "SDL_endian.h"
#include "SDL_scancode.h"
#include "../../events/SDL_events_c.h"
#include "../../events/scancodes_linux.h" /* adds linux_scancode_table */
#include "../../events/SDL_scancode_tables_c.h"
#include "../../core/linux/SDL_evdev_capabilities.h"
#include "../../core/linux/SDL_udev.h"
@ -509,23 +509,21 @@ SDL_EVDEV_Poll(void)
static SDL_Scancode
SDL_EVDEV_translate_keycode(int keycode)
{
SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
SDL_Scancode scancode = SDL_GetScancodeFromTable(SDL_SCANCODE_TABLE_LINUX, keycode);
if (keycode < SDL_arraysize(linux_scancode_table)) {
scancode = linux_scancode_table[keycode];
if (scancode == SDL_SCANCODE_UNKNOWN) {
/* BTN_TOUCH is handled elsewhere, but we might still end up here if
you get an unexpected BTN_TOUCH from something SDL believes is not
a touch device. In this case, we'd rather not get a misleading
SDL_Log message about an unknown key. */
if (keycode != BTN_TOUCH) {
SDL_Log("The key you just pressed is not recognized by SDL. To help "
"get this fixed, please report this to the SDL forums/mailing list "
"<https://discourse.libsdl.org/> EVDEV KeyCode %d", keycode);
}
#ifdef DEBUG_SCANCODES
if (scancode == SDL_SCANCODE_UNKNOWN) {
/* BTN_TOUCH is handled elsewhere, but we might still end up here if
you get an unexpected BTN_TOUCH from something SDL believes is not
a touch device. In this case, we'd rather not get a misleading
SDL_Log message about an unknown key. */
if (keycode != BTN_TOUCH) {
SDL_Log("The key you just pressed is not recognized by SDL. To help "
"get this fixed, please report this to the SDL forums/mailing list "
"<https://discourse.libsdl.org/> EVDEV KeyCode %d", keycode);
}
}
#endif /* DEBUG_SCANCODES */
return scancode;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,73 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../SDL_internal.h"
#if SDL_INPUT_LINUXEV || SDL_VIDEO_DRIVER_DIRECTFB || SDL_VIDEO_DRIVER_WAYLAND || SDL_VIDEO_DRIVER_X11
#include "SDL_scancode_tables_c.h"
#include "scancodes_darwin.h"
#include "scancodes_linux.h"
#include "scancodes_xfree86.h"
static const struct
{
SDL_ScancodeTable table;
SDL_Scancode const *scancodes;
int num_entries;
} SDL_scancode_tables[] = {
{ SDL_SCANCODE_TABLE_DARWIN, darwin_scancode_table, SDL_arraysize(darwin_scancode_table) },
{ SDL_SCANCODE_TABLE_LINUX, linux_scancode_table, SDL_arraysize(linux_scancode_table) },
{ SDL_SCANCODE_TABLE_XFREE86_1, xfree86_scancode_table, SDL_arraysize(xfree86_scancode_table) },
{ SDL_SCANCODE_TABLE_XFREE86_2, xfree86_scancode_table2, SDL_arraysize(xfree86_scancode_table2) },
{ SDL_SCANCODE_TABLE_XVNC, xvnc_scancode_table, SDL_arraysize(xvnc_scancode_table) },
};
const SDL_Scancode *SDL_GetScancodeTable(SDL_ScancodeTable table, int *num_entries)
{
int i;
for (i = 0; i < SDL_arraysize(SDL_scancode_tables); ++i) {
if (table == SDL_scancode_tables[i].table) {
*num_entries = SDL_scancode_tables[i].num_entries;
return SDL_scancode_tables[i].scancodes;
}
}
*num_entries = 0;
return NULL;
}
SDL_Scancode SDL_GetScancodeFromTable(SDL_ScancodeTable table, int keycode)
{
SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN;
int num_entries;
const SDL_Scancode *scancodes = SDL_GetScancodeTable(table, &num_entries);
if (keycode >= 0 && keycode < num_entries) {
scancode = scancodes[keycode];
}
return scancode;
}
#endif /* SDL_INPUT_LINUXEV || SDL_VIDEO_DRIVER_DIRECTFB || SDL_VIDEO_DRIVER_WAYLAND || SDL_VIDEO_DRIVER_X11 */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -0,0 +1,37 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../SDL_internal.h"
#include "../../include/SDL_scancode.h"
typedef enum
{
SDL_SCANCODE_TABLE_DARWIN,
SDL_SCANCODE_TABLE_LINUX,
SDL_SCANCODE_TABLE_XFREE86_1,
SDL_SCANCODE_TABLE_XFREE86_2,
SDL_SCANCODE_TABLE_XVNC,
} SDL_ScancodeTable;
extern const SDL_Scancode *SDL_GetScancodeTable(SDL_ScancodeTable table, int *num_entries);
extern SDL_Scancode SDL_GetScancodeFromTable(SDL_ScancodeTable table, int keycode);
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -157,3 +157,5 @@ static const SDL_Scancode darwin_scancode_table[] = {
/* 127 */ SDL_SCANCODE_POWER
};
/* *INDENT-ON* */ /* clang-format on */
/* vi: set ts=4 sw=4 expandtab: */

File diff suppressed because it is too large Load diff

View file

@ -53,3 +53,5 @@ static const SDL_Scancode windows_scancode_table[] =
SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_INTERNATIONAL4, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_INTERNATIONAL5, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_INTERNATIONAL3, SDL_SCANCODE_UNKNOWN, SDL_SCANCODE_UNKNOWN /* 7 */
};
/* *INDENT-ON* */ /* clang-format on */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -179,247 +179,256 @@ static const SDL_Scancode xfree86_scancode_table[] = {
/* 146 */ SDL_SCANCODE_CUT,
};
/* for wireless usb keyboard (manufacturer TRUST) without numpad. */
/* This is largely identical to the Linux keycode mapping */
static const SDL_Scancode xfree86_scancode_table2[] = {
/* 0 */ SDL_SCANCODE_UNKNOWN,
/* 1 */ SDL_SCANCODE_ESCAPE,
/* 2 */ SDL_SCANCODE_1,
/* 3 */ SDL_SCANCODE_2,
/* 4 */ SDL_SCANCODE_3,
/* 5 */ SDL_SCANCODE_4,
/* 6 */ SDL_SCANCODE_5,
/* 7 */ SDL_SCANCODE_6,
/* 8 */ SDL_SCANCODE_7,
/* 9 */ SDL_SCANCODE_8,
/* 10 */ SDL_SCANCODE_9,
/* 11 */ SDL_SCANCODE_0,
/* 12 */ SDL_SCANCODE_MINUS,
/* 13 */ SDL_SCANCODE_EQUALS,
/* 14 */ SDL_SCANCODE_BACKSPACE,
/* 15 */ SDL_SCANCODE_TAB,
/* 16 */ SDL_SCANCODE_Q,
/* 17 */ SDL_SCANCODE_W,
/* 18 */ SDL_SCANCODE_E,
/* 19 */ SDL_SCANCODE_R,
/* 20 */ SDL_SCANCODE_T,
/* 21 */ SDL_SCANCODE_Y,
/* 22 */ SDL_SCANCODE_U,
/* 23 */ SDL_SCANCODE_I,
/* 24 */ SDL_SCANCODE_O,
/* 25 */ SDL_SCANCODE_P,
/* 26 */ SDL_SCANCODE_LEFTBRACKET,
/* 27 */ SDL_SCANCODE_RIGHTBRACKET,
/* 28 */ SDL_SCANCODE_RETURN,
/* 29 */ SDL_SCANCODE_LCTRL,
/* 30 */ SDL_SCANCODE_A,
/* 31 */ SDL_SCANCODE_S,
/* 32 */ SDL_SCANCODE_D,
/* 33 */ SDL_SCANCODE_F,
/* 34 */ SDL_SCANCODE_G,
/* 35 */ SDL_SCANCODE_H,
/* 36 */ SDL_SCANCODE_J,
/* 37 */ SDL_SCANCODE_K,
/* 38 */ SDL_SCANCODE_L,
/* 39 */ SDL_SCANCODE_SEMICOLON,
/* 40 */ SDL_SCANCODE_APOSTROPHE,
/* 41 */ SDL_SCANCODE_GRAVE,
/* 42 */ SDL_SCANCODE_LSHIFT,
/* 43 */ SDL_SCANCODE_BACKSLASH,
/* 44 */ SDL_SCANCODE_Z,
/* 45 */ SDL_SCANCODE_X,
/* 46 */ SDL_SCANCODE_C,
/* 47 */ SDL_SCANCODE_V,
/* 48 */ SDL_SCANCODE_B,
/* 49 */ SDL_SCANCODE_N,
/* 50 */ SDL_SCANCODE_M,
/* 51 */ SDL_SCANCODE_COMMA,
/* 52 */ SDL_SCANCODE_PERIOD,
/* 53 */ SDL_SCANCODE_SLASH,
/* 54 */ SDL_SCANCODE_RSHIFT,
/* 55 */ SDL_SCANCODE_KP_MULTIPLY,
/* 56 */ SDL_SCANCODE_LALT,
/* 57 */ SDL_SCANCODE_SPACE,
/* 58 */ SDL_SCANCODE_CAPSLOCK,
/* 59 */ SDL_SCANCODE_F1,
/* 60 */ SDL_SCANCODE_F2,
/* 61 */ SDL_SCANCODE_F3,
/* 62 */ SDL_SCANCODE_F4,
/* 63 */ SDL_SCANCODE_F5,
/* 64 */ SDL_SCANCODE_F6,
/* 65 */ SDL_SCANCODE_F7,
/* 66 */ SDL_SCANCODE_F8,
/* 67 */ SDL_SCANCODE_F9,
/* 68 */ SDL_SCANCODE_F10,
/* 69 */ SDL_SCANCODE_NUMLOCKCLEAR,
/* 70 */ SDL_SCANCODE_SCROLLLOCK,
/* 71 */ SDL_SCANCODE_KP_7,
/* 72 */ SDL_SCANCODE_KP_8,
/* 73 */ SDL_SCANCODE_KP_9,
/* 74 */ SDL_SCANCODE_KP_MINUS,
/* 75 */ SDL_SCANCODE_KP_4,
/* 76 */ SDL_SCANCODE_KP_5,
/* 77 */ SDL_SCANCODE_KP_6,
/* 78 */ SDL_SCANCODE_KP_PLUS,
/* 79 */ SDL_SCANCODE_KP_1,
/* 80 */ SDL_SCANCODE_KP_2,
/* 81 */ SDL_SCANCODE_KP_3,
/* 82 */ SDL_SCANCODE_KP_0,
/* 83 */ SDL_SCANCODE_KP_PERIOD,
/* 84 */ SDL_SCANCODE_SYSREQ, /* ???? */
/* 85 */ SDL_SCANCODE_MODE, /* ???? */
/* 86 */ SDL_SCANCODE_NONUSBACKSLASH,
/* 87 */ SDL_SCANCODE_F11,
/* 88 */ SDL_SCANCODE_F12,
/* 89 */ SDL_SCANCODE_INTERNATIONAL1, /* \_ */
/* 90 */ SDL_SCANCODE_UNKNOWN, /* Katakana */
/* 91 */ SDL_SCANCODE_UNKNOWN, /* Hiragana */
/* 92 */ SDL_SCANCODE_INTERNATIONAL4, /* Henkan_Mode */
/* 93 */ SDL_SCANCODE_INTERNATIONAL2, /* Hiragana_Katakana */
/* 94 */ SDL_SCANCODE_INTERNATIONAL5, /* Muhenkan */
/* 95 */ SDL_SCANCODE_UNKNOWN,
/* 96 */ SDL_SCANCODE_KP_ENTER,
/* 97 */ SDL_SCANCODE_RCTRL,
/* 98 */ SDL_SCANCODE_KP_DIVIDE,
/* 99 */ SDL_SCANCODE_PRINTSCREEN,
/* 100 */ SDL_SCANCODE_RALT, /* ISO_Level3_Shift, ALTGR, RALT */
/* 101 */ SDL_SCANCODE_UNKNOWN, /* Linefeed */
/* 102 */ SDL_SCANCODE_HOME,
/* 103 */ SDL_SCANCODE_UP,
/* 104 */ SDL_SCANCODE_PAGEUP,
/* 105 */ SDL_SCANCODE_LEFT,
/* 106 */ SDL_SCANCODE_RIGHT,
/* 107 */ SDL_SCANCODE_END,
/* 108 */ SDL_SCANCODE_DOWN,
/* 109 */ SDL_SCANCODE_PAGEDOWN,
/* 110 */ SDL_SCANCODE_INSERT,
/* 111 */ SDL_SCANCODE_DELETE,
/* 112 */ SDL_SCANCODE_UNKNOWN,
/* 113 */ SDL_SCANCODE_MUTE,
/* 114 */ SDL_SCANCODE_VOLUMEDOWN,
/* 115 */ SDL_SCANCODE_VOLUMEUP,
/* 116 */ SDL_SCANCODE_POWER,
/* 117 */ SDL_SCANCODE_KP_EQUALS,
/* 118 */ SDL_SCANCODE_KP_PLUSMINUS, /* plusminus */
/* 119 */ SDL_SCANCODE_PAUSE,
/* 120 */ SDL_SCANCODE_UNKNOWN, /* XF86LaunchA */
/* 121 */ SDL_SCANCODE_KP_COMMA, /* KP_Decimal */
/* 122 */ SDL_SCANCODE_LANG1, /* Hangul */
/* 123 */ SDL_SCANCODE_LANG2, /* Hangul_Hanja */
/* 124 */ SDL_SCANCODE_INTERNATIONAL3, /* Yen */
/* 125 */ SDL_SCANCODE_LGUI,
/* 126 */ SDL_SCANCODE_RGUI,
/* 127 */ SDL_SCANCODE_APPLICATION,
/* 128 */ SDL_SCANCODE_CANCEL,
/* 129 */ SDL_SCANCODE_AGAIN,
/* 130 */ SDL_SCANCODE_UNKNOWN, /* SunProps */
/* 131 */ SDL_SCANCODE_UNDO,
/* 132 */ SDL_SCANCODE_UNKNOWN, /* SunFront */
/* 133 */ SDL_SCANCODE_COPY,
/* 134 */ SDL_SCANCODE_UNKNOWN, /* SunOpen */
/* 135 */ SDL_SCANCODE_PASTE,
/* 136 */ SDL_SCANCODE_FIND,
/* 137 */ SDL_SCANCODE_CUT,
/* 138 */ SDL_SCANCODE_HELP,
/* 139 */ SDL_SCANCODE_MENU, /* XF86MenuKB */
/* 140 */ SDL_SCANCODE_CALCULATOR,
/* 141 */ SDL_SCANCODE_UNKNOWN,
/* 142 */ SDL_SCANCODE_SLEEP,
/* 143 */ SDL_SCANCODE_UNKNOWN, /* XF86WakeUp */
/* 144 */ SDL_SCANCODE_UNKNOWN, /* XF86Explorer */
/* 145 */ SDL_SCANCODE_UNKNOWN, /* XF86Send */
/* 146 */ SDL_SCANCODE_UNKNOWN,
/* 147 */ SDL_SCANCODE_UNKNOWN, /* XF86Xfer */
/* 148 */ SDL_SCANCODE_APP1, /* XF86Launch1 */
/* 149 */ SDL_SCANCODE_APP2, /* XF86Launch2 */
/* 150 */ SDL_SCANCODE_WWW,
/* 151 */ SDL_SCANCODE_UNKNOWN, /* XF86DOS */
/* 152 */ SDL_SCANCODE_UNKNOWN, /* XF86ScreenSaver */
/* 153 */ SDL_SCANCODE_UNKNOWN,
/* 154 */ SDL_SCANCODE_UNKNOWN, /* XF86RotateWindows */
/* 155 */ SDL_SCANCODE_MAIL,
/* 156 */ SDL_SCANCODE_AC_BOOKMARKS, /* XF86Favorites */
/* 157 */ SDL_SCANCODE_COMPUTER,
/* 158 */ SDL_SCANCODE_AC_BACK,
/* 159 */ SDL_SCANCODE_AC_FORWARD,
/* 160 */ SDL_SCANCODE_UNKNOWN,
/* 161 */ SDL_SCANCODE_EJECT,
/* 162 */ SDL_SCANCODE_EJECT,
/* 163 */ SDL_SCANCODE_AUDIONEXT,
/* 164 */ SDL_SCANCODE_AUDIOPLAY,
/* 165 */ SDL_SCANCODE_AUDIOPREV,
/* 166 */ SDL_SCANCODE_AUDIOSTOP,
/* 167 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioRecord */
/* 168 */ SDL_SCANCODE_AUDIOREWIND, /* XF86AudioRewind */
/* 169 */ SDL_SCANCODE_UNKNOWN, /* XF86Phone */
/* 170 */ SDL_SCANCODE_UNKNOWN,
/* 171 */ SDL_SCANCODE_F13, /* XF86Tools */
/* 172 */ SDL_SCANCODE_AC_HOME,
/* 173 */ SDL_SCANCODE_AC_REFRESH,
/* 174 */ SDL_SCANCODE_UNKNOWN, /* XF86Close */
/* 175 */ SDL_SCANCODE_UNKNOWN,
/* 176 */ SDL_SCANCODE_UNKNOWN,
/* 177 */ SDL_SCANCODE_UNKNOWN, /* XF86ScrollUp */
/* 178 */ SDL_SCANCODE_UNKNOWN, /* XF86ScrollDown */
/* 179 */ SDL_SCANCODE_KP_LEFTPAREN, /* parenleft */
/* 180 */ SDL_SCANCODE_KP_RIGHTPAREN, /* parenright */
/* 181 */ SDL_SCANCODE_UNKNOWN, /* XF86New */
/* 182 */ SDL_SCANCODE_AGAIN,
/* 183 */ SDL_SCANCODE_F13, /* XF86Tools */
/* 184 */ SDL_SCANCODE_F14, /* XF86Launch5 */
/* 185 */ SDL_SCANCODE_F15, /* XF86Launch6 */
/* 186 */ SDL_SCANCODE_F16, /* XF86Launch7 */
/* 187 */ SDL_SCANCODE_F17, /* XF86Launch8 */
/* 188 */ SDL_SCANCODE_F18, /* XF86Launch9 */
/* 189 */ SDL_SCANCODE_F19, /* null keysym */
/* 190 */ SDL_SCANCODE_F20,
/* 191 */ SDL_SCANCODE_UNKNOWN,
/* 192 */ SDL_SCANCODE_UNKNOWN, /* XF86TouchpadToggle */
/* 193 */ SDL_SCANCODE_UNKNOWN,
/* 194 */ SDL_SCANCODE_UNKNOWN,
/* 195 */ SDL_SCANCODE_MODE,
/* 196 */ SDL_SCANCODE_UNKNOWN,
/* 197 */ SDL_SCANCODE_UNKNOWN,
/* 198 */ SDL_SCANCODE_UNKNOWN,
/* 199 */ SDL_SCANCODE_UNKNOWN,
/* 200 */ SDL_SCANCODE_AUDIOPLAY,
/* 201 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioPause */
/* 202 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch3 */
/* 203 */ SDL_SCANCODE_UNKNOWN, /* XF86Launch4 */
/* 204 */ SDL_SCANCODE_UNKNOWN, /* XF86LaunchB */
/* 205 */ SDL_SCANCODE_UNKNOWN, /* XF86Suspend */
/* 206 */ SDL_SCANCODE_UNKNOWN, /* XF86Close */
/* 207 */ SDL_SCANCODE_AUDIOPLAY,
/* 208 */ SDL_SCANCODE_AUDIOFASTFORWARD,
/* 209 */ SDL_SCANCODE_UNKNOWN,
/* 210 */ SDL_SCANCODE_PRINTSCREEN,
/* 211 */ SDL_SCANCODE_UNKNOWN,
/* 212 */ SDL_SCANCODE_UNKNOWN, /* XF86WebCam */
/* 213 */ SDL_SCANCODE_UNKNOWN,
/* 214 */ SDL_SCANCODE_UNKNOWN,
/* 215 */ SDL_SCANCODE_MAIL,
/* 216 */ SDL_SCANCODE_UNKNOWN,
/* 217 */ SDL_SCANCODE_AC_SEARCH,
/* 218 */ SDL_SCANCODE_UNKNOWN,
/* 219 */ SDL_SCANCODE_UNKNOWN, /* XF86Finance */
/* 220 */ SDL_SCANCODE_UNKNOWN,
/* 221 */ SDL_SCANCODE_UNKNOWN, /* XF86Shop */
/* 222 */ SDL_SCANCODE_UNKNOWN,
/* 223 */ SDL_SCANCODE_STOP,
/* 224 */ SDL_SCANCODE_BRIGHTNESSDOWN,
/* 225 */ SDL_SCANCODE_BRIGHTNESSUP,
/* 226 */ SDL_SCANCODE_MEDIASELECT,
/* 227 */ SDL_SCANCODE_DISPLAYSWITCH,
/* 228 */ SDL_SCANCODE_KBDILLUMTOGGLE,
/* 229 */ SDL_SCANCODE_KBDILLUMDOWN,
/* 230 */ SDL_SCANCODE_KBDILLUMUP,
/* 231 */ SDL_SCANCODE_UNKNOWN, /* XF86Send */
/* 232 */ SDL_SCANCODE_UNKNOWN, /* XF86Reply */
/* 233 */ SDL_SCANCODE_UNKNOWN, /* XF86MailForward */
/* 234 */ SDL_SCANCODE_UNKNOWN, /* XF86Save */
/* 235 */ SDL_SCANCODE_UNKNOWN, /* XF86Documents */
/* 236 */ SDL_SCANCODE_UNKNOWN, /* XF86Battery */
/* 237 */ SDL_SCANCODE_UNKNOWN, /* XF86Bluetooth */
/* 238 */ SDL_SCANCODE_UNKNOWN, /* XF86WLAN */
/* 0, 0x000 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */
/* 1, 0x001 */ SDL_SCANCODE_ESCAPE, /* Escape */
/* 2, 0x002 */ SDL_SCANCODE_1, /* 1 */
/* 3, 0x003 */ SDL_SCANCODE_2, /* 2 */
/* 4, 0x004 */ SDL_SCANCODE_3, /* 3 */
/* 5, 0x005 */ SDL_SCANCODE_4, /* 4 */
/* 6, 0x006 */ SDL_SCANCODE_5, /* 5 */
/* 7, 0x007 */ SDL_SCANCODE_6, /* 6 */
/* 8, 0x008 */ SDL_SCANCODE_7, /* 7 */
/* 9, 0x009 */ SDL_SCANCODE_8, /* 8 */
/* 10, 0x00a */ SDL_SCANCODE_9, /* 9 */
/* 11, 0x00b */ SDL_SCANCODE_0, /* 0 */
/* 12, 0x00c */ SDL_SCANCODE_MINUS, /* minus */
/* 13, 0x00d */ SDL_SCANCODE_EQUALS, /* equal */
/* 14, 0x00e */ SDL_SCANCODE_BACKSPACE, /* BackSpace */
/* 15, 0x00f */ SDL_SCANCODE_TAB, /* Tab */
/* 16, 0x010 */ SDL_SCANCODE_Q, /* q */
/* 17, 0x011 */ SDL_SCANCODE_W, /* w */
/* 18, 0x012 */ SDL_SCANCODE_E, /* e */
/* 19, 0x013 */ SDL_SCANCODE_R, /* r */
/* 20, 0x014 */ SDL_SCANCODE_T, /* t */
/* 21, 0x015 */ SDL_SCANCODE_Y, /* y */
/* 22, 0x016 */ SDL_SCANCODE_U, /* u */
/* 23, 0x017 */ SDL_SCANCODE_I, /* i */
/* 24, 0x018 */ SDL_SCANCODE_O, /* o */
/* 25, 0x019 */ SDL_SCANCODE_P, /* p */
/* 26, 0x01a */ SDL_SCANCODE_LEFTBRACKET, /* bracketleft */
/* 27, 0x01b */ SDL_SCANCODE_RIGHTBRACKET, /* bracketright */
/* 28, 0x01c */ SDL_SCANCODE_RETURN, /* Return */
/* 29, 0x01d */ SDL_SCANCODE_LCTRL, /* Control_L */
/* 30, 0x01e */ SDL_SCANCODE_A, /* a */
/* 31, 0x01f */ SDL_SCANCODE_S, /* s */
/* 32, 0x020 */ SDL_SCANCODE_D, /* d */
/* 33, 0x021 */ SDL_SCANCODE_F, /* f */
/* 34, 0x022 */ SDL_SCANCODE_G, /* g */
/* 35, 0x023 */ SDL_SCANCODE_H, /* h */
/* 36, 0x024 */ SDL_SCANCODE_J, /* j */
/* 37, 0x025 */ SDL_SCANCODE_K, /* k */
/* 38, 0x026 */ SDL_SCANCODE_L, /* l */
/* 39, 0x027 */ SDL_SCANCODE_SEMICOLON, /* semicolon */
/* 40, 0x028 */ SDL_SCANCODE_APOSTROPHE, /* apostrophe */
/* 41, 0x029 */ SDL_SCANCODE_GRAVE, /* grave */
/* 42, 0x02a */ SDL_SCANCODE_LSHIFT, /* Shift_L */
/* 43, 0x02b */ SDL_SCANCODE_BACKSLASH, /* backslash */
/* 44, 0x02c */ SDL_SCANCODE_Z, /* z */
/* 45, 0x02d */ SDL_SCANCODE_X, /* x */
/* 46, 0x02e */ SDL_SCANCODE_C, /* c */
/* 47, 0x02f */ SDL_SCANCODE_V, /* v */
/* 48, 0x030 */ SDL_SCANCODE_B, /* b */
/* 49, 0x031 */ SDL_SCANCODE_N, /* n */
/* 50, 0x032 */ SDL_SCANCODE_M, /* m */
/* 51, 0x033 */ SDL_SCANCODE_COMMA, /* comma */
/* 52, 0x034 */ SDL_SCANCODE_PERIOD, /* period */
/* 53, 0x035 */ SDL_SCANCODE_SLASH, /* slash */
/* 54, 0x036 */ SDL_SCANCODE_RSHIFT, /* Shift_R */
/* 55, 0x037 */ SDL_SCANCODE_KP_MULTIPLY, /* KP_Multiply */
/* 56, 0x038 */ SDL_SCANCODE_LALT, /* Alt_L */
/* 57, 0x039 */ SDL_SCANCODE_SPACE, /* space */
/* 58, 0x03a */ SDL_SCANCODE_CAPSLOCK, /* Caps_Lock */
/* 59, 0x03b */ SDL_SCANCODE_F1, /* F1 */
/* 60, 0x03c */ SDL_SCANCODE_F2, /* F2 */
/* 61, 0x03d */ SDL_SCANCODE_F3, /* F3 */
/* 62, 0x03e */ SDL_SCANCODE_F4, /* F4 */
/* 63, 0x03f */ SDL_SCANCODE_F5, /* F5 */
/* 64, 0x040 */ SDL_SCANCODE_F6, /* F6 */
/* 65, 0x041 */ SDL_SCANCODE_F7, /* F7 */
/* 66, 0x042 */ SDL_SCANCODE_F8, /* F8 */
/* 67, 0x043 */ SDL_SCANCODE_F9, /* F9 */
/* 68, 0x044 */ SDL_SCANCODE_F10, /* F10 */
/* 69, 0x045 */ SDL_SCANCODE_NUMLOCKCLEAR, /* Num_Lock */
/* 70, 0x046 */ SDL_SCANCODE_SCROLLLOCK, /* Scroll_Lock */
/* 71, 0x047 */ SDL_SCANCODE_KP_7, /* KP_Home */
/* 72, 0x048 */ SDL_SCANCODE_KP_8, /* KP_Up */
/* 73, 0x049 */ SDL_SCANCODE_KP_9, /* KP_Prior */
/* 74, 0x04a */ SDL_SCANCODE_KP_MINUS, /* KP_Subtract */
/* 75, 0x04b */ SDL_SCANCODE_KP_4, /* KP_Left */
/* 76, 0x04c */ SDL_SCANCODE_KP_5, /* KP_Begin */
/* 77, 0x04d */ SDL_SCANCODE_KP_6, /* KP_Right */
/* 78, 0x04e */ SDL_SCANCODE_KP_PLUS, /* KP_Add */
/* 79, 0x04f */ SDL_SCANCODE_KP_1, /* KP_End */
/* 80, 0x050 */ SDL_SCANCODE_KP_2, /* KP_Down */
/* 81, 0x051 */ SDL_SCANCODE_KP_3, /* KP_Next */
/* 82, 0x052 */ SDL_SCANCODE_KP_0, /* KP_Insert */
/* 83, 0x053 */ SDL_SCANCODE_KP_PERIOD, /* KP_Delete */
/* 84, 0x054 */ SDL_SCANCODE_RALT, /* ISO_Level3_Shift */
/* 85, 0x055 */ SDL_SCANCODE_MODE, /* ???? */
/* 86, 0x056 */ SDL_SCANCODE_NONUSBACKSLASH, /* less */
/* 87, 0x057 */ SDL_SCANCODE_F11, /* F11 */
/* 88, 0x058 */ SDL_SCANCODE_F12, /* F12 */
/* 89, 0x059 */ SDL_SCANCODE_INTERNATIONAL1, /* \_ */
/* 90, 0x05a */ SDL_SCANCODE_LANG3, /* Katakana */
/* 91, 0x05b */ SDL_SCANCODE_LANG4, /* Hiragana */
/* 92, 0x05c */ SDL_SCANCODE_INTERNATIONAL4, /* Henkan_Mode */
/* 93, 0x05d */ SDL_SCANCODE_INTERNATIONAL2, /* Hiragana_Katakana */
/* 94, 0x05e */ SDL_SCANCODE_INTERNATIONAL5, /* Muhenkan */
/* 95, 0x05f */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */
/* 96, 0x060 */ SDL_SCANCODE_KP_ENTER, /* KP_Enter */
/* 97, 0x061 */ SDL_SCANCODE_RCTRL, /* Control_R */
/* 98, 0x062 */ SDL_SCANCODE_KP_DIVIDE, /* KP_Divide */
/* 99, 0x063 */ SDL_SCANCODE_PRINTSCREEN, /* Print */
/* 100, 0x064 */ SDL_SCANCODE_RALT, /* ISO_Level3_Shift, ALTGR, RALT */
/* 101, 0x065 */ SDL_SCANCODE_UNKNOWN, /* Linefeed */
/* 102, 0x066 */ SDL_SCANCODE_HOME, /* Home */
/* 103, 0x067 */ SDL_SCANCODE_UP, /* Up */
/* 104, 0x068 */ SDL_SCANCODE_PAGEUP, /* Prior */
/* 105, 0x069 */ SDL_SCANCODE_LEFT, /* Left */
/* 106, 0x06a */ SDL_SCANCODE_RIGHT, /* Right */
/* 107, 0x06b */ SDL_SCANCODE_END, /* End */
/* 108, 0x06c */ SDL_SCANCODE_DOWN, /* Down */
/* 109, 0x06d */ SDL_SCANCODE_PAGEDOWN, /* Next */
/* 110, 0x06e */ SDL_SCANCODE_INSERT, /* Insert */
/* 111, 0x06f */ SDL_SCANCODE_DELETE, /* Delete */
/* 112, 0x070 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */
/* 113, 0x071 */ SDL_SCANCODE_MUTE, /* XF86AudioMute */
/* 114, 0x072 */ SDL_SCANCODE_VOLUMEDOWN, /* XF86AudioLowerVolume */
/* 115, 0x073 */ SDL_SCANCODE_VOLUMEUP, /* XF86AudioRaiseVolume */
/* 116, 0x074 */ SDL_SCANCODE_POWER, /* XF86PowerOff */
/* 117, 0x075 */ SDL_SCANCODE_KP_EQUALS, /* KP_Equal */
/* 118, 0x076 */ SDL_SCANCODE_KP_PLUSMINUS, /* plusminus */
/* 119, 0x077 */ SDL_SCANCODE_PAUSE, /* Pause */
/* 120, 0x078 */ SDL_SCANCODE_UNKNOWN, /* XF86LaunchA */
/* 121, 0x079 */ SDL_SCANCODE_KP_PERIOD, /* KP_Decimal */
/* 122, 0x07a */ SDL_SCANCODE_LANG1, /* Hangul */
/* 123, 0x07b */ SDL_SCANCODE_LANG2, /* Hangul_Hanja */
/* 124, 0x07c */ SDL_SCANCODE_INTERNATIONAL3, /* Yen */
/* 125, 0x07d */ SDL_SCANCODE_LGUI, /* Super_L */
/* 126, 0x07e */ SDL_SCANCODE_RGUI, /* Super_R */
/* 127, 0x07f */ SDL_SCANCODE_APPLICATION, /* Menu */
/* 128, 0x080 */ SDL_SCANCODE_CANCEL, /* Cancel */
/* 129, 0x081 */ SDL_SCANCODE_AGAIN, /* Redo */
/* 130, 0x082 */ SDL_SCANCODE_UNKNOWN, /* SunProps */
/* 131, 0x083 */ SDL_SCANCODE_UNDO, /* Undo */
/* 132, 0x084 */ SDL_SCANCODE_UNKNOWN, /* SunFront */
/* 133, 0x085 */ SDL_SCANCODE_COPY, /* XF86Copy */
/* 134, 0x086 */ SDL_SCANCODE_UNKNOWN, /* SunOpen, XF86Open */
/* 135, 0x087 */ SDL_SCANCODE_PASTE, /* XF86Paste */
/* 136, 0x088 */ SDL_SCANCODE_FIND, /* Find */
/* 137, 0x089 */ SDL_SCANCODE_CUT, /* XF86Cut */
/* 138, 0x08a */ SDL_SCANCODE_HELP, /* Help */
/* 139, 0x08b */ SDL_SCANCODE_MENU, /* XF86MenuKB */
/* 140, 0x08c */ SDL_SCANCODE_CALCULATOR, /* XF86Calculator */
/* 141, 0x08d */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */
/* 142, 0x08e */ SDL_SCANCODE_SLEEP, /* XF86Sleep */
/* 143, 0x08f */ SDL_SCANCODE_UNKNOWN, /* XF86WakeUp */
/* 144, 0x090 */ SDL_SCANCODE_UNKNOWN, /* XF86Explorer */
/* 145, 0x091 */ SDL_SCANCODE_UNKNOWN, /* XF86Send */
/* 146, 0x092 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */
/* 147, 0x093 */ SDL_SCANCODE_UNKNOWN, /* XF86Xfer */
/* 148, 0x094 */ SDL_SCANCODE_APP1, /* XF86Launch1 */
/* 149, 0x095 */ SDL_SCANCODE_APP2, /* XF86Launch2 */
/* 150, 0x096 */ SDL_SCANCODE_WWW, /* XF86WWW */
/* 151, 0x097 */ SDL_SCANCODE_UNKNOWN, /* XF86DOS */
/* 152, 0x098 */ SDL_SCANCODE_UNKNOWN, /* XF86ScreenSaver */
/* 153, 0x099 */ SDL_SCANCODE_UNKNOWN, /* XF86RotateWindows */
/* 154, 0x09a */ SDL_SCANCODE_UNKNOWN, /* XF86TaskPane */
/* 155, 0x09b */ SDL_SCANCODE_MAIL, /* XF86Mail */
/* 156, 0x09c */ SDL_SCANCODE_AC_BOOKMARKS, /* XF86Favorites */
/* 157, 0x09d */ SDL_SCANCODE_COMPUTER, /* XF86MyComputer */
/* 158, 0x09e */ SDL_SCANCODE_AC_BACK, /* XF86Back */
/* 159, 0x09f */ SDL_SCANCODE_AC_FORWARD, /* XF86Forward */
/* 160, 0x0a0 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */
/* 161, 0x0a1 */ SDL_SCANCODE_EJECT, /* XF86Eject */
/* 162, 0x0a2 */ SDL_SCANCODE_EJECT, /* XF86Eject */
/* 163, 0x0a3 */ SDL_SCANCODE_AUDIONEXT, /* XF86AudioNext */
/* 164, 0x0a4 */ SDL_SCANCODE_AUDIOPLAY, /* XF86AudioPlay */
/* 165, 0x0a5 */ SDL_SCANCODE_AUDIOPREV, /* XF86AudioPrev */
/* 166, 0x0a6 */ SDL_SCANCODE_AUDIOSTOP, /* XF86AudioStop */
/* 167, 0x0a7 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioRecord */
/* 168, 0x0a8 */ SDL_SCANCODE_AUDIOREWIND, /* XF86AudioRewind */
/* 169, 0x0a9 */ SDL_SCANCODE_UNKNOWN, /* XF86Phone */
/* 170, 0x0aa */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */
/* 171, 0x0ab */ SDL_SCANCODE_F13, /* XF86Tools */
/* 172, 0x0ac */ SDL_SCANCODE_AC_HOME, /* XF86HomePage */
/* 173, 0x0ad */ SDL_SCANCODE_AC_REFRESH, /* XF86Reload */
/* 174, 0x0ae */ SDL_SCANCODE_UNKNOWN, /* XF86Close */
/* 175, 0x0af */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */
/* 176, 0x0b0 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */
/* 177, 0x0b1 */ SDL_SCANCODE_UNKNOWN, /* XF86ScrollUp */
/* 178, 0x0b2 */ SDL_SCANCODE_UNKNOWN, /* XF86ScrollDown */
/* 179, 0x0b3 */ SDL_SCANCODE_KP_LEFTPAREN, /* parenleft */
/* 180, 0x0b4 */ SDL_SCANCODE_KP_RIGHTPAREN, /* parenright */
/* 181, 0x0b5 */ SDL_SCANCODE_UNKNOWN, /* XF86New */
/* 182, 0x0b6 */ SDL_SCANCODE_AGAIN, /* Redo */
/* 183, 0x0b7 */ SDL_SCANCODE_F13, /* XF86Tools */
/* 184, 0x0b8 */ SDL_SCANCODE_F14, /* XF86Launch5 */
/* 185, 0x0b9 */ SDL_SCANCODE_F15, /* XF86Launch6 */
/* 186, 0x0ba */ SDL_SCANCODE_F16, /* XF86Launch7 */
/* 187, 0x0bb */ SDL_SCANCODE_F17, /* XF86Launch8 */
/* 188, 0x0bc */ SDL_SCANCODE_F18, /* XF86Launch9 */
/* 189, 0x0bd */ SDL_SCANCODE_F19, /* NoSymbol */
/* 190, 0x0be */ SDL_SCANCODE_F20, /* XF86AudioMicMute */
/* 191, 0x0bf */ SDL_SCANCODE_UNKNOWN, /* XF86TouchpadToggle */
/* 192, 0x0c0 */ SDL_SCANCODE_UNKNOWN, /* XF86TouchpadOn */
/* 193, 0x0c1 */ SDL_SCANCODE_UNKNOWN, /* XF86TouchpadOff */
/* 194, 0x0c2 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */
/* 195, 0x0c3 */ SDL_SCANCODE_MODE, /* Mode_switch */
/* 196, 0x0c4 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */
/* 197, 0x0c5 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */
/* 198, 0x0c6 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */
/* 199, 0x0c7 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */
/* 200, 0x0c8 */ SDL_SCANCODE_AUDIOPLAY, /* XF86AudioPlay */
/* 201, 0x0c9 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioPause */
/* 202, 0x0ca */ SDL_SCANCODE_UNKNOWN, /* XF86Launch3 */
/* 203, 0x0cb */ SDL_SCANCODE_UNKNOWN, /* XF86Launch4 */
/* 204, 0x0cc */ SDL_SCANCODE_UNKNOWN, /* XF86LaunchB */
/* 205, 0x0cd */ SDL_SCANCODE_UNKNOWN, /* XF86Suspend */
/* 206, 0x0ce */ SDL_SCANCODE_UNKNOWN, /* XF86Close */
/* 207, 0x0cf */ SDL_SCANCODE_AUDIOPLAY, /* XF86AudioPlay */
/* 208, 0x0d0 */ SDL_SCANCODE_AUDIOFASTFORWARD, /* XF86AudioForward */
/* 209, 0x0d1 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */
/* 210, 0x0d2 */ SDL_SCANCODE_PRINTSCREEN, /* Print */
/* 211, 0x0d3 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */
/* 212, 0x0d4 */ SDL_SCANCODE_UNKNOWN, /* XF86WebCam */
/* 213, 0x0d5 */ SDL_SCANCODE_UNKNOWN, /* XF86AudioPreset */
/* 214, 0x0d6 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */
/* 215, 0x0d7 */ SDL_SCANCODE_MAIL, /* XF86Mail */
/* 216, 0x0d8 */ SDL_SCANCODE_UNKNOWN, /* XF86Messenger */
/* 217, 0x0d9 */ SDL_SCANCODE_AC_SEARCH, /* XF86Search */
/* 218, 0x0da */ SDL_SCANCODE_UNKNOWN, /* XF86Go */
/* 219, 0x0db */ SDL_SCANCODE_UNKNOWN, /* XF86Finance */
/* 220, 0x0dc */ SDL_SCANCODE_UNKNOWN, /* XF86Game */
/* 221, 0x0dd */ SDL_SCANCODE_UNKNOWN, /* XF86Shop */
/* 222, 0x0de */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */
/* 223, 0x0df */ SDL_SCANCODE_CANCEL, /* Cancel */
/* 224, 0x0e0 */ SDL_SCANCODE_BRIGHTNESSDOWN, /* XF86MonBrightnessDown */
/* 225, 0x0e1 */ SDL_SCANCODE_BRIGHTNESSUP, /* XF86MonBrightnessUp */
/* 226, 0x0e2 */ SDL_SCANCODE_MEDIASELECT, /* XF86AudioMedia */
/* 227, 0x0e3 */ SDL_SCANCODE_DISPLAYSWITCH, /* XF86Display */
/* 228, 0x0e4 */ SDL_SCANCODE_KBDILLUMTOGGLE, /* XF86KbdLightOnOff */
/* 229, 0x0e5 */ SDL_SCANCODE_KBDILLUMDOWN, /* XF86KbdBrightnessDown */
/* 230, 0x0e6 */ SDL_SCANCODE_KBDILLUMUP, /* XF86KbdBrightnessUp */
/* 231, 0x0e7 */ SDL_SCANCODE_UNKNOWN, /* XF86Send */
/* 232, 0x0e8 */ SDL_SCANCODE_UNKNOWN, /* XF86Reply */
/* 233, 0x0e9 */ SDL_SCANCODE_UNKNOWN, /* XF86MailForward */
/* 234, 0x0ea */ SDL_SCANCODE_UNKNOWN, /* XF86Save */
/* 235, 0x0eb */ SDL_SCANCODE_UNKNOWN, /* XF86Documents */
/* 236, 0x0ec */ SDL_SCANCODE_UNKNOWN, /* XF86Battery */
/* 237, 0x0ed */ SDL_SCANCODE_UNKNOWN, /* XF86Bluetooth */
/* 238, 0x0ee */ SDL_SCANCODE_UNKNOWN, /* XF86WLAN */
/* 239, 0x0ef */ SDL_SCANCODE_UNKNOWN, /* XF86UWB */
/* 240, 0x0f0 */ SDL_SCANCODE_UNKNOWN, /* NoSymbol */
/* 241, 0x0f1 */ SDL_SCANCODE_UNKNOWN, /* XF86Next_VMode */
/* 242, 0x0f2 */ SDL_SCANCODE_UNKNOWN, /* XF86Prev_VMode */
/* 243, 0x0f3 */ SDL_SCANCODE_UNKNOWN, /* XF86MonBrightnessCycle */
/* 244, 0x0f4 */ SDL_SCANCODE_UNKNOWN, /* XF86BrightnessAuto */
/* 245, 0x0f5 */ SDL_SCANCODE_UNKNOWN, /* XF86DisplayOff */
/* 246, 0x0f6 */ SDL_SCANCODE_UNKNOWN, /* XF86WWAN */
/* 247, 0x0f7 */ SDL_SCANCODE_UNKNOWN, /* XF86RFKill */
};
/* Xvnc / Xtightvnc scancodes from xmodmap -pk */
@ -510,3 +519,5 @@ static const SDL_Scancode xvnc_scancode_table[] = {
#endif /* scancodes_xfree86_h_ */
/* *INDENT-ON* */ /* clang-format on */
/* vi: set ts=4 sw=4 expandtab: */

View file

@ -34,8 +34,7 @@
#include "../../events/SDL_keyboard_c.h"
#include "../../events/SDL_windowevents_c.h"
#include "../../events/SDL_events_c.h"
#include "../../events/scancodes_linux.h"
#include "../../events/scancodes_xfree86.h"
#include "../../events/SDL_scancode_tables_c.h"
#include "SDL_DirectFB_events.h"
@ -684,12 +683,10 @@ EnumKeyboards(DFBInputDeviceID device_id,
devdata->keyboard[devdata->num_keyboard].is_generic = 0;
if (!SDL_strncmp("X11", desc.name, 3))
{
devdata->keyboard[devdata->num_keyboard].map = xfree86_scancode_table2;
devdata->keyboard[devdata->num_keyboard].map_size = SDL_arraysize(xfree86_scancode_table2);
devdata->keyboard[devdata->num_keyboard].map = SDL_GetScancodeTable(SDL_SCANCODE_TABLE_XFREE86_2, &devdata->keyboard[devdata->num_keyboard].map_size);
devdata->keyboard[devdata->num_keyboard].map_adjust = 8;
} else {
devdata->keyboard[devdata->num_keyboard].map = linux_scancode_table;
devdata->keyboard[devdata->num_keyboard].map_size = SDL_arraysize(linux_scancode_table);
devdata->keyboard[devdata->num_keyboard].map = SDL_GetScancodeTable(SDL_SCANCODE_TABLE_EVDEV, &devdata->keyboard[devdata->num_keyboard].map_size);
devdata->keyboard[devdata->num_keyboard].map_adjust = 0;
}

View file

@ -29,7 +29,7 @@
#include "../../core/unix/SDL_poll.h"
#include "../../events/SDL_events_c.h"
#include "../../events/scancodes_xfree86.h"
#include "../../events/SDL_scancode_tables_c.h"
#include "../SDL_sysvideo.h"
#include "SDL_waylandvideo.h"
@ -1125,9 +1125,8 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
keyboard_input_get_text(text, input, key, SDL_RELEASED, &handled_by_ime);
}
if (!handled_by_ime && key < SDL_arraysize(xfree86_scancode_table2)) {
scancode = xfree86_scancode_table2[key];
if (!handled_by_ime) {
scancode = SDL_GetScancodeFromTable(SDL_SCANCODE_TABLE_XFREE86_2, key);
if (scancode != SDL_SCANCODE_UNKNOWN) {
SDL_SendKeyboardKey(state == WL_KEYBOARD_KEY_STATE_PRESSED ?
SDL_PRESSED : SDL_RELEASED, scancode);
@ -1159,43 +1158,42 @@ Wayland_keymap_iter(struct xkb_keymap *keymap, xkb_keycode_t key, void *data)
{
const xkb_keysym_t *syms;
Wayland_Keymap *sdlKeymap = (Wayland_Keymap *)data;
SDL_Scancode scancode;
if ((key - 8) < SDL_arraysize(xfree86_scancode_table2)) {
SDL_Scancode scancode = xfree86_scancode_table2[key - 8];
if (scancode == SDL_SCANCODE_UNKNOWN) {
return;
scancode = SDL_GetScancodeFromTable(SDL_SCANCODE_TABLE_XFREE86_2, (key - 8));
if (scancode == SDL_SCANCODE_UNKNOWN) {
return;
}
if (WAYLAND_xkb_keymap_key_get_syms_by_level(keymap, key, sdlKeymap->layout, 0, &syms) > 0) {
uint32_t keycode = SDL_KeySymToUcs4(syms[0]);
if (!keycode) {
keycode = Wayland_KeySymToSDLKeyCode(syms[0]);
}
if (WAYLAND_xkb_keymap_key_get_syms_by_level(keymap, key, sdlKeymap->layout, 0, &syms) > 0) {
uint32_t keycode = SDL_KeySymToUcs4(syms[0]);
if (!keycode) {
keycode = Wayland_KeySymToSDLKeyCode(syms[0]);
}
if (keycode) {
sdlKeymap->keymap[scancode] = keycode;
} else {
switch (scancode) {
case SDL_SCANCODE_RETURN:
sdlKeymap->keymap[scancode] = SDLK_RETURN;
break;
case SDL_SCANCODE_ESCAPE:
sdlKeymap->keymap[scancode] = SDLK_ESCAPE;
break;
case SDL_SCANCODE_BACKSPACE:
sdlKeymap->keymap[scancode] = SDLK_BACKSPACE;
break;
case SDL_SCANCODE_TAB:
sdlKeymap->keymap[scancode] = SDLK_TAB;
break;
case SDL_SCANCODE_DELETE:
sdlKeymap->keymap[scancode] = SDLK_DELETE;
break;
default:
sdlKeymap->keymap[scancode] = SDL_SCANCODE_TO_KEYCODE(scancode);
break;
}
if (keycode) {
sdlKeymap->keymap[scancode] = keycode;
} else {
switch (scancode) {
case SDL_SCANCODE_RETURN:
sdlKeymap->keymap[scancode] = SDLK_RETURN;
break;
case SDL_SCANCODE_ESCAPE:
sdlKeymap->keymap[scancode] = SDLK_ESCAPE;
break;
case SDL_SCANCODE_BACKSPACE:
sdlKeymap->keymap[scancode] = SDLK_BACKSPACE;
break;
case SDL_SCANCODE_TAB:
sdlKeymap->keymap[scancode] = SDLK_TAB;
break;
case SDL_SCANCODE_DELETE:
sdlKeymap->keymap[scancode] = SDLK_DELETE;
break;
default:
sdlKeymap->keymap[scancode] = SDL_SCANCODE_TO_KEYCODE(scancode);
break;
}
}
}

View file

@ -402,7 +402,7 @@ X11_ReconcileKeyboardState(_THIS)
}
keyboardState = SDL_GetKeyboardState(0);
for (keycode = 0; keycode < 256; ++keycode) {
for (keycode = 0; keycode < SDL_arraysize(viddata->key_layout); ++keycode) {
SDL_Scancode scancode = viddata->key_layout[keycode];
SDL_bool x11KeyPressed = (keys[keycode / 8] & (1 << (keycode % 8))) != 0;
SDL_bool sdlKeyPressed = keyboardState[scancode] == SDL_PRESSED;
@ -1046,18 +1046,17 @@ X11_DispatchEvent(_THIS, XEvent *xevent)
#ifdef DEBUG_XEVENTS
printf("window %p: %s (X11 keycode = 0x%X)\n", data, (xevent->type == KeyPress ? "KeyPress" : "KeyRelease"), xevent->xkey.keycode);
#endif
#if 1
#ifdef DEBUG_SCANCODES
if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN && keycode) {
int min_keycode, max_keycode;
X11_XDisplayKeycodes(display, &min_keycode, &max_keycode);
keysym = X11_KeyCodeToSym(_this, keycode, xevent->xkey.state >> 13);
fprintf(stderr,
"The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL forums/mailing list <https://discourse.libsdl.org/> X11 KeyCode %d (%d), X11 KeySym 0x%lX (%s).\n",
SDL_Log("The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL forums/mailing list <https://discourse.libsdl.org/> X11 KeyCode %d (%d), X11 KeySym 0x%lX (%s).\n",
keycode, keycode - min_keycode, keysym,
X11_XKeysymToString(keysym));
}
#endif
/* */
#endif /* DEBUG SCANCODES */
SDL_zeroa(text);
#ifdef X_HAVE_UTF8_STRING
if (data->ic && xevent->type == KeyPress) {

View file

@ -25,8 +25,7 @@
#include "SDL_x11video.h"
#include "../../events/SDL_keyboard_c.h"
#include "../../events/scancodes_darwin.h"
#include "../../events/scancodes_xfree86.h"
#include "../../events/SDL_scancode_tables_c.h"
#include <X11/keysym.h>
#include <X11/XKBlib.h>
@ -42,43 +41,6 @@ static const struct {
KeySym keysym;
SDL_Scancode scancode;
} KeySymToSDLScancode[] = {
{ XK_Return, SDL_SCANCODE_RETURN },
{ XK_Escape, SDL_SCANCODE_ESCAPE },
{ XK_BackSpace, SDL_SCANCODE_BACKSPACE },
{ XK_Tab, SDL_SCANCODE_TAB },
{ XK_Caps_Lock, SDL_SCANCODE_CAPSLOCK },
{ XK_F1, SDL_SCANCODE_F1 },
{ XK_F2, SDL_SCANCODE_F2 },
{ XK_F3, SDL_SCANCODE_F3 },
{ XK_F4, SDL_SCANCODE_F4 },
{ XK_F5, SDL_SCANCODE_F5 },
{ XK_F6, SDL_SCANCODE_F6 },
{ XK_F7, SDL_SCANCODE_F7 },
{ XK_F8, SDL_SCANCODE_F8 },
{ XK_F9, SDL_SCANCODE_F9 },
{ XK_F10, SDL_SCANCODE_F10 },
{ XK_F11, SDL_SCANCODE_F11 },
{ XK_F12, SDL_SCANCODE_F12 },
{ XK_Print, SDL_SCANCODE_PRINTSCREEN },
{ XK_Scroll_Lock, SDL_SCANCODE_SCROLLLOCK },
{ XK_Pause, SDL_SCANCODE_PAUSE },
{ XK_Insert, SDL_SCANCODE_INSERT },
{ XK_Home, SDL_SCANCODE_HOME },
{ XK_Prior, SDL_SCANCODE_PAGEUP },
{ XK_Delete, SDL_SCANCODE_DELETE },
{ XK_End, SDL_SCANCODE_END },
{ XK_Next, SDL_SCANCODE_PAGEDOWN },
{ XK_Right, SDL_SCANCODE_RIGHT },
{ XK_Left, SDL_SCANCODE_LEFT },
{ XK_Down, SDL_SCANCODE_DOWN },
{ XK_Up, SDL_SCANCODE_UP },
{ XK_Num_Lock, SDL_SCANCODE_NUMLOCKCLEAR },
{ XK_KP_Divide, SDL_SCANCODE_KP_DIVIDE },
{ XK_KP_Multiply, SDL_SCANCODE_KP_MULTIPLY },
{ XK_KP_Subtract, SDL_SCANCODE_KP_MINUS },
{ XK_KP_Add, SDL_SCANCODE_KP_PLUS },
{ XK_KP_Enter, SDL_SCANCODE_KP_ENTER },
{ XK_KP_Delete, SDL_SCANCODE_KP_PERIOD },
{ XK_KP_End, SDL_SCANCODE_KP_1 },
{ XK_KP_Down, SDL_SCANCODE_KP_2 },
{ XK_KP_Next, SDL_SCANCODE_KP_3 },
@ -89,111 +51,409 @@ static const struct {
{ XK_KP_Up, SDL_SCANCODE_KP_8 },
{ XK_KP_Prior, SDL_SCANCODE_KP_9 },
{ XK_KP_Insert, SDL_SCANCODE_KP_0 },
{ XK_KP_Decimal, SDL_SCANCODE_KP_PERIOD },
{ XK_KP_1, SDL_SCANCODE_KP_1 },
{ XK_KP_2, SDL_SCANCODE_KP_2 },
{ XK_KP_3, SDL_SCANCODE_KP_3 },
{ XK_KP_4, SDL_SCANCODE_KP_4 },
{ XK_KP_5, SDL_SCANCODE_KP_5 },
{ XK_KP_6, SDL_SCANCODE_KP_6 },
{ XK_KP_7, SDL_SCANCODE_KP_7 },
{ XK_KP_8, SDL_SCANCODE_KP_8 },
{ XK_KP_9, SDL_SCANCODE_KP_9 },
{ XK_KP_0, SDL_SCANCODE_KP_0 },
{ XK_KP_Decimal, SDL_SCANCODE_KP_PERIOD },
{ XK_Hyper_R, SDL_SCANCODE_APPLICATION },
{ XK_KP_Equal, SDL_SCANCODE_KP_EQUALS },
{ XK_F13, SDL_SCANCODE_F13 },
{ XK_F14, SDL_SCANCODE_F14 },
{ XK_F15, SDL_SCANCODE_F15 },
{ XK_F16, SDL_SCANCODE_F16 },
{ XK_F17, SDL_SCANCODE_F17 },
{ XK_F18, SDL_SCANCODE_F18 },
{ XK_F19, SDL_SCANCODE_F19 },
{ XK_F20, SDL_SCANCODE_F20 },
{ XK_F21, SDL_SCANCODE_F21 },
{ XK_F22, SDL_SCANCODE_F22 },
{ XK_F23, SDL_SCANCODE_F23 },
{ XK_F24, SDL_SCANCODE_F24 },
{ XK_KP_Delete, SDL_SCANCODE_KP_PERIOD },
{ XK_Execute, SDL_SCANCODE_EXECUTE },
{ XK_Help, SDL_SCANCODE_HELP },
{ XK_Menu, SDL_SCANCODE_MENU },
{ XK_Select, SDL_SCANCODE_SELECT },
{ XK_Cancel, SDL_SCANCODE_STOP },
{ XK_Redo, SDL_SCANCODE_AGAIN },
{ XK_Undo, SDL_SCANCODE_UNDO },
{ XK_Find, SDL_SCANCODE_FIND },
{ XK_KP_Separator, SDL_SCANCODE_KP_COMMA },
{ XK_Sys_Req, SDL_SCANCODE_SYSREQ },
{ XK_Control_L, SDL_SCANCODE_LCTRL },
{ XK_Shift_L, SDL_SCANCODE_LSHIFT },
{ XK_Alt_L, SDL_SCANCODE_LALT },
{ XK_Meta_L, SDL_SCANCODE_LGUI },
{ XK_Super_L, SDL_SCANCODE_LGUI },
{ XK_Control_R, SDL_SCANCODE_RCTRL },
{ XK_Shift_R, SDL_SCANCODE_RSHIFT },
{ XK_Alt_R, SDL_SCANCODE_RALT },
{ XK_Hyper_R, SDL_SCANCODE_APPLICATION },
{ XK_ISO_Level3_Shift, SDL_SCANCODE_RALT },
{ XK_Meta_R, SDL_SCANCODE_RGUI },
{ XK_Super_L, SDL_SCANCODE_LGUI },
{ XK_Super_R, SDL_SCANCODE_RGUI },
{ XK_Mode_switch, SDL_SCANCODE_MODE },
{ XK_period, SDL_SCANCODE_PERIOD },
{ XK_comma, SDL_SCANCODE_COMMA },
{ XK_slash, SDL_SCANCODE_SLASH },
{ XK_backslash, SDL_SCANCODE_BACKSLASH },
{ XK_minus, SDL_SCANCODE_MINUS },
{ XK_equal, SDL_SCANCODE_EQUALS },
{ XK_space, SDL_SCANCODE_SPACE },
{ XK_grave, SDL_SCANCODE_GRAVE },
{ XK_apostrophe, SDL_SCANCODE_APOSTROPHE },
{ XK_bracketleft, SDL_SCANCODE_LEFTBRACKET },
{ XK_bracketright, SDL_SCANCODE_RIGHTBRACKET },
{ 0x1008FF65, SDL_SCANCODE_MENU }, /* XF86MenuKB */
{ 0x1008FF81, SDL_SCANCODE_F13 }, /* XF86Tools */
{ 0x1008FF45, SDL_SCANCODE_F14 }, /* XF86Launch5 */
{ 0x1008FF46, SDL_SCANCODE_F15 }, /* XF86Launch6 */
{ 0x1008FF47, SDL_SCANCODE_F16 }, /* XF86Launch7 */
{ 0x1008FF48, SDL_SCANCODE_F17 }, /* XF86Launch8 */
{ 0x1008FF49, SDL_SCANCODE_F18 }, /* XF86Launch9 */
};
static const struct
/* This is a mapping from X keysym to Linux keycode */
static const KeySym LinuxKeycodeKeysyms[] = {
/* 0, 0x000 */ 0x0, /* NoSymbol */
/* 1, 0x001 */ 0xFF1B, /* Escape */
/* 2, 0x002 */ 0x31, /* 1 */
/* 3, 0x003 */ 0x32, /* 2 */
/* 4, 0x004 */ 0x33, /* 3 */
/* 5, 0x005 */ 0x34, /* 4 */
/* 6, 0x006 */ 0x35, /* 5 */
/* 7, 0x007 */ 0x36, /* 6 */
/* 8, 0x008 */ 0x37, /* 7 */
/* 9, 0x009 */ 0x38, /* 8 */
/* 10, 0x00a */ 0x39, /* 9 */
/* 11, 0x00b */ 0x30, /* 0 */
/* 12, 0x00c */ 0x2D, /* minus */
/* 13, 0x00d */ 0x3D, /* equal */
/* 14, 0x00e */ 0xFF08, /* BackSpace */
/* 15, 0x00f */ 0xFF09, /* Tab */
/* 16, 0x010 */ 0x71, /* q */
/* 17, 0x011 */ 0x77, /* w */
/* 18, 0x012 */ 0x65, /* e */
/* 19, 0x013 */ 0x72, /* r */
/* 20, 0x014 */ 0x74, /* t */
/* 21, 0x015 */ 0x79, /* y */
/* 22, 0x016 */ 0x75, /* u */
/* 23, 0x017 */ 0x69, /* i */
/* 24, 0x018 */ 0x6F, /* o */
/* 25, 0x019 */ 0x70, /* p */
/* 26, 0x01a */ 0x5B, /* bracketleft */
/* 27, 0x01b */ 0x5D, /* bracketright */
/* 28, 0x01c */ 0xFF0D, /* Return */
/* 29, 0x01d */ 0xFFE3, /* Control_L */
/* 30, 0x01e */ 0x61, /* a */
/* 31, 0x01f */ 0x73, /* s */
/* 32, 0x020 */ 0x64, /* d */
/* 33, 0x021 */ 0x66, /* f */
/* 34, 0x022 */ 0x67, /* g */
/* 35, 0x023 */ 0x68, /* h */
/* 36, 0x024 */ 0x6A, /* j */
/* 37, 0x025 */ 0x6B, /* k */
/* 38, 0x026 */ 0x6C, /* l */
/* 39, 0x027 */ 0x3B, /* semicolon */
/* 40, 0x028 */ 0x27, /* apostrophe */
/* 41, 0x029 */ 0x60, /* grave */
/* 42, 0x02a */ 0xFFE1, /* Shift_L */
/* 43, 0x02b */ 0x5C, /* backslash */
/* 44, 0x02c */ 0x7A, /* z */
/* 45, 0x02d */ 0x78, /* x */
/* 46, 0x02e */ 0x63, /* c */
/* 47, 0x02f */ 0x76, /* v */
/* 48, 0x030 */ 0x62, /* b */
/* 49, 0x031 */ 0x6E, /* n */
/* 50, 0x032 */ 0x6D, /* m */
/* 51, 0x033 */ 0x2C, /* comma */
/* 52, 0x034 */ 0x2E, /* period */
/* 53, 0x035 */ 0x2F, /* slash */
/* 54, 0x036 */ 0xFFE2, /* Shift_R */
/* 55, 0x037 */ 0xFFAA, /* KP_Multiply */
/* 56, 0x038 */ 0xFFE9, /* Alt_L */
/* 57, 0x039 */ 0x20, /* space */
/* 58, 0x03a */ 0xFFE5, /* Caps_Lock */
/* 59, 0x03b */ 0xFFBE, /* F1 */
/* 60, 0x03c */ 0xFFBF, /* F2 */
/* 61, 0x03d */ 0xFFC0, /* F3 */
/* 62, 0x03e */ 0xFFC1, /* F4 */
/* 63, 0x03f */ 0xFFC2, /* F5 */
/* 64, 0x040 */ 0xFFC3, /* F6 */
/* 65, 0x041 */ 0xFFC4, /* F7 */
/* 66, 0x042 */ 0xFFC5, /* F8 */
/* 67, 0x043 */ 0xFFC6, /* F9 */
/* 68, 0x044 */ 0xFFC7, /* F10 */
/* 69, 0x045 */ 0xFF7F, /* Num_Lock */
/* 70, 0x046 */ 0xFF14, /* Scroll_Lock */
/* 71, 0x047 */ 0xFFB7, /* KP_7 */
/* 72, 0x048 */ 0XFFB8, /* KP_8 */
/* 73, 0x049 */ 0XFFB9, /* KP_9 */
/* 74, 0x04a */ 0xFFAD, /* KP_Subtract */
/* 75, 0x04b */ 0xFFB4, /* KP_4 */
/* 76, 0x04c */ 0xFFB5, /* KP_5 */
/* 77, 0x04d */ 0xFFB6, /* KP_6 */
/* 78, 0x04e */ 0xFFAB, /* KP_Add */
/* 79, 0x04f */ 0xFFB1, /* KP_1 */
/* 80, 0x050 */ 0xFFB2, /* KP_2 */
/* 81, 0x051 */ 0xFFB3, /* KP_3 */
/* 82, 0x052 */ 0xFFB0, /* KP_0 */
/* 83, 0x053 */ 0xFFAE, /* KP_Decimal */
/* 84, 0x054 */ 0x0, /* NoSymbol */
/* 85, 0x055 */ 0x0, /* NoSymbol */
/* 86, 0x056 */ 0x3C, /* less */
/* 87, 0x057 */ 0xFFC8, /* F11 */
/* 88, 0x058 */ 0xFFC9, /* F12 */
/* 89, 0x059 */ 0x0, /* NoSymbol */
/* 90, 0x05a */ 0xFF26, /* Katakana */
/* 91, 0x05b */ 0xFF25, /* Hiragana */
/* 92, 0x05c */ 0xFF23, /* Henkan_Mode */
/* 93, 0x05d */ 0xFF27, /* Hiragana_Katakana */
/* 94, 0x05e */ 0xFF22, /* Muhenkan */
/* 95, 0x05f */ 0x0, /* NoSymbol */
/* 96, 0x060 */ 0xFF8D, /* KP_Enter */
/* 97, 0x061 */ 0xFFE4, /* Control_R */
/* 98, 0x062 */ 0xFFAF, /* KP_Divide */
/* 99, 0x063 */ 0xFF15, /* Sys_Req */
/* 100, 0x064 */ 0xFFEA, /* Alt_R */
/* 101, 0x065 */ 0xFF0A, /* Linefeed */
/* 102, 0x066 */ 0xFF50, /* Home */
/* 103, 0x067 */ 0xFF52, /* Up */
/* 104, 0x068 */ 0xFF55, /* Prior */
/* 105, 0x069 */ 0xFF51, /* Left */
/* 106, 0x06a */ 0xFF53, /* Right */
/* 107, 0x06b */ 0xFF57, /* End */
/* 108, 0x06c */ 0xFF54, /* Down */
/* 109, 0x06d */ 0xFF56, /* Next */
/* 110, 0x06e */ 0xFF63, /* Insert */
/* 111, 0x06f */ 0xFFFF, /* Delete */
/* 112, 0x070 */ 0x0, /* NoSymbol */
/* 113, 0x071 */ 0x1008FF12, /* XF86AudioMute */
/* 114, 0x072 */ 0x1008FF11, /* XF86AudioLowerVolume */
/* 115, 0x073 */ 0x1008FF13, /* XF86AudioRaiseVolume */
/* 116, 0x074 */ 0x1008FF2A, /* XF86PowerOff */
/* 117, 0x075 */ 0xFFBD, /* KP_Equal */
/* 118, 0x076 */ 0xB1, /* plusminus */
/* 119, 0x077 */ 0xFF13, /* Pause */
/* 120, 0x078 */ 0x1008FF4A, /* XF86LaunchA */
/* 121, 0x079 */ 0xFFAC, /* KP_Separator */
/* 122, 0x07a */ 0xFF31, /* Hangul */
/* 123, 0x07b */ 0xFF34, /* Hangul_Hanja */
/* 124, 0x07c */ 0x0, /* NoSymbol */
/* 125, 0x07d */ 0xFFE7, /* Meta_L */
/* 126, 0x07e */ 0xFFE8, /* Meta_R */
/* 127, 0x07f */ 0xFF67, /* Menu */
/* 128, 0x080 */ 0x00, /* NoSymbol */
/* 129, 0x081 */ 0xFF66, /* Redo */
/* 130, 0x082 */ 0x1005FF70, /* SunProps */
/* 131, 0x083 */ 0xFF65, /* Undo */
/* 132, 0x084 */ 0x1005FF71, /* SunFront */
/* 133, 0x085 */ 0x1008FF57, /* XF86Copy */
/* 134, 0x086 */ 0x1008FF6B, /* XF86Open */
/* 135, 0x087 */ 0x1008FF6D, /* XF86Paste */
/* 136, 0x088 */ 0xFF68, /* Find */
/* 137, 0x089 */ 0x1008FF58, /* XF86Cut */
/* 138, 0x08a */ 0xFF6A, /* Help */
/* 139, 0x08b */ 0xFF67, /* Menu */
/* 140, 0x08c */ 0x1008FF1D, /* XF86Calculator */
/* 141, 0x08d */ 0x0, /* NoSymbol */
/* 142, 0x08e */ 0x1008FF2F, /* XF86Sleep */
/* 143, 0x08f */ 0x1008FF2B, /* XF86WakeUp */
/* 144, 0x090 */ 0x1008FF5D, /* XF86Explorer */
/* 145, 0x091 */ 0x1008FF7B, /* XF86Send */
/* 146, 0x092 */ 0x0, /* NoSymbol */
/* 147, 0x093 */ 0x1008FF8A, /* XF86Xfer */
/* 148, 0x094 */ 0x1008FF41, /* XF86Launch1 */
/* 149, 0x095 */ 0x1008FF42, /* XF86Launch2 */
/* 150, 0x096 */ 0x1008FF2E, /* XF86WWW */
/* 151, 0x097 */ 0x1008FF5A, /* XF86DOS */
/* 152, 0x098 */ 0x1008FF2D, /* XF86ScreenSaver */
/* 153, 0x099 */ 0x1008FF74, /* XF86RotateWindows */
/* 154, 0x09a */ 0x1008FF7F, /* XF86TaskPane */
/* 155, 0x09b */ 0x1008FF19, /* XF86Mail */
/* 156, 0x09c */ 0x1008FF30, /* XF86Favorites */
/* 157, 0x09d */ 0x1008FF33, /* XF86MyComputer */
/* 158, 0x09e */ 0x1008FF26, /* XF86Back */
/* 159, 0x09f */ 0x1008FF27, /* XF86Forward */
/* 160, 0x0a0 */ 0x0, /* NoSymbol */
/* 161, 0x0a1 */ 0x1008FF2C, /* XF86Eject */
/* 162, 0x0a2 */ 0x1008FF2C, /* XF86Eject */
/* 163, 0x0a3 */ 0x1008FF17, /* XF86AudioNext */
/* 164, 0x0a4 */ 0x1008FF14, /* XF86AudioPlay */
/* 165, 0x0a5 */ 0x1008FF16, /* XF86AudioPrev */
/* 166, 0x0a6 */ 0x1008FF15, /* XF86AudioStop */
/* 167, 0x0a7 */ 0x1008FF1C, /* XF86AudioRecord */
/* 168, 0x0a8 */ 0x1008FF3E, /* XF86AudioRewind */
/* 169, 0x0a9 */ 0x1008FF6E, /* XF86Phone */
/* 170, 0x0aa */ 0x0, /* NoSymbol */
/* 171, 0x0ab */ 0x1008FF81, /* XF86Tools */
/* 172, 0x0ac */ 0x1008FF18, /* XF86HomePage */
/* 173, 0x0ad */ 0x1008FF73, /* XF86Reload */
/* 174, 0x0ae */ 0x1008FF56, /* XF86Close */
/* 175, 0x0af */ 0x0, /* NoSymbol */
/* 176, 0x0b0 */ 0x0, /* NoSymbol */
/* 177, 0x0b1 */ 0x1008FF78, /* XF86ScrollUp */
/* 178, 0x0b2 */ 0x1008FF79, /* XF86ScrollDown */
/* 179, 0x0b3 */ 0x28, /* parenleft */
/* 180, 0x0b4 */ 0x29, /* parenright */
/* 181, 0x0b5 */ 0x1008FF68, /* XF86New */
/* 182, 0x0b6 */ 0xFF66, /* Redo */
/* 183, 0x0b7 */ 0xFFCA, /* F13 */
/* 184, 0x0b8 */ 0xFFCB, /* F14 */
/* 185, 0x0b9 */ 0xFFCC, /* F15 */
/* 186, 0x0ba */ 0xFFCD, /* F16 */
/* 187, 0x0bb */ 0xFFCE, /* F17 */
/* 188, 0x0bc */ 0xFFCF, /* F18 */
/* 189, 0x0bd */ 0xFFD0, /* F19 */
/* 190, 0x0be */ 0xFFD1, /* F20 */
/* 191, 0x0bf */ 0xFFD2, /* F21 */
/* 192, 0x0c0 */ 0xFFD3, /* F22 */
/* 193, 0x0c1 */ 0xFFD4, /* F23 */
/* 194, 0x0c2 */ 0xFFD5, /* F24 */
/* 195, 0x0c3 */ 0x0, /* NoSymbol */
/* 196, 0x0c4 */ 0x0, /* NoSymbol */
/* 197, 0x0c5 */ 0x0, /* NoSymbol */
/* 198, 0x0c6 */ 0x0, /* NoSymbol */
/* 199, 0x0c7 */ 0x0, /* NoSymbol */
/* 200, 0x0c8 */ 0x1008FF14, /* XF86AudioPlay */
/* 201, 0x0c9 */ 0x1008FF31, /* XF86AudioPause */
/* 202, 0x0ca */ 0x1008FF43, /* XF86Launch3 */
/* 203, 0x0cb */ 0x1008FF44, /* XF86Launch4 */
/* 204, 0x0cc */ 0x1008FF4B, /* XF86LaunchB */
/* 205, 0x0cd */ 0x1008FFA7, /* XF86Suspend */
/* 206, 0x0ce */ 0x1008FF56, /* XF86Close */
/* 207, 0x0cf */ 0x1008FF14, /* XF86AudioPlay */
/* 208, 0x0d0 */ 0x1008FF97, /* XF86AudioForward */
/* 209, 0x0d1 */ 0x0, /* NoSymbol */
/* 210, 0x0d2 */ 0xFF61, /* Print */
/* 211, 0x0d3 */ 0x0, /* NoSymbol */
/* 212, 0x0d4 */ 0x1008FF8F, /* XF86WebCam */
/* 213, 0x0d5 */ 0x1008FFB6, /* XF86AudioPreset */
/* 214, 0x0d6 */ 0x0, /* NoSymbol */
/* 215, 0x0d7 */ 0x1008FF19, /* XF86Mail */
/* 216, 0x0d8 */ 0x1008FF8E, /* XF86Messenger */
/* 217, 0x0d9 */ 0x1008FF1B, /* XF86Search */
/* 218, 0x0da */ 0x1008FF5F, /* XF86Go */
/* 219, 0x0db */ 0x1008FF3C, /* XF86Finance */
/* 220, 0x0dc */ 0x1008FF5E, /* XF86Game */
/* 221, 0x0dd */ 0x1008FF36, /* XF86Shop */
/* 222, 0x0de */ 0x0, /* NoSymbol */
/* 223, 0x0df */ 0xFF69, /* Cancel */
/* 224, 0x0e0 */ 0x1008FF03, /* XF86MonBrightnessDown */
/* 225, 0x0e1 */ 0x1008FF02, /* XF86MonBrightnessUp */
/* 226, 0x0e2 */ 0x1008FF32, /* XF86AudioMedia */
/* 227, 0x0e3 */ 0x1008FF59, /* XF86Display */
/* 228, 0x0e4 */ 0x1008FF04, /* XF86KbdLightOnOff */
/* 229, 0x0e5 */ 0x1008FF06, /* XF86KbdBrightnessDown */
/* 230, 0x0e6 */ 0x1008FF05, /* XF86KbdBrightnessUp */
/* 231, 0x0e7 */ 0x1008FF7B, /* XF86Send */
/* 232, 0x0e8 */ 0x1008FF72, /* XF86Reply */
/* 233, 0x0e9 */ 0x1008FF90, /* XF86MailForward */
/* 234, 0x0ea */ 0x1008FF77, /* XF86Save */
/* 235, 0x0eb */ 0x1008FF5B, /* XF86Documents */
/* 236, 0x0ec */ 0x1008FF93, /* XF86Battery */
/* 237, 0x0ed */ 0x1008FF94, /* XF86Bluetooth */
/* 238, 0x0ee */ 0x1008FF95, /* XF86WLAN */
/* 239, 0x0ef */ 0x1008FF96, /* XF86UWB */
/* 240, 0x0f0 */ 0x0, /* NoSymbol */
/* 241, 0x0f1 */ 0x1008FE22, /* XF86Next_VMode */
/* 242, 0x0f2 */ 0x1008FE23, /* XF86Prev_VMode */
/* 243, 0x0f3 */ 0x1008FF07, /* XF86MonBrightnessCycle */
/* 244, 0x0f4 */ 0x100810F4, /* XF86BrightnessAuto */
/* 245, 0x0f5 */ 0x100810F5, /* XF86DisplayOff */
/* 246, 0x0f6 */ 0x1008FFB4, /* XF86WWAN */
/* 247, 0x0f7 */ 0x1008FFB5, /* XF86RFKill */
};
#if 0 /* Here is a script to generate the ExtendedLinuxKeycodeKeysyms table */
#!/bin/bash
function process_line
{
SDL_Scancode const *table;
int table_size;
} scancode_set[] = {
{ darwin_scancode_table, SDL_arraysize(darwin_scancode_table) },
{ xfree86_scancode_table, SDL_arraysize(xfree86_scancode_table) },
{ xfree86_scancode_table2, SDL_arraysize(xfree86_scancode_table2) },
{ xvnc_scancode_table, SDL_arraysize(xvnc_scancode_table) },
sym=$(echo "$1" | awk '{print $3}')
code=$(echo "$1" | sed 's,.*_EVDEVK(\(0x[0-9A-Fa-f]*\)).*,\1,')
value=$(egrep "#define ${sym}\s" -R /usr/include/X11 | awk '{print $3}')
printf " { 0x%.8X, 0x%.3x }, /* $sym */\n" $value $code
}
fgrep "/* Use: " /usr/include/xkbcommon/xkbcommon-keysyms.h | fgrep _EVDEVK | while read line; do
process_line "$line"
done
#endif
static const struct {
KeySym keysym;
int linux_keycode;
} ExtendedLinuxKeycodeKeysyms[] = {
{ 0x1008FF2C, 0x0a2 }, /* XF86XK_Eject */
{ 0x1008FF68, 0x0b5 }, /* XF86XK_New */
{ 0x0000FF66, 0x0b6 }, /* XK_Redo */
{ 0x1008FF4B, 0x0cc }, /* XF86XK_LaunchB */
{ 0x1008FF59, 0x0e3 }, /* XF86XK_Display */
{ 0x1008FF04, 0x0e4 }, /* XF86XK_KbdLightOnOff */
{ 0x1008FF06, 0x0e5 }, /* XF86XK_KbdBrightnessDown */
{ 0x1008FF05, 0x0e6 }, /* XF86XK_KbdBrightnessUp */
{ 0x1008FF7B, 0x0e7 }, /* XF86XK_Send */
{ 0x1008FF72, 0x0e8 }, /* XF86XK_Reply */
{ 0x1008FF90, 0x0e9 }, /* XF86XK_MailForward */
{ 0x1008FF77, 0x0ea }, /* XF86XK_Save */
{ 0x1008FF5B, 0x0eb }, /* XF86XK_Documents */
{ 0x1008FF93, 0x0ec }, /* XF86XK_Battery */
{ 0x1008FF94, 0x0ed }, /* XF86XK_Bluetooth */
{ 0x1008FF95, 0x0ee }, /* XF86XK_WLAN */
{ 0x1008FF96, 0x0ef }, /* XF86XK_UWB */
{ 0x1008FE22, 0x0f1 }, /* XF86XK_Next_VMode */
{ 0x1008FE23, 0x0f2 }, /* XF86XK_Prev_VMode */
{ 0x1008FF07, 0x0f3 }, /* XF86XK_MonBrightnessCycle */
{ 0x1008FFB4, 0x0f6 }, /* XF86XK_WWAN */
{ 0x1008FFB5, 0x0f7 }, /* XF86XK_RFKill */
{ 0x1008FFB2, 0x0f8 }, /* XF86XK_AudioMicMute */
{ 0x1008FF9C, 0x173 }, /* XF86XK_CycleAngle */
{ 0x1008FFB8, 0x174 }, /* XF86XK_FullScreen */
{ 0x1008FF87, 0x189 }, /* XF86XK_Video */
{ 0x1008FF20, 0x18d }, /* XF86XK_Calendar */
{ 0x1008FF99, 0x19a }, /* XF86XK_AudioRandomPlay */
{ 0x1008FF5E, 0x1a1 }, /* XF86XK_Game */
{ 0x1008FF8B, 0x1a2 }, /* XF86XK_ZoomIn */
{ 0x1008FF8C, 0x1a3 }, /* XF86XK_ZoomOut */
{ 0x1008FF89, 0x1a5 }, /* XF86XK_Word */
{ 0x1008FF5C, 0x1a7 }, /* XF86XK_Excel */
{ 0x1008FF69, 0x1ab }, /* XF86XK_News */
{ 0x1008FF8E, 0x1ae }, /* XF86XK_Messenger */
{ 0x1008FF61, 0x1b1 }, /* XF86XK_LogOff */
{ 0x00000024, 0x1b2 }, /* XK_dollar */
{ 0x000020AC, 0x1b3 }, /* XK_EuroSign */
{ 0x1008FF9D, 0x1b4 }, /* XF86XK_FrameBack */
{ 0x1008FF9E, 0x1b5 }, /* XF86XK_FrameForward */
{ 0x0000FFF1, 0x1f1 }, /* XK_braille_dot_1 */
{ 0x0000FFF2, 0x1f2 }, /* XK_braille_dot_2 */
{ 0x0000FFF3, 0x1f3 }, /* XK_braille_dot_3 */
{ 0x0000FFF4, 0x1f4 }, /* XK_braille_dot_4 */
{ 0x0000FFF5, 0x1f5 }, /* XK_braille_dot_5 */
{ 0x0000FFF6, 0x1f6 }, /* XK_braille_dot_6 */
{ 0x0000FFF7, 0x1f7 }, /* XK_braille_dot_7 */
{ 0x0000FFF8, 0x1f8 }, /* XK_braille_dot_8 */
{ 0x0000FFF9, 0x1f9 }, /* XK_braille_dot_9 */
{ 0x0000FFF1, 0x1fa }, /* XK_braille_dot_1 */
{ 0x1008FFA9, 0x212 }, /* XF86XK_TouchpadToggle */
{ 0x1008FFB0, 0x213 }, /* XF86XK_TouchpadOn */
{ 0x1008FFB1, 0x214 }, /* XF86XK_TouchpadOff */
{ 0x1008FFB7, 0x231 }, /* XF86XK_RotationLockToggle */
{ 0x0000FE08, 0x248 }, /* XK_ISO_Next_Group */
};
static SDL_ScancodeTable scancode_set[] = {
SDL_SCANCODE_TABLE_DARWIN,
SDL_SCANCODE_TABLE_XFREE86_1,
SDL_SCANCODE_TABLE_XFREE86_2,
SDL_SCANCODE_TABLE_XVNC,
};
/* *INDENT-OFF* */ /* clang-format off */
/* This function only works for keyboards in US QWERTY layout */
/* This function only correctly maps letters and numbers for keyboards in US QWERTY layout */
static SDL_Scancode
X11_KeyCodeToSDLScancode(_THIS, KeyCode keycode)
{
KeySym keysym;
int i;
int linux_keycode = 0;
keysym = X11_KeyCodeToSym(_this, keycode, 0);
if (keysym == NoSymbol) {
return SDL_SCANCODE_UNKNOWN;
}
if (keysym >= XK_a && keysym <= XK_z) {
return SDL_SCANCODE_A + (keysym - XK_a);
}
if (keysym >= XK_A && keysym <= XK_Z) {
return SDL_SCANCODE_A + (keysym - XK_A);
}
if (keysym == XK_0) {
return SDL_SCANCODE_0;
}
if (keysym >= XK_1 && keysym <= XK_9) {
return SDL_SCANCODE_1 + (keysym - XK_1);
}
/* First check our custom list */
for (i = 0; i < SDL_arraysize(KeySymToSDLScancode); ++i) {
if (keysym == KeySymToSDLScancode[i].keysym) {
return KeySymToSDLScancode[i].scancode;
}
}
return SDL_SCANCODE_UNKNOWN;
/* The rest of the keysyms map to Linux keycodes, so use that mapping */
if (keysym >= 0x10081000 && keysym <= 0x10081FFF) {
/* Per xkbcommon-keysyms.h, this is actually a linux keycode */
linux_keycode = (keysym - 0x10081000);
}
if (!linux_keycode) {
/* See if this keysym is an exact match in our table */
i = (keycode - 8);
if (i >= 0 && i < SDL_arraysize(LinuxKeycodeKeysyms) && keysym == LinuxKeycodeKeysyms[i]) {
linux_keycode = i;
} else {
/* Scan the table for this keysym */
for (i = 0; i < SDL_arraysize(LinuxKeycodeKeysyms); ++i) {
if (keysym == LinuxKeycodeKeysyms[i]) {
linux_keycode = i;
break;
}
}
}
}
if (!linux_keycode) {
/* Scan the extended table for this keysym */
for (i = 0; i < SDL_arraysize(ExtendedLinuxKeycodeKeysyms); ++i) {
if (keysym == ExtendedLinuxKeycodeKeysyms[i].keysym) {
linux_keycode = ExtendedLinuxKeycodeKeysyms[i].linux_keycode;
break;
}
}
}
return SDL_GetScancodeFromTable(SDL_SCANCODE_TABLE_LINUX, linux_keycode);
}
static Uint32
@ -339,21 +599,21 @@ X11_InitKeyboard(_THIS)
best_index = -1;
X11_XDisplayKeycodes(data->display, &min_keycode, &max_keycode);
for (i = 0; i < SDL_arraysize(fingerprint); ++i) {
fingerprint[i].value =
X11_XKeysymToKeycode(data->display, fingerprint[i].keysym) -
min_keycode;
fingerprint[i].value = X11_XKeysymToKeycode(data->display, fingerprint[i].keysym) - min_keycode;
}
for (i = 0; i < SDL_arraysize(scancode_set); ++i) {
int table_size;
const SDL_Scancode *table = SDL_GetScancodeTable(scancode_set[i], &table_size);
/* Make sure the scancode set isn't too big */
if ((max_keycode - min_keycode + 1) <= scancode_set[i].table_size) {
if (table_size > (max_keycode - min_keycode + 1)) {
continue;
}
distance = 0;
for (j = 0; j < SDL_arraysize(fingerprint); ++j) {
if (fingerprint[j].value < 0
|| fingerprint[j].value >= scancode_set[i].table_size) {
if (fingerprint[j].value < 0 || fingerprint[j].value >= table_size) {
distance += 1;
} else if (scancode_set[i].table[fingerprint[j].value] != fingerprint[j].scancode) {
} else if (table[fingerprint[j].value] != fingerprint[j].scancode) {
distance += 1;
}
}
@ -363,34 +623,68 @@ X11_InitKeyboard(_THIS)
}
}
if (best_index >= 0 && best_distance <= 2) {
#ifdef DEBUG_KEYBOARD
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);
#endif
SDL_memcpy(&data->key_layout[min_keycode], scancode_set[best_index].table,
sizeof(SDL_Scancode) * scancode_set[best_index].table_size);
} else {
SDL_Keycode keymap[SDL_NUM_SCANCODES];
SDL_Keycode default_keymap[SDL_NUM_SCANCODES];
int table_size;
const SDL_Scancode *table = SDL_GetScancodeTable(scancode_set[best_index], &table_size);
printf
("Keyboard layout unknown, please report the following to the SDL forums/mailing list (https://discourse.libsdl.org/):\n");
#ifdef DEBUG_KEYBOARD
SDL_Log("Using scancode set %d, min_keycode = %d, max_keycode = %d, table_size = %d\n", best_index, min_keycode, max_keycode, table_size);
#endif
/* This should never happen, but just in case... */
if (table_size > (SDL_arraysize(data->key_layout) - min_keycode)) {
table_size = (SDL_arraysize(data->key_layout) - min_keycode);
}
SDL_memcpy(&data->key_layout[min_keycode], table, sizeof(SDL_Scancode) * table_size);
/* Scancodes represent physical locations on the keyboard, unaffected by keyboard mapping.
However, there are a number of extended scancodes that have no standard location, so use
the X11 mapping for all non-character keys.
*/
SDL_GetDefaultKeymap(default_keymap);
for (i = min_keycode; i <= max_keycode; ++i) {
SDL_Scancode scancode = X11_KeyCodeToSDLScancode(_this, i);
#ifdef DEBUG_KEYBOARD
{
KeySym sym;
sym = X11_KeyCodeToSym(_this, (KeyCode)i, 0);
SDL_Log("code = %d, sym = 0x%X (%s) ", i - min_keycode,
(unsigned int)sym, sym == NoSymbol ? "NoSymbol" : X11_XKeysymToString(sym));
}
#endif
if (scancode == data->key_layout[i]) {
continue;
}
if (scancode == SDL_SCANCODE_UNKNOWN || default_keymap[scancode] >= SDLK_SCANCODE_MASK) {
/* Not a character key, safe to remap */
#ifdef DEBUG_KEYBOARD
SDL_Log("Changing scancode, was %d (%s), now %d (%s)\n", data->key_layout[i], SDL_GetScancodeName(data->key_layout[i]), scancode, SDL_GetScancodeName(scancode));
#endif
data->key_layout[i] = scancode;
}
}
} else {
#ifdef DEBUG_SCANCODES
SDL_Log("Keyboard layout unknown, please report the following to the SDL forums/mailing list (https://discourse.libsdl.org/):\n");
#endif
/* Determine key_layout - only works on US QWERTY layout */
SDL_GetDefaultKeymap(keymap);
for (i = min_keycode; i <= max_keycode; ++i) {
KeySym sym;
sym = X11_KeyCodeToSym(_this, (KeyCode) i, 0);
if (sym != NoSymbol) {
SDL_Scancode scancode;
printf("code = %d, sym = 0x%X (%s) ", i - min_keycode,
(unsigned int) sym, X11_XKeysymToString(sym));
scancode = X11_KeyCodeToSDLScancode(_this, i);
data->key_layout[i] = scancode;
if (scancode == SDL_SCANCODE_UNKNOWN) {
printf("scancode not found\n");
} else {
printf("scancode = %d (%s)\n", scancode, SDL_GetScancodeName(scancode));
}
SDL_Scancode scancode = X11_KeyCodeToSDLScancode(_this, i);
#ifdef DEBUG_SCANCODES
{
KeySym sym;
sym = X11_KeyCodeToSym(_this, (KeyCode)i, 0);
SDL_Log("code = %d, sym = 0x%X (%s) ", i - min_keycode,
(unsigned int)sym, sym == NoSymbol ? "NoSymbol" : X11_XKeysymToString(sym));
}
if (scancode == SDL_SCANCODE_UNKNOWN) {
SDL_Log("scancode not found\n");
} else {
SDL_Log("scancode = %d (%s)\n", scancode, SDL_GetScancodeName(scancode));
}
#endif
data->key_layout[i] = scancode;
}
}