Handle Colemak swapping of CapsLock and Backspace

Fixes https://github.com/libsdl-org/SDL/issues/7853
This commit is contained in:
Sam Lantinga 2024-08-04 09:56:57 -07:00
parent c709385856
commit 66cb2153cc
1 changed files with 12 additions and 0 deletions

View File

@ -108,6 +108,18 @@ void WIN_UpdateKeymap(SDL_bool send_event)
if (scancode == SDL_SCANCODE_UNKNOWN ||
scancode == SDL_SCANCODE_DELETE ||
(SDL_GetDefaultKeyFromScancode(scancode, SDL_KMOD_NONE) & SDLK_SCANCODE_MASK)) {
/* The Colemak mapping swaps Backspace and CapsLock */
if (mods[m] == SDL_KMOD_NONE &&
(scancode == SDL_SCANCODE_CAPSLOCK ||
scancode == SDL_SCANCODE_BACKSPACE)) {
vk = LOBYTE(MapVirtualKey(i, MAPVK_VSC_TO_VK));
if (vk == VK_CAPITAL) {
SDL_SetKeymapEntry(keymap, scancode, mods[m], SDLK_CAPSLOCK);
} else if (vk == VK_BACK) {
SDL_SetKeymapEntry(keymap, scancode, mods[m], SDLK_BACKSPACE);
}
}
continue;
}