Skip to content
Permalink
Browse files
Fixed bug 3188 - AZERTY keyboard support broken and inconsistent
Daniel Gibson

AZERTY keyboard layouts (which are the default layouts in France and Belgium) don't have the number keys (1, 2, ..., 9, 0) in the first row of keys, but ?, &, ?", ', (, -, ?_, ??), = (with small differences between the France and Belgian variants). Numbers are reached via shift.

On Linux and OSX, SDL seems to use the corresponding ISO 8859-1 codes (231 for ?232 for ?tc) as SDL_Keycode (but no SDK_* constants exists for those values!), while on Windows SDL seems to map those keys to SDLK_1, SDLK_2 etc, like you'd get on QWERTY.
I don't know how other platforms behave.

So we have two problems:
1. At least on Linux and OSX invalid/undefined SDL_Keycodes are returned
2. Different platforms behave differently (Windows vs Linux/OSX)

It's unclear what behavior is desired: Should SDL_* constants for those keys be introduced (and Windows behavior changed accordingly)?
Or should all platforms behave like Windows here and use the existing SDLK_1, ..., SDLK_0 keycodes?

This bug on the mailing list:
https://forums.libsdl.org/viewtopic.php?t=11555 (my post about Linux/Windows)
https://forums.libsdl.org/viewtopic.php?t=11573 (Tim Walters discovered the same problem on OSX about 1.5 weeks later).
  • Loading branch information
slouken committed Aug 12, 2017
1 parent 1a54414 commit 3b837a26591fe9146353d607ce497fd7a5641290
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/events/SDL_keyboard.c
@@ -594,12 +594,22 @@ void
SDL_SetKeymap(int start, SDL_Keycode * keys, int length)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
SDL_Scancode scancode;

if (start < 0 || start + length > SDL_NUM_SCANCODES) {
return;
}

SDL_memcpy(&keyboard->keymap[start], keys, sizeof(*keys) * length);

/* The number key scancodes always map to the number key keycodes.
* On AZERTY layouts these technically are symbols, but users (and games)
* always think of them and view them in UI as number keys.
*/
keyboard->keymap[SDL_SCANCODE_0] = SDLK_0;
for (scancode = SDL_SCANCODE_1; scancode <= SDL_SCANCODE_9; ++scancode) {
keyboard->keymap[scancode] = SDLK_1 + (scancode - SDL_SCANCODE_1);
}
}

void

0 comments on commit 3b837a2

Please sign in to comment.