Skip to content

Commit

Permalink
Improved fix for bug 2096 - Mapping from scancode to keycode doesn't …
Browse files Browse the repository at this point in the history
…work for remapped modifier keys

Zack Middleton

The change to the keymap to use SDL_SCANCODE_TO_KEYCODE in SDL_x11keyboard.c causes all SDL scancodes without a Usc4 character to be XOR'd with SDLK_SCANCODE_MASK, but not all key code are suppose to be (as seen in include/SDL_keycodes.h). SDLK_BACKSPACE is not 0x4000002A.

I think the full list of keys affected are return, escape, backspace, tab, and delete.
  • Loading branch information
slouken committed May 29, 2015
1 parent 45f967b commit c888183
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/video/x11/SDL_x11keyboard.c
Expand Up @@ -316,7 +316,28 @@ X11_UpdateKeymap(_THIS)
if (key) {
keymap[scancode] = key;
} else {
keymap[scancode] = SDL_SCANCODE_TO_KEYCODE(X11_KeyCodeToSDLScancode(data->display, (KeyCode)i));
SDL_Scancode keyScancode = X11_KeyCodeToSDLScancode(data->display, (KeyCode)i);

switch (keyScancode) {
case SDL_SCANCODE_RETURN:
keymap[scancode] = SDLK_RETURN;
break;
case SDL_SCANCODE_ESCAPE:
keymap[scancode] = SDLK_ESCAPE;
break;
case SDL_SCANCODE_BACKSPACE:
keymap[scancode] = SDLK_BACKSPACE;
break;
case SDL_SCANCODE_TAB:
keymap[scancode] = SDLK_TAB;
break;
case SDL_SCANCODE_DELETE:
keymap[scancode] = SDLK_DELETE;
break;
default:
keymap[scancode] = SDL_SCANCODE_TO_KEYCODE(keyScancode);
break;
}
}
}
SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
Expand Down

0 comments on commit c888183

Please sign in to comment.