diff options
Diffstat (limited to 'src/user/knob')
-rw-r--r-- | src/user/knob/key.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/user/knob/key.c b/src/user/knob/key.c index 1506f3b..b2e3f5e 100644 --- a/src/user/knob/key.c +++ b/src/user/knob/key.c @@ -1,4 +1,5 @@ #include <keypack.h> +#include <stdbool.h> static const char no_mod[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, '\t','\n', 0, 0, 0, 0, 0, @@ -48,7 +49,7 @@ static const char num[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '*', '+', '\n', '-', '.', '/' }; -__attribute__ ((pure)) +__attribute__ ((const)) char key_to_char(struct key_packet kp) { if (kp.key_id < 0x80) { const char ch = (kp.modifiers & SHIFTS @@ -64,4 +65,13 @@ char key_to_char(struct key_packet kp) { else return 0; +} + +__attribute__ ((const)) +bool match_side_agnostic(struct key_packet a, struct key_packet b) { + return (a.key_id == b.key_id) && + ((bool)(a.modifiers & SHIFTS) == (bool)(b.modifiers & SHIFTS)) && + ((bool)(a.modifiers & CTRLS) == (bool)(b.modifiers & CTRLS)) && + ((bool)(a.modifiers & ALTS) == (bool)(b.modifiers & ALTS)) && + ((bool)(a.modifiers & WINS) == (bool)(b.modifiers & WINS)); }
\ No newline at end of file |