Skip to content

Commit cf5d834

Browse files
authored
fix(combo): emit result to processing pipeline (#1086)
This is necessary in order for other processing modules (sticky keys, holdtap, etc.) to see the combo result as a "regular" key event.
1 parent 0079b9e commit cf5d834

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

kmk/modules/combos.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,13 +301,13 @@ def send_key_buffer(self, keyboard):
301301
def activate(self, keyboard, combo):
302302
if debug.enabled:
303303
debug('activate', combo)
304-
combo.result.on_press(keyboard)
304+
keyboard.resume_process_key(self, combo.result, True)
305305
combo._state = _ComboState.ACTIVE
306306

307307
def deactivate(self, keyboard, combo):
308308
if debug.enabled:
309309
debug('deactivate', combo)
310-
combo.result.on_release(keyboard)
310+
keyboard.resume_process_key(self, combo.result, False)
311311
combo._state = _ComboState.IDLE
312312

313313
def reset_combo(self, keyboard, combo):

tests/test_combos_sticky_keys.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import unittest
2+
3+
from kmk.keys import KC
4+
from kmk.modules.combos import Chord, Combo, Combos
5+
from kmk.modules.sticky_keys import StickyKeys
6+
from tests.keyboard_test import KeyboardTest
7+
8+
t_within = 2 * KeyboardTest.loop_delay_ms
9+
t_combo = 6 * KeyboardTest.loop_delay_ms
10+
t_sticky = 8 * KeyboardTest.loop_delay_ms
11+
t_after = 11 * KeyboardTest.loop_delay_ms
12+
13+
# overide default timeouts
14+
Combo.timeout = t_combo
15+
16+
combos = Combos()
17+
combos.combos = [
18+
Chord((KC.N0, KC.N1), KC.A),
19+
]
20+
21+
sticky_keys = StickyKeys(release_after=t_sticky)
22+
23+
kb = KeyboardTest(
24+
[combos, sticky_keys],
25+
[[KC.N0, KC.N1, KC.SK(KC.LSFT)]],
26+
debug_enabled=True,
27+
)
28+
29+
30+
class TestCombo(unittest.TestCase):
31+
def test_0(self):
32+
kb.test(
33+
'',
34+
[(2, True), (2, False), (0, True), (1, True), (0, False), (1, False)],
35+
[{KC.LSFT}, {KC.LSFT, KC.A}, {KC.LSFT}, {}],
36+
)
37+
38+
def test_1(self):
39+
kb.test(
40+
'',
41+
[(2, True), (0, True), (2, False), (1, True), (0, False), (1, False)],
42+
[{KC.LSFT}, {KC.LSFT, KC.N0}, {KC.N0}, {KC.N0, KC.N1}, {KC.N1}, {}],
43+
)
44+
45+
def test_2(self):
46+
kb.test(
47+
'',
48+
[
49+
(2, True),
50+
t_after,
51+
(0, True),
52+
(1, True),
53+
(2, False),
54+
(0, False),
55+
(1, False),
56+
],
57+
[{KC.LSFT}, {KC.LSFT, KC.A}, {KC.A}, {}],
58+
)

0 commit comments

Comments
 (0)