Explorar o código

keyboard: Use SDL_SetKeymap() to set the default keymap

This ensures the AZERTY workaround is applied for backends that
never call SDL_SetKeymap() themselves.
Cameron Gutman %!s(int64=3) %!d(string=hai) anos
pai
achega
9515fb2501
Modificáronse 2 ficheiros con 4 adicións e 6 borrados
  1. 3 5
      src/events/SDL_keyboard.c
  2. 1 1
      src/events/SDL_keyboard_c.h

+ 3 - 5
src/events/SDL_keyboard.c

@@ -560,11 +560,9 @@ SDL_UCS4ToUTF8(Uint32 ch, char *dst)
 int
 int
 SDL_KeyboardInit(void)
 SDL_KeyboardInit(void)
 {
 {
-    SDL_Keyboard *keyboard = &SDL_keyboard;
-
     /* Set the default keymap */
     /* 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
 void
@@ -590,7 +588,7 @@ SDL_GetDefaultKeymap(SDL_Keycode * keymap)
 }
 }
 
 
 void
 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_Keyboard *keyboard = &SDL_keyboard;
     SDL_Scancode scancode;
     SDL_Scancode scancode;

+ 1 - 1
src/events/SDL_keyboard_c.h

@@ -33,7 +33,7 @@ extern int SDL_KeyboardInit(void);
 extern void SDL_GetDefaultKeymap(SDL_Keycode * keymap);
 extern void SDL_GetDefaultKeymap(SDL_Keycode * keymap);
 
 
 /* Set the mapping of scancode to key codes */
 /* 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
 /* 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
    name. Encoded as UTF-8. The string is not copied, thus the pointer given to