Skip to content

Commit

Permalink
Fix broken release of modifiers and improve tests
Browse files Browse the repository at this point in the history
  • Loading branch information
okke-formsma committed Sep 10, 2020
1 parent 71e0e81 commit ecb4249
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/src/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ static int modifier_counts[8] = {0, 0, 0, 0, 0, 0, 0, 0};
int zmk_hid_register_mod(zmk_mod modifier)
{
modifier_counts[modifier]++;
LOG_DBG("Modifier %d count %d", modifier, modifier_counts[modifier]);
WRITE_BIT(kp_report.body.modifiers, modifier, true);
return 0;
}
Expand All @@ -36,8 +37,9 @@ int zmk_hid_unregister_mod(zmk_mod modifier)
return -EINVAL;
}
modifier_counts[modifier]--;
LOG_DBG("Modifier %d count: %d", modifier, modifier_counts[modifier]);
if (modifier_counts[modifier] == 0) {
LOG_DBG("Modifier %d released.", modifier);
LOG_DBG("Modifier %d released", modifier);
WRITE_BIT(kp_report.body.modifiers, modifier, false);
}
return 0;
Expand Down Expand Up @@ -129,7 +131,7 @@ int zmk_hid_keypad_release(zmk_key code)
{
zmk_mod_flags mods = SELECT_MODS(code);
if (mods) {
return zmk_hid_unregister_mod(mods);
return zmk_hid_unregister_mods(mods);
}
code = STRIP_MODS(code);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
pressed: usage_page 0x07 keycode 0x05 mods 0x02
reg: Modifier 1 count 1
pressed: usage_page 0x07 keycode 0x04 mods 0x02
reg: Modifier 1 count 2
released: usage_page 0x07 keycode 0x04 mods 0x02
unreg: Modifier 1 count: 1
released: usage_page 0x07 keycode 0x05 mods 0x02
unreg: Modifier 1 count: 0
unreg: Modifier 1 released

0 comments on commit ecb4249

Please sign in to comment.