diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-01-07 16:38:33 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-01-07 16:38:33 -0500 |
commit | 320c2915b0aeb4bbecb753bf00091e24905c5652 (patch) | |
tree | a854f1068b7360952835b38bc38a1138bf1de7f0 /sway/input_state.c | |
parent | 8f5de70c93b2afaab0dd7d384c58ff3d3007193c (diff) | |
parent | 55f63935ab9319da8e145b49edc1a7ae3e6782c6 (diff) |
Merge pull request #439 from mikkeloscar/bindsym-release
Implement bindsym --release
Diffstat (limited to 'sway/input_state.c')
-rw-r--r-- | sway/input_state.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sway/input_state.c b/sway/input_state.c index 2f40b6c2..86868083 100644 --- a/sway/input_state.c +++ b/sway/input_state.c @@ -22,6 +22,8 @@ struct key_state { static struct key_state key_state_array[KEY_STATE_MAX_LENGTH]; +static struct key_state last_released; + static uint32_t modifiers_state; void input_init(void) { @@ -31,6 +33,9 @@ void input_init(void) { key_state_array[i] = none; } + struct key_state none = { 0, 0, 0 }; + last_released = none; + modifiers_state = 0; } @@ -76,6 +81,12 @@ bool check_key(uint32_t key_sym, uint32_t key_code) { return find_key(key_sym, key_code, false) < KEY_STATE_MAX_LENGTH; } +bool check_released_key(uint32_t key_sym) { + return (key_sym != 0 + && (last_released.key_sym == key_sym + || last_released.alt_sym == key_sym)); +} + void press_key(uint32_t key_sym, uint32_t key_code) { if (key_code == 0) { return; @@ -94,6 +105,9 @@ void press_key(uint32_t key_sym, uint32_t key_code) { void release_key(uint32_t key_sym, uint32_t key_code) { uint8_t index = find_key(key_sym, key_code, true); if (index < KEY_STATE_MAX_LENGTH) { + last_released.key_sym = key_state_array[index].key_sym; + last_released.alt_sym = key_state_array[index].alt_sym; + last_released.key_code = key_state_array[index].key_code; struct key_state none = { 0, 0, 0 }; key_state_array[index] = none; } |