Skip to content

Commit

Permalink
Fix retaining key release from rolls into HT (#979)
Browse files Browse the repository at this point in the history
  • Loading branch information
xs5871 authored Jun 8, 2024
1 parent d29bdf2 commit 05b96e0
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kmk/modules/holdtap.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def process_key(self, keyboard, key, is_pressed, int_coord):

# holdtap isn't interruptable, resolves on ht_release or timeout.
if not key.meta.tap_interrupted and not key.meta.prefer_hold:
append_buffer = True
append_buffer = is_pressed or self.key_buffer
continue

# holdtap is interrupted by another key event.
Expand Down
77 changes: 77 additions & 0 deletions tests/test_holdtap.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,80 @@ def test_holdtap_repeat(self):
[(2, True), (2, False), (2, True), t_after, (2, False)],
[{KC.A}, {}, {KC.B}, {}],
)

def test_holdtap_roll_into(self):
t_after = self.t_after

keyboard = KeyboardTest(
[HoldTap()],
[
[
KC.N0,
KC.HT(
KC.N1,
KC.A,
prefer_hold=True,
tap_interrupted=True,
),
KC.HT(
KC.N2,
KC.B,
prefer_hold=False,
),
KC.HT(
KC.N3,
KC.C,
prefer_hold=True,
),
],
],
debug_enabled=False,
)

keyboard.test(
'roll into tap',
[(0, True), (1, True), (0, False), (1, False)],
[{KC.N0}, {}, {KC.N1}, {}],
)

keyboard.test(
'roll into hold',
[(0, True), (1, True), t_after, (0, False), (1, False)],
[{KC.N0}, {KC.N0, KC.A}, {KC.A}, {}],
)

keyboard.test(
'roll into hold w other release',
[(0, True), (1, True), (0, False), t_after, (1, False)],
[{KC.N0}, {}, {KC.A}, {}],
)

keyboard.test(
'roll into tap w prefer_hold',
[(0, True), (2, True), (0, False), (2, False)],
[{KC.N0}, {}, {KC.N2}, {}],
)

keyboard.test(
'roll into tap from HT',
[(2, True), (1, True), (2, False), (1, False)],
[{KC.N2}, {}, {KC.N1}, {}],
)

keyboard.test(
'roll into tap from HT',
[(1, True), (2, True), (1, False), (2, False)],
[{KC.N1}, {}, {KC.N2}, {}],
)

keyboard.test(
'roll into tap from HT',
[(1, True), (3, True), (1, False), (3, False)],
[{KC.N1}, {}, {KC.N3}, {}],
)

keyboard.test(
'roll into tap from HT',
[(3, True), (1, True), (3, False), (1, False)],
[{KC.C}, {}, {KC.N1}, {}],
)

0 comments on commit 05b96e0

Please sign in to comment.