diff options
author | Drew DeVault <[email protected]> | 2016-01-06 07:26:54 -0500 |
---|---|---|
committer | Drew DeVault <[email protected]> | 2016-01-06 07:26:54 -0500 |
commit | 8f5de70c93b2afaab0dd7d384c58ff3d3007193c (patch) | |
tree | 4826eca48ec5d4d2b827477c74de7d500f39f0fa /sway/input_state.c | |
parent | 18f81850114af1ca969387e0715d9284e77b0148 (diff) | |
parent | 843e2ad2c140288733110691f7dc8252fbe4dc16 (diff) |
Merge pull request #434 from mikkeloscar/detect-modifier
Send IPC modifier event on bar_modifier up/down
Diffstat (limited to 'sway/input_state.c')
-rw-r--r-- | sway/input_state.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sway/input_state.c b/sway/input_state.c index 58619d1f..2f40b6c2 100644 --- a/sway/input_state.c +++ b/sway/input_state.c @@ -22,12 +22,36 @@ struct key_state { static struct key_state key_state_array[KEY_STATE_MAX_LENGTH]; +static uint32_t modifiers_state; + void input_init(void) { int i; for (i = 0; i < KEY_STATE_MAX_LENGTH; ++i) { struct key_state none = { 0, 0, 0 }; key_state_array[i] = none; } + + modifiers_state = 0; +} + +uint32_t modifier_state_changed(uint32_t new_state, uint32_t mod) { + if ((new_state & mod) != 0) { // pressed + if ((modifiers_state & mod) != 0) { // already pressed + return MOD_STATE_UNCHANGED; + } else { // pressed + return MOD_STATE_PRESSED; + } + } else { // not pressed + if ((modifiers_state & mod) != 0) { // released + return MOD_STATE_RELEASED; + } else { // already released + return MOD_STATE_UNCHANGED; + } + } +} + +void modifiers_state_update(uint32_t new_state) { + modifiers_state = new_state; } static uint8_t find_key(uint32_t key_sym, uint32_t key_code, bool update) { |