src/events/SDL_keyboard.c
changeset 11247 27eb9a10002c
parent 11240 1f6105d09344
child 11811 5d94cb6b24d3
     1.1 --- a/src/events/SDL_keyboard.c	Sat Aug 12 15:21:26 2017 -0700
     1.2 +++ b/src/events/SDL_keyboard.c	Sat Aug 12 15:41:03 2017 -0700
     1.3 @@ -594,12 +594,22 @@
     1.4  SDL_SetKeymap(int start, SDL_Keycode * keys, int length)
     1.5  {
     1.6      SDL_Keyboard *keyboard = &SDL_keyboard;
     1.7 +    SDL_Scancode scancode;
     1.8  
     1.9      if (start < 0 || start + length > SDL_NUM_SCANCODES) {
    1.10          return;
    1.11      }
    1.12  
    1.13      SDL_memcpy(&keyboard->keymap[start], keys, sizeof(*keys) * length);
    1.14 +
    1.15 +    /* The number key scancodes always map to the number key keycodes.
    1.16 +     * On AZERTY layouts these technically are symbols, but users (and games)
    1.17 +     * always think of them and view them in UI as number keys.
    1.18 +     */
    1.19 +    keyboard->keymap[SDL_SCANCODE_0] = SDLK_0;
    1.20 +    for (scancode = SDL_SCANCODE_1; scancode <= SDL_SCANCODE_9; ++scancode) {
    1.21 +        keyboard->keymap[scancode] = SDLK_1 + (scancode - SDL_SCANCODE_1);
    1.22 +    }
    1.23  }
    1.24  
    1.25  void