From: Holger Schemel Date: Fri, 16 Nov 2018 21:25:30 +0000 (+0100) Subject: fixed handling debug keys to prevent handling keys twice X-Git-Tag: 4.1.2.0~94 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=d81b002c4d63b292284b1bea1972b4d764f6fb59;p=rocksndiamonds.git fixed handling debug keys to prevent handling keys twice This change has two effects: - handle debug keys before handling all other defined keys - if debug key was processed, do not handle this key again --- diff --git a/src/events.c b/src/events.c index 0c5b2bc1..6fee5bbc 100644 --- a/src/events.c +++ b/src/events.c @@ -1778,11 +1778,14 @@ static void HandleKeysSpecial(Key key) } } -void HandleKeysDebug(Key key) +boolean HandleKeysDebug(Key key, int key_status) { #ifdef DEBUG int i; + if (key_status != KEY_PRESSED) + return FALSE; + if (game_status == GAME_MODE_PLAYING || !setup.debug.frame_delay_game_only) { boolean mod_key_pressed = ((GetKeyModState() & KMOD_Valid) != KMOD_None); @@ -1809,7 +1812,7 @@ void HandleKeysDebug(Key key) else Error(ERR_DEBUG, "frame delay == 0 ms (maximum speed)"); - break; + return TRUE; } } } @@ -1822,13 +1825,19 @@ void HandleKeysDebug(Key key) Error(ERR_DEBUG, "debug mode %s", (options.debug ? "enabled" : "disabled")); + + return TRUE; } else if (key == KSYM_v) { Error(ERR_DEBUG, "currently using game engine version %d", game.engine_version); + + return TRUE; } } + + return FALSE; #endif } @@ -1856,6 +1865,9 @@ void HandleKey(Key key, int key_status) int joy = 0; int i; + if (HandleKeysDebug(key, key_status)) + return; // do not handle already processed keys again + // map special keys (media keys / remote control buttons) to default keys if (key == KSYM_PlayPause) key = KSYM_space; @@ -2198,8 +2210,6 @@ void HandleKey(Key key, int key_status) return; } } - - HandleKeysDebug(key); } void HandleNoEvent(void) diff --git a/src/events.h b/src/events.h index 47a86c56..93504eb9 100644 --- a/src/events.h +++ b/src/events.h @@ -31,7 +31,7 @@ void HandleWindowEvent(WindowEvent *); void HandleFingerEvent(FingerEvent *); void HandleTextEvent(TextEvent *); void HandlePauseResumeEvent(PauseResumeEvent *); -void HandleKeysDebug(Key); +boolean HandleKeysDebug(Key, int); void HandleKeyEvent(KeyEvent *); void HandleFocusEvent(FocusChangeEvent *); void HandleClientMessageEvent(ClientMessageEvent *); diff --git a/src/tools.c b/src/tools.c index 7e6424f8..451ef014 100644 --- a/src/tools.c +++ b/src/tools.c @@ -4387,7 +4387,7 @@ static int RequestHandleEvents(unsigned int req_state) break; default: - HandleKeysDebug(key); + HandleKeysDebug(key, KEY_PRESSED); break; }