mirror of
https://github.com/swaywm/sway.git
synced 2026-03-31 07:11:24 -04:00
Detect bar modifier pressed/released
This commit is contained in:
parent
f9b92783c5
commit
7727c9efbc
4 changed files with 61 additions and 1 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue