summaryrefslogtreecommitdiffstats
path: root/sway/input_state.c
diff options
context:
space:
mode:
authorLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-01-05 00:49:11 +0100
committerLibravatar Mikkel Oscar Lyderik <mikkeloscar@gmail.com>2016-01-05 00:49:44 +0100
commit7727c9efbc105269befe06a5bb12d2019c52515e (patch)
tree14ae600a7fe97012c4a2a8bbd4e2d9abecc2e105 /sway/input_state.c
parentMerge pull request #432 from mikkeloscar/fix-sway-multikey (diff)
downloadsway-7727c9efbc105269befe06a5bb12d2019c52515e.tar.gz
sway-7727c9efbc105269befe06a5bb12d2019c52515e.tar.zst
sway-7727c9efbc105269befe06a5bb12d2019c52515e.zip
Detect bar modifier pressed/released
Diffstat (limited to 'sway/input_state.c')
-rw-r--r--sway/input_state.c24
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 {
22 22
23static struct key_state key_state_array[KEY_STATE_MAX_LENGTH]; 23static struct key_state key_state_array[KEY_STATE_MAX_LENGTH];
24 24
25static uint32_t modifiers_state;
26
25void input_init(void) { 27void input_init(void) {
26 int i; 28 int i;
27 for (i = 0; i < KEY_STATE_MAX_LENGTH; ++i) { 29 for (i = 0; i < KEY_STATE_MAX_LENGTH; ++i) {
28 struct key_state none = { 0, 0, 0 }; 30 struct key_state none = { 0, 0, 0 };
29 key_state_array[i] = none; 31 key_state_array[i] = none;
30 } 32 }
33
34 modifiers_state = 0;
35}
36
37uint32_t modifier_state_changed(uint32_t new_state, uint32_t mod) {
38 if ((new_state & mod) != 0) { // pressed
39 if ((modifiers_state & mod) != 0) { // already pressed
40 return MOD_STATE_UNCHANGED;
41 } else { // pressed
42 return MOD_STATE_PRESSED;
43 }
44 } else { // not pressed
45 if ((modifiers_state & mod) != 0) { // released
46 return MOD_STATE_RELEASED;
47 } else { // already released
48 return MOD_STATE_UNCHANGED;
49 }
50 }
51}
52
53void modifiers_state_update(uint32_t new_state) {
54 modifiers_state = new_state;
31} 55}
32 56
33static uint8_t find_key(uint32_t key_sym, uint32_t key_code, bool update) { 57static uint8_t find_key(uint32_t key_sym, uint32_t key_code, bool update) {