Skip to content

Commit

Permalink
Merge pull request #309 from GLVis/najlkin/fix-key-locale
Browse files Browse the repository at this point in the history
Fixed Shift combinations with different keyboard layouts
  • Loading branch information
tzanio authored Aug 20, 2024
2 parents c6c1f47 + 8e84a81 commit 975049b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,9 @@ void SdlWindow::keyDownEvent(SDL_Keysym& ks)
// handle key translation due to Shift or CapsLock, so we leave such events
// to be processed there.
// Note: the same condition has to be used in signalKeyDown().
if ((ks.sym >= 32 && ks.sym < 127) &&
(ks.mod & (KMOD_CTRL | KMOD_ALT | KMOD_GUI)) == 0)
const char *scan_name = SDL_GetScancodeName(ks.scancode);
if ((scan_name[0] >= 32 && scan_name[0] < 127) && scan_name[1] == '\0'
&& (ks.mod & (KMOD_CTRL | KMOD_ALT | KMOD_GUI)) == 0)
{
lastKeyDownProcessed = false;
return;
Expand Down Expand Up @@ -626,6 +627,7 @@ void SdlWindow::signalKeyDown(SDL_Keycode k, SDL_Keymod m)
event.type = SDL_KEYDOWN;
event.key.windowID = window_id;
event.key.keysym.sym = k;
event.key.keysym.scancode = SDL_GetScancodeFromKey(tolower(k));
event.key.keysym.mod = m;
queueEvents({ event });

Expand Down

0 comments on commit 975049b

Please sign in to comment.