Skip to content

Commit

Permalink
Count repeat presses of the keyboard shortcut
Browse files Browse the repository at this point in the history
Allows shortcuts such as:
CTRL + n + n to open the settings panel
  • Loading branch information
brunoais committed Apr 17, 2021
1 parent c4f3a76 commit 90e6ffa
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/src/input_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 90e6ffa

Please sign in to comment.