Fix layer tap interrupted

This commit is contained in:
xs5871
2023-03-13 22:14:49 +00:00
committed by xs5871
parent 878fe0deca
commit 26bf630608
6 changed files with 38 additions and 9 deletions

View File

@@ -11,8 +11,8 @@ class TestHoldTap(unittest.TestCase):
KC.clear()
self.t_within = 2 * KeyboardTest.loop_delay_ms
self.t_after = 5 * KeyboardTest.loop_delay_ms
tap_time = (self.t_after + self.t_within) // 2
self.t_after = 6 * KeyboardTest.loop_delay_ms
tap_time = 5 * KeyboardTest.loop_delay_ms
# overide default timeouts
HoldTap.tap_time = tap_time
@@ -91,13 +91,13 @@ class TestHoldTap(unittest.TestCase):
keyboard.test(
'LT within tap time rolling -> tap behavior',
[(1, True), t_within, (3, True), t_after, (1, False), (3, False)],
[(1, True), t_within, (3, True), (1, False), (3, False)],
[{KC.B}, {KC.B, KC.D}, {KC.D}, {}],
)
keyboard.test(
'LT within tap time nested -> tap behavior',
[(1, True), t_within, (3, True), (3, False), t_after, (1, False)],
[(1, True), t_within, (3, True), (3, False), (1, False)],
[{KC.B}, {KC.B, KC.D}, {KC.B}, {}],
)

View File

@@ -10,8 +10,13 @@ class TestLayers(unittest.TestCase):
self.kb = KeyboardTest(
[Layers()],
[
[KC.N0, KC.LM(1, KC.LCTL)],
[KC.A, KC.B],
[
KC.N0,
KC.LM(1, KC.LCTL),
KC.LT(1, KC.N2, tap_interrupted=True, prefer_hold=True),
KC.LT(1, KC.N3, tap_interrupted=False, prefer_hold=True),
],
[KC.A, KC.B, KC.C, KC.D],
],
debug_enabled=False,
)
@@ -23,6 +28,25 @@ class TestLayers(unittest.TestCase):
[{KC.LCTL}, {KC.LCTL, KC.A}, {KC.A}, {}],
)
def test_layertap(self):
self.kb.test(
'Layertap roll',
[(2, True), (0, True), (2, False), (0, False)],
[{KC.N2}, {KC.N0, KC.N2}, {KC.N0}, {}],
)
self.kb.test(
'Layertap tap interrupted',
[(2, True), (0, True), 200, (0, False), (2, False)],
[{KC.A}, {}],
)
self.kb.test(
'Layertap tap interrupted by holdtap',
[(3, True), (2, True), (2, False), (3, False)],
[{KC.C}, {}],
)
if __name__ == '__main__':
unittest.main()