diff --git a/src/posix/cocoa/i_input.mm b/src/posix/cocoa/i_input.mm index 7ae2050b4..9a536d3bf 100644 --- a/src/posix/cocoa/i_input.mm +++ b/src/posix/cocoa/i_input.mm @@ -371,7 +371,7 @@ NSStringEncoding GetEncodingForUnicodeCharacter(const unichar character) return NSWindowsCP1252StringEncoding; } -unsigned char GetCharacterFromNSEvent(NSEvent* theEvent) +unsigned char GetCharacterFromNSEvent(NSEvent* theEvent, unichar *realchar) { const NSString* unicodeCharacters = [theEvent characters]; @@ -400,6 +400,7 @@ unsigned char GetCharacterFromNSEvent(NSEvent* theEvent) : '\0'; } + *realchar = unicodeCharacter; return character; } @@ -407,9 +408,10 @@ void ProcessKeyboardEventInMenu(NSEvent* theEvent) { event_t event = {}; + unichar realchar; event.type = EV_GUI_Event; event.subtype = NSKeyDown == [theEvent type] ? EV_GUI_KeyDown : EV_GUI_KeyUp; - event.data2 = GetCharacterFromNSEvent(theEvent); + event.data2 = GetCharacterFromNSEvent(theEvent, &realchar); event.data3 = ModifierFlagsToGUIKeyModifiers(theEvent); if (EV_GUI_KeyDown == event.subtype && [theEvent isARepeat]) @@ -462,7 +464,7 @@ void ProcessKeyboardEventInMenu(NSEvent* theEvent) && ShouldGenerateGUICharEvent(theEvent)) { event.subtype = EV_GUI_Char; - event.data1 = event.data2; + event.data1 = realchar; event.data2 = event.data3 & GKM_ALT; D_PostEvent(&event); diff --git a/src/posix/sdl/i_input.cpp b/src/posix/sdl/i_input.cpp index 61a1fe0be..6ea1cb70d 100644 --- a/src/posix/sdl/i_input.cpp +++ b/src/posix/sdl/i_input.cpp @@ -471,11 +471,18 @@ void MessagePump (const SDL_Event &sev) case SDL_TEXTINPUT: if (GUICapture) { - event.type = EV_GUI_Event; - event.subtype = EV_GUI_Char; - event.data1 = sev.text.text[0]; - event.data2 = !!(SDL_GetModState() & KMOD_ALT); - D_PostEvent (&event); + int utf8_decode(const char *src, int *size); + int size; + + int unichar = utf8_decode(sev.text.text, &size); + if (size != 4) + { + event.type = EV_GUI_Event; + event.subtype = EV_GUI_Char; + event.data1 = (int16_t)unichar; + event.data2 = !!(SDL_GetModState() & KMOD_ALT); + D_PostEvent (&event); + } } break;