Skip to content

Commit

Permalink
Fix continuous sprinting when using a modifier key
Browse files Browse the repository at this point in the history
as a mapping key (#142).

When holding a key(W,A,S,D) and then pressing a modifier(SHIFT,CTRL,ALT),
we get two sets {MOD,MOD,0} and {KEY,MOD,0} with MOD > 0 after a
{KEY,0,0}. When releasing the initial key while holding the modifier,
we search for {KEY,MOD,0} instead of {KEY,0,0} to be removed.

Finally, when releasing the modifier, we remove {MOD,MOD,0} from our
stack. This means the {KEY,0,0} stays "pressed", although no input
is being taken from the keyboard.

Full example using WASD as movement keys and L_SHIFT as our B button.
1. Press and hold "A" --> add {A,0,0} to stack;
2. Press "L_SHIFT" --> add {L_SHIFT,4,0} and {A,4,0} to stack;
3. Release "A" --> remove {A,4,0} from stack (no effect);
4. Release "L_SHIFT" --> remove {L_SHIFT,4,0} from stack;
5. {A,0,0} still on stack.

No keyboard button is being pressed anymore, but there is a continuous
movement towards the direction mapped by "A" {A,0,0}. It is only fixed
when "A" is pressed two times in succession, because we don't add
duplicate sets to our stack, but try to remove them anyway.
  • Loading branch information
denisfa authored and rkitover committed May 22, 2019
1 parent 5045971 commit 22307de
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/wx/panel.cpp
Expand Up @@ -1183,6 +1183,9 @@ static bool process_key_press(bool down, int key, int mod, int joy = 0)
mod |= wxMOD_RAW_CONTROL;
break;
#endif
default:
mod = 0;
break;
}

// check if key is already pressed
Expand Down

0 comments on commit 22307de

Please sign in to comment.