From 5a53ae0c5ee5c9c61fdc3a103b92a8a85add50d2 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 14 Sep 2020 21:42:59 +0200 Subject: [PATCH] fixed key shortcut to start/end game (broken by regression) This change fixes a regression of commit 888ee049 (and 35da46e4) that causes problems when handling text input in situations unrelated to the Android screen keyboard, like entering key shortcuts to start and end a game on non-Android platforms. This commit fixes a bug that results in restarting the game when the player has died and the "space" key (or other configured key) was used to return to the main menu (or level editor). --- src/events.c | 4 ++++ src/libgame/sdl.h | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/events.c b/src/events.c index 2df4eb7b..c18a8a46 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; + // ignore raw keys as text input when not in text input mode + if (KSYM_RAW(key) && !textinput_status) + return FALSE; + // else handle all printable keys as text input return KSYM_PRINTABLE(key); } diff --git a/src/libgame/sdl.h b/src/libgame/sdl.h index 9fb16338..dfdd4a40 100644 --- a/src/libgame/sdl.h +++ b/src/libgame/sdl.h @@ -350,6 +350,12 @@ typedef struct UserEventInfo UserEvent; #define KSYM_FKEY_LAST KSYM_F12 #define KSYM_NUM_FKEYS (KSYM_FKEY_LAST - KSYM_FKEY_FIRST + 1) +#define KSYM_RAW(k) (((k) >= KSYM_a && \ + (k) <= KSYM_z) || \ + ((k) >= KSYM_0 && \ + (k) <= KSYM_9) || \ + (k) == KSYM_space) + #define KSYM_PRINTABLE(k) (((k) >= KSYM_space && \ (k) <= KSYM_z) || \ (k) == KSYM_Adiaeresis || \ -- 2.34.1