Fix some old holdtap inconsistencies

This commit is contained in:
xs5871 2023-03-15 20:59:03 +00:00 committed by xs5871
parent 26bf630608
commit ba06d3c8a5
3 changed files with 11 additions and 12 deletions

View File

@ -268,8 +268,9 @@ class KMKKeyboard:
key: Key, key: Key,
is_pressed: bool, is_pressed: bool,
int_coord: Optional[int] = None, int_coord: Optional[int] = None,
reprocess: Optional[bool] = False,
) -> None: ) -> None:
index = self.modules.index(module) + 1 index = self.modules.index(module) + (0 if reprocess else 1)
ksf = KeyBufferFrame( ksf = KeyBufferFrame(
key=key, is_pressed=is_pressed, int_coord=int_coord, index=index key=key, is_pressed=is_pressed, int_coord=int_coord, index=index
) )

View File

@ -98,15 +98,12 @@ class HoldTap(Module):
self.ht_activate_on_interrupt( self.ht_activate_on_interrupt(
key, keyboard, *state.args, **state.kwargs key, keyboard, *state.args, **state.kwargs
) )
append_buffer = True
send_buffer = True send_buffer = True
# if interrupt on release: store interrupting keys until one of them # if interrupt on release: store interrupting keys until one of them
# is released. # is released.
if ( if key.meta.tap_interrupted and is_pressed:
key.meta.tap_interrupted
and is_pressed
and not isinstance(current_key.meta, HoldTapKeyMeta)
):
append_buffer = True append_buffer = True
# apply changes with 'side-effects' on key_states or the loop behaviour # apply changes with 'side-effects' on key_states or the loop behaviour
@ -115,10 +112,8 @@ class HoldTap(Module):
self.key_buffer.append((int_coord, current_key, is_pressed)) self.key_buffer.append((int_coord, current_key, is_pressed))
current_key = None current_key = None
elif send_buffer: if send_buffer:
self.send_key_buffer(keyboard) self.send_key_buffer(keyboard)
keyboard.resume_process_key(self, current_key, is_pressed, int_coord)
current_key = None
return current_key return current_key
@ -226,8 +221,11 @@ class HoldTap(Module):
if not self.key_buffer: if not self.key_buffer:
return return
reprocess = False
for (int_coord, key, is_pressed) in self.key_buffer: for (int_coord, key, is_pressed) in self.key_buffer:
keyboard.resume_process_key(self, key, is_pressed, int_coord) keyboard.resume_process_key(self, key, is_pressed, int_coord, reprocess)
if isinstance(key.meta, HoldTapKeyMeta):
reprocess = True
self.key_buffer.clear() self.key_buffer.clear()

View File

@ -172,7 +172,7 @@ class TestHoldTap(unittest.TestCase):
'chained 1', 'chained 1',
[(2, True), (1, True), (0, True), (0, False), (1, False), (2, False)], [(2, True), (1, True), (0, True), (0, False), (1, False), (2, False)],
[ [
{KC.LCTL}, {KC.LSFT},
{KC.LCTL, KC.LSFT}, {KC.LCTL, KC.LSFT},
{KC.LCTL, KC.LSFT, KC.N0}, {KC.LCTL, KC.LSFT, KC.N0},
{KC.LCTL, KC.LSFT}, {KC.LCTL, KC.LSFT},
@ -224,7 +224,7 @@ class TestHoldTap(unittest.TestCase):
'chained 5', 'chained 5',
[(3, True), (1, True), (0, True), (0, False), (1, False), (3, False)], [(3, True), (1, True), (0, True), (0, False), (1, False), (3, False)],
[ [
{KC.LCTL}, {KC.N3},
{KC.LCTL, KC.N3}, {KC.LCTL, KC.N3},
{KC.LCTL, KC.N3, KC.N0}, {KC.LCTL, KC.N3, KC.N0},
{KC.LCTL, KC.N3}, {KC.LCTL, KC.N3},