Skip to content

Commit

Permalink
keyboard: Use SDL_SetKeymap() to set the default keymap
Browse files Browse the repository at this point in the history
This ensures the AZERTY workaround is applied for backends that
never call SDL_SetKeymap() themselves.
  • Loading branch information
cgutman authored and slouken committed Jul 31, 2022
1 parent 8b438f7 commit 9515fb2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/events/SDL_keyboard.c
Expand Up @@ -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
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/events/SDL_keyboard_c.h
Expand Up @@ -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
Expand Down

0 comments on commit 9515fb2

Please sign in to comment.