From: Holger Schemel Date: Wed, 16 Sep 2020 21:52:56 +0000 (+0200) Subject: fixed text event handling for newer SDL versions (again) X-Git-Tag: 4.2.0.3~31 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=fc2258f533dd7578e76f89a0fe1ad093022284dd;p=rocksndiamonds.git fixed text event handling for newer SDL versions (again) This fixes another regression of commit 5a53ae0c, 888ee049 and 35da46e4 that still causes incorrect key/text event handling. The problem occurs when entering uppercase letters, which creates two key events (pressed and released) with the lowercase letter (while modifier state indicates that the Shift key is active), plus one text event with the uppercase letter. The previous logic caused both cases to be handled as a new key event, effectively handling that letter twice (one time in lowercase, and another time in uppercase). An additional check for text input style modifier keys prevents the lowercase variant of the case described above not to be handled. --- diff --git a/src/events.c b/src/events.c index 24106461..f4311bfd 100644 --- a/src/events.c +++ b/src/events.c @@ -1386,6 +1386,10 @@ static boolean checkTextInputKey(Key key) if (game_status == GAME_MODE_PLAYING) return FALSE; + // if Shift or right Alt key is pressed, handle key as text input + if ((GetKeyModState() & KMOD_TextInput) != KMOD_None) + return TRUE; + // ignore raw keys as text input when not in text input mode if (KSYM_RAW(key) && !textinput_status) return FALSE; diff --git a/src/libgame/sdl.h b/src/libgame/sdl.h index dfdd4a40..4fec8030 100644 --- a/src/libgame/sdl.h +++ b/src/libgame/sdl.h @@ -386,6 +386,9 @@ typedef struct UserEventInfo UserEvent; KMOD_Meta | \ KMOD_Alt) +#define KMOD_TextInput (KMOD_Shift | KMOD_Alt_R) + + // SDL function definitions const char *SDLGetRendererName(void);