keyboard: Use SDL_SetKeymap() to set the default keymap This ensures the AZERTY workaround is applied for backends that never call SDL_SetKeymap() themselves.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c
index 9a8c403..2ec2285 100644
--- a/src/events/SDL_keyboard.c
+++ b/src/events/SDL_keyboard.c
@@ -560,11 +560,9 @@ SDL_UCS4ToUTF8(Uint32 ch, char *dst)
int
SDL_KeyboardInit(void)
{
- SDL_Keyboard *keyboard = &SDL_keyboard;
-
/* Set the default keymap */
- SDL_memcpy(keyboard->keymap, SDL_default_keymap, sizeof(SDL_default_keymap));
- return (0);
+ SDL_SetKeymap(0, SDL_default_keymap, SDL_NUM_SCANCODES, SDL_FALSE);
+ return 0;
}
void
@@ -590,7 +588,7 @@ SDL_GetDefaultKeymap(SDL_Keycode * keymap)
}
void
-SDL_SetKeymap(int start, SDL_Keycode * keys, int length, SDL_bool send_event)
+SDL_SetKeymap(int start, const SDL_Keycode * keys, int length, SDL_bool send_event)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
SDL_Scancode scancode;
diff --git a/src/events/SDL_keyboard_c.h b/src/events/SDL_keyboard_c.h
index e911312..dc2e882 100644
--- a/src/events/SDL_keyboard_c.h
+++ b/src/events/SDL_keyboard_c.h
@@ -33,7 +33,7 @@ extern int SDL_KeyboardInit(void);
extern void SDL_GetDefaultKeymap(SDL_Keycode * keymap);
/* Set the mapping of scancode to key codes */
-extern void SDL_SetKeymap(int start, SDL_Keycode * keys, int length, SDL_bool send_event);
+extern void SDL_SetKeymap(int start, const SDL_Keycode * keys, int length, SDL_bool send_event);
/* Set a platform-dependent key name, overriding the default platform-agnostic
name. Encoded as UTF-8. The string is not copied, thus the pointer given to