diff options
| author | Louis Burda <quent.burda@gmail.com> | 2023-02-13 01:02:05 +0100 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2023-02-13 01:02:05 +0100 |
| commit | ecc81e80a5cc4320bc565e270e2185d9cf402b35 (patch) | |
| tree | ce02b1b962f44f01a110cbf40ca5c985fa5905c9 /src | |
| parent | 75991f63b5a061592d57b59a9c4f46a078d19406 (diff) | |
| download | sxkbd-ecc81e80a5cc4320bc565e270e2185d9cf402b35.tar.gz sxkbd-ecc81e80a5cc4320bc565e270e2185d9cf402b35.zip | |
Only update weakmods when new keycode is added
Diffstat (limited to 'src')
| -rw-r--r-- | src/hid.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -296,8 +296,6 @@ process_keydown(uint32_t keysym, uint x, uint y) add_keycode(TO_KC(keysym)); } else if (IS_KC(keysym) && IS_MOD_KC(TO_KC(keysym))) { active_mods |= MOD_BIT(TO_KC(keysym)); - } else if (IS_MOD(keysym)) { - active_mods |= parse_modifiers(keysym); } } @@ -367,14 +365,26 @@ bool update_keyboard_report(struct hid_keyboard_report *new, struct hid_keyboard_report *old) { - return memcmp(new, old, sizeof(struct hid_keyboard_report)); + return memcmp(new->codes, old->codes, HID_REPORT_CODES); } bool update_weak_mods(struct hid_keyboard_report *new, struct hid_keyboard_report *old) { - return memcmp(new->codes, old->codes, HID_REPORT_CODES); + int i, k; + + /* only need weak modes if new keycode added */ + for (i = 0; i < new->cnt; i++) { + for (k = 0; k < old->cnt; k++) { + if (new->codes[i] != old->codes[k]) + break; + } + if (k == old->cnt) + return true; + } + + return false; } bool |
