From: Holger Schemel Date: Mon, 14 Sep 2020 19:42:59 +0000 (+0200) Subject: fixed key shortcut to start/end game (broken by regression) X-Git-Tag: 4.2.0.3~43 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=5a53ae0c5ee5c9c61fdc3a103b92a8a85add50d2;p=rocksndiamonds.git 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). --- 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 || \