events: Remove X and XKB keysym constants and headers

The XKB_KEY_* and XK_* macros resolve to the same constant values, so use the raw values and note what keys they correspond to in the comments, as is done for the other keysym values in this file.

This completely eliminates the need for any X or XKB system headers along with the if/else defines.
This commit is contained in:
Frank Praznik 2022-11-16 11:32:31 -05:00 committed by Sam Lantinga
parent 20af698b02
commit 8ea96f365f
1 changed files with 20 additions and 52 deletions

View File

@ -26,60 +26,28 @@
#include "SDL_keyboard_c.h" #include "SDL_keyboard_c.h"
#include "SDL_scancode_tables_c.h" #include "SDL_scancode_tables_c.h"
#if SDL_VIDEO_DRIVER_WAYLAND
#include <xkbcommon/xkbcommon.h>
typedef xkb_keysym_t SDL_xkb_keysym_t;
#else
#include <X11/keysym.h>
#include <X11/XKBlib.h>
typedef KeySym SDL_xkb_keysym_t;
#endif
/* *INDENT-OFF* */ /* clang-format off */ /* *INDENT-OFF* */ /* clang-format off */
static const struct { static const struct {
SDL_xkb_keysym_t keysym; Uint32 keysym;
SDL_Scancode scancode; SDL_Scancode scancode;
} KeySymToSDLScancode[] = { } KeySymToSDLScancode[] = {
#if SDL_VIDEO_DRIVER_WAYLAND { 0xFF9C, SDL_SCANCODE_KP_1 }, /* XK_KP_End */
{ XKB_KEY_KP_End, SDL_SCANCODE_KP_1 }, { 0xFF99, SDL_SCANCODE_KP_2 }, /* XK_KP_Down */
{ XKB_KEY_KP_Down, SDL_SCANCODE_KP_2 }, { 0xFF9B, SDL_SCANCODE_KP_3 }, /* XK_KP_Next */
{ XKB_KEY_KP_Next, SDL_SCANCODE_KP_3 }, { 0xFF96, SDL_SCANCODE_KP_4 }, /* XK_KP_Left */
{ XKB_KEY_KP_Left, SDL_SCANCODE_KP_4 }, { 0xFF9D, SDL_SCANCODE_KP_5 }, /* XK_KP_Begin */
{ XKB_KEY_KP_Begin, SDL_SCANCODE_KP_5 }, { 0xFF98, SDL_SCANCODE_KP_6 }, /* XK_KP_Right */
{ XKB_KEY_KP_Right, SDL_SCANCODE_KP_6 }, { 0xFF95, SDL_SCANCODE_KP_7 }, /* XK_KP_Home */
{ XKB_KEY_KP_Home, SDL_SCANCODE_KP_7 }, { 0xFF97, SDL_SCANCODE_KP_8 }, /* XK_KP_Up */
{ XKB_KEY_KP_Up, SDL_SCANCODE_KP_8 }, { 0xFF9A, SDL_SCANCODE_KP_9 }, /* XK_KP_Prior */
{ XKB_KEY_KP_Prior, SDL_SCANCODE_KP_9 }, { 0xFF9E, SDL_SCANCODE_KP_0 }, /* XK_KP_Insert */
{ XKB_KEY_KP_Insert, SDL_SCANCODE_KP_0 }, { 0xFF9F, SDL_SCANCODE_KP_PERIOD }, /* XK_KP_Delete */
{ XKB_KEY_KP_Delete, SDL_SCANCODE_KP_PERIOD }, { 0xFF62, SDL_SCANCODE_EXECUTE }, /* XK_Execute */
{ XKB_KEY_Execute, SDL_SCANCODE_EXECUTE }, { 0xFFEE, SDL_SCANCODE_APPLICATION }, /* XK_Hyper_R */
{ XKB_KEY_Hyper_R, SDL_SCANCODE_APPLICATION }, { 0xFE03, SDL_SCANCODE_RALT }, /* XK_ISO_Level3_Shift */
{ XKB_KEY_ISO_Level3_Shift, SDL_SCANCODE_RALT }, { 0xFFEB, SDL_SCANCODE_LGUI }, /* XK_Super_L */
{ XKB_KEY_Super_L, SDL_SCANCODE_LGUI }, { 0xFFEC, SDL_SCANCODE_RGUI }, /* XK_Super_R */
{ XKB_KEY_Super_R, SDL_SCANCODE_RGUI }, { 0xFF7E, SDL_SCANCODE_MODE }, /* XK_Mode_switch */
{ XKB_KEY_Mode_switch, SDL_SCANCODE_MODE },
#else
{ XK_KP_End, SDL_SCANCODE_KP_1 },
{ XK_KP_Down, SDL_SCANCODE_KP_2 },
{ XK_KP_Next, SDL_SCANCODE_KP_3 },
{ XK_KP_Left, SDL_SCANCODE_KP_4 },
{ XK_KP_Begin, SDL_SCANCODE_KP_5 },
{ XK_KP_Right, SDL_SCANCODE_KP_6 },
{ XK_KP_Home, SDL_SCANCODE_KP_7 },
{ XK_KP_Up, SDL_SCANCODE_KP_8 },
{ XK_KP_Prior, SDL_SCANCODE_KP_9 },
{ XK_KP_Insert, SDL_SCANCODE_KP_0 },
{ XK_KP_Delete, SDL_SCANCODE_KP_PERIOD },
{ XK_Execute, SDL_SCANCODE_EXECUTE },
{ XK_Hyper_R, SDL_SCANCODE_APPLICATION },
{ XK_ISO_Level3_Shift, SDL_SCANCODE_RALT },
{ XK_Super_L, SDL_SCANCODE_LGUI },
{ XK_Super_R, SDL_SCANCODE_RGUI },
{ XK_Mode_switch, SDL_SCANCODE_MODE },
#endif
{ 0x1008FF65, SDL_SCANCODE_MENU }, /* XF86MenuKB */ { 0x1008FF65, SDL_SCANCODE_MENU }, /* XF86MenuKB */
{ 0x1008FF81, SDL_SCANCODE_F13 }, /* XF86Tools */ { 0x1008FF81, SDL_SCANCODE_F13 }, /* XF86Tools */
{ 0x1008FF45, SDL_SCANCODE_F14 }, /* XF86Launch5 */ { 0x1008FF45, SDL_SCANCODE_F14 }, /* XF86Launch5 */
@ -90,7 +58,7 @@ static const struct {
}; };
/* This is a mapping from X keysym to Linux keycode */ /* This is a mapping from X keysym to Linux keycode */
static const SDL_xkb_keysym_t LinuxKeycodeKeysyms[] = { static const Uint32 LinuxKeycodeKeysyms[] = {
/* 0, 0x000 */ 0x0, /* NoSymbol */ /* 0, 0x000 */ 0x0, /* NoSymbol */
/* 1, 0x001 */ 0xFF1B, /* Escape */ /* 1, 0x001 */ 0xFF1B, /* Escape */
/* 2, 0x002 */ 0x31, /* 1 */ /* 2, 0x002 */ 0x31, /* 1 */
@ -358,7 +326,7 @@ done
#endif #endif
static const struct { static const struct {
SDL_xkb_keysym_t keysym; Uint32 keysym;
int linux_keycode; int linux_keycode;
} ExtendedLinuxKeycodeKeysyms[] = { } ExtendedLinuxKeycodeKeysyms[] = {
{ 0x1008FF2C, 0x0a2 }, /* XF86XK_Eject */ { 0x1008FF2C, 0x0a2 }, /* XF86XK_Eject */