diff options
author | dec05eba <dec05eba@protonmail.com> | 2025-03-23 00:22:49 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2025-03-23 00:22:49 +0100 |
commit | 726e0c7dcea3f187ac02bcd25a1a049b98b84502 (patch) | |
tree | 1f6b1ae4f77932193e2d97f7b9f95817c75ffa97 /tools/gsr-global-hotkeys/keyboard_event.c | |
parent | fcc3bf3d503ccb8292bd211360a2acf9ad88ff88 (diff) |
Allow binding non alpha-numerical keys without a modifier
Diffstat (limited to 'tools/gsr-global-hotkeys/keyboard_event.c')
-rw-r--r-- | tools/gsr-global-hotkeys/keyboard_event.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/tools/gsr-global-hotkeys/keyboard_event.c b/tools/gsr-global-hotkeys/keyboard_event.c index f3fba62..c2bd75a 100644 --- a/tools/gsr-global-hotkeys/keyboard_event.c +++ b/tools/gsr-global-hotkeys/keyboard_event.c @@ -575,6 +575,13 @@ static int parse_u8(const char *str, int size) { return result; } +static bool is_key_alpha_numerical(uint8_t key) { + return (key >= KEY_1 && key <= KEY_0) + || (key >= KEY_Q && key <= KEY_P) + || (key >= KEY_A && key <= KEY_L) + || (key >= KEY_Z && key <= KEY_M); +} + static bool keyboard_event_parse_bind_keys(const char *str, int size, uint8_t *key, uint32_t *modifiers) { *key = 0; *modifiers = 0; @@ -609,13 +616,13 @@ static bool keyboard_event_parse_bind_keys(const char *str, int size, uint8_t *k break; } - if(key == 0) { + if(*key == 0) { fprintf(stderr, "Error: can't bind hotkey without a non-modifier key\n"); return false; } - if(modifiers == 0) { - fprintf(stderr, "Error: can't bind hotkey without a modifier\n"); + if(*modifiers == 0 && is_key_alpha_numerical(*key)) { + fprintf(stderr, "Error: can't bind hotkey without a modifier unless the key is a non alpha-numerical key\n"); return false; } |