The keycode in key events is the base, unmodified, keycode for the current keyboard layout

This commit is contained in:
Sam Lantinga
2024-06-30 19:58:48 -07:00
parent 5755bde3b8
commit d9dc4b320a
15 changed files with 125 additions and 160 deletions

View File

@@ -315,6 +315,11 @@ typedef struct SDL_KeyboardDeviceEvent
/**
* Keyboard button event structure (event.key.*)
*
* The `key` is the base SDL_Keycode generated by pressing the `scancode` using the current keyboard layout, applying any options specified in SDL_HINT_KEYCODE_OPTIONS. You can get the SDL_Keycode corresponding to the event scancode and modifiers directly from the keyboard layout, bypassing SDL_HINT_KEYCODE_OPTIONS, by calling SDL_GetKeyFromScancode().
*
* \sa SDL_GetKeyFromScancode
* \sa SDL_HINT_KEYCODE_OPTIONS
*
* \since This struct is available since SDL 3.0.0.
*/
typedef struct SDL_KeyboardEvent

View File

@@ -1999,11 +1999,7 @@ extern "C" {
* This variable is a comma separated set of options for translating keycodes
* in events:
*
* - "unmodified": The keycode is the symbol generated by pressing the key
* without any modifiers applied. e.g. Shift+A would yield the keycode
* SDLK_a, or 'a'.
* - "modified": The keycode is the symbol generated by pressing the key with
* modifiers applied. e.g. Shift+A would yield the keycode SDLK_A, or 'A'.
* - "none": Keycode options are cleared, this overrides other options.
* - "french_numbers": The number row on French keyboards is inverted, so
* pressing the 1 key would yield the keycode SDLK_1, or '1', instead of
* SDLK_AMPERSAND, or '&'
@@ -2012,7 +2008,7 @@ extern "C" {
* layout. e.g. pressing the key associated with SDL_SCANCODE_A on a Russian
* keyboard would yield 'a' instead of 'ф'.
*
* The default value for this hint is equivalent to "modified,french_numbers"
* The default value for this hint is "french_numbers"
*
* Some platforms like Emscripten only provide modified keycodes and the
* options are not used.

View File

@@ -88,32 +88,6 @@ typedef Uint32 SDL_Keycode;
#define SDLK_GREATER 0x0000003eu /* '>' */
#define SDLK_QUESTION 0x0000003fu /* '?' */
#define SDLK_AT 0x00000040u /* '@' */
#define SDLK_A 0x00000041u /* 'A' */
#define SDLK_B 0x00000042u /* 'B' */
#define SDLK_C 0x00000043u /* 'C' */
#define SDLK_D 0x00000044u /* 'D' */
#define SDLK_E 0x00000045u /* 'E' */
#define SDLK_F 0x00000046u /* 'F' */
#define SDLK_G 0x00000047u /* 'G' */
#define SDLK_H 0x00000048u /* 'H' */
#define SDLK_I 0x00000049u /* 'I' */
#define SDLK_J 0x0000004au /* 'J' */
#define SDLK_K 0x0000004bu /* 'K' */
#define SDLK_L 0x0000004cu /* 'L' */
#define SDLK_M 0x0000004du /* 'M' */
#define SDLK_N 0x0000004eu /* 'N' */
#define SDLK_O 0x0000004fu /* 'O' */
#define SDLK_P 0x00000050u /* 'P' */
#define SDLK_Q 0x00000051u /* 'Q' */
#define SDLK_R 0x00000052u /* 'R' */
#define SDLK_S 0x00000053u /* 'S' */
#define SDLK_T 0x00000054u /* 'T' */
#define SDLK_U 0x00000055u /* 'U' */
#define SDLK_V 0x00000056u /* 'V' */
#define SDLK_W 0x00000057u /* 'W' */
#define SDLK_X 0x00000058u /* 'X' */
#define SDLK_Y 0x00000059u /* 'Y' */
#define SDLK_Z 0x0000005au /* 'Z' */
#define SDLK_LEFTBRACKET 0x0000005bu /* '[' */
#define SDLK_BACKSLASH 0x0000005cu /* '\\' */
#define SDLK_RIGHTBRACKET 0x0000005du /* ']' */

View File

@@ -415,6 +415,8 @@ typedef enum SDL_Scancode
/* Add any other keys here. */
SDL_SCANCODE_RESERVED = 400, /**< 400-500 reserved for dynamic keycodes */
SDL_NUM_SCANCODES = 512 /**< not a key, just marks the number of scancodes
for array bounds */
} SDL_Scancode;