From 90e6ffa1e0267f05ba84dff6824f24057583487a Mon Sep 17 00:00:00 2001 From: brunoais Date: Sat, 17 Apr 2021 13:15:31 +0100 Subject: [PATCH] Count repeat presses of the keyboard shortcut Allows shortcuts such as: CTRL + n + n to open the settings panel --- app/src/input_manager.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/src/input_manager.c b/app/src/input_manager.c index b8a8c84602..51e079c979 100644 --- a/app/src/input_manager.c +++ b/app/src/input_manager.c @@ -394,6 +394,19 @@ input_manager_process_key(struct input_manager *im, bool shift = event->keysym.mod & KMOD_SHIFT; bool repeat = event->repeat; + static SDL_Keycode lastKeycode = -1; + static Uint16 lastMod = -1; + static int repeatCount = 0; + + if(down && keycode == lastKeycode && event->keysym.mod == lastMod){ + repeatCount++; + LOGD("Repeat %d -> %d", keycode, repeatCount); + } else if(down) { + repeatCount = 0; + lastKeycode = keycode; + lastMod = event->keysym.mod; + } + // The shortcut modifier is pressed if (smod) { int action = down ? ACTION_DOWN : ACTION_UP;