From 44c0b4644fcc66adb816afa4588fc1afaf95f4ad Mon Sep 17 00:00:00 2001 From: Zvika Haramaty Date: Sun, 10 May 2020 08:56:54 +0300 Subject: [PATCH] SDL: Return unicode keycode for Hebrew input Before this commit, when typing in Hebrew, SDL reported the equivalent English keycode. Thus, if user typed Hebrew letter Aleph, it was reported as ascii of 't' (or 'T', I don't remember...). It's still impossible to type Hebrew letters in the GUI's input dialogs, but it's a step forward. --- backends/events/sdl/sdl-events.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index 11fcc9bded8..fe1a497d24b 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -114,7 +114,7 @@ SdlEventSource::~SdlEventSource() { int SdlEventSource::mapKey(SDL_Keycode sdlKey, SDL_Keymod mod, Uint16 unicode) { Common::KeyCode key = SDLToOSystemKeycode(sdlKey); - // Keep unicode in case it's regular ASCII text or in case we didn't get a valid keycode + // Keep unicode in case it's regular ASCII text, Hebrew or in case we didn't get a valid keycode // // We need to use unicode in those cases, simply because SDL1.x passes us non-layout-adjusted keycodes. // So unicode is the only way to get layout-adjusted keys. @@ -136,6 +136,10 @@ int SdlEventSource::mapKey(SDL_Keycode sdlKey, SDL_Keymod mod, Uint16 unicode) { if (unicode > 0x7E) unicode = 0; // do not allow any characters above 0x7E } else { + // We allow Hebrew characters + if (unicode >= 0x05D0 && unicode <= 0x05EA) + return unicode; + // We must not restrict as much as when Ctrl/Alt-modifiers are active, otherwise // we wouldn't let umlauts through for SDL1. For SDL1 umlauts may set for example KEYCODE_QUOTE, KEYCODE_MINUS, etc. if (unicode > 0xFF)