Fix some old holdtap inconsistencies
This commit is contained in:
		@@ -268,8 +268,9 @@ class KMKKeyboard:
 | 
			
		||||
        key: Key,
 | 
			
		||||
        is_pressed: bool,
 | 
			
		||||
        int_coord: Optional[int] = None,
 | 
			
		||||
        reprocess: Optional[bool] = False,
 | 
			
		||||
    ) -> None:
 | 
			
		||||
        index = self.modules.index(module) + 1
 | 
			
		||||
        index = self.modules.index(module) + (0 if reprocess else 1)
 | 
			
		||||
        ksf = KeyBufferFrame(
 | 
			
		||||
            key=key, is_pressed=is_pressed, int_coord=int_coord, index=index
 | 
			
		||||
        )
 | 
			
		||||
 
 | 
			
		||||
@@ -98,15 +98,12 @@ class HoldTap(Module):
 | 
			
		||||
                self.ht_activate_on_interrupt(
 | 
			
		||||
                    key, keyboard, *state.args, **state.kwargs
 | 
			
		||||
                )
 | 
			
		||||
                append_buffer = True
 | 
			
		||||
                send_buffer = True
 | 
			
		||||
 | 
			
		||||
            # if interrupt on release: store interrupting keys until one of them
 | 
			
		||||
            # is released.
 | 
			
		||||
            if (
 | 
			
		||||
                key.meta.tap_interrupted
 | 
			
		||||
                and is_pressed
 | 
			
		||||
                and not isinstance(current_key.meta, HoldTapKeyMeta)
 | 
			
		||||
            ):
 | 
			
		||||
            if key.meta.tap_interrupted and is_pressed:
 | 
			
		||||
                append_buffer = True
 | 
			
		||||
 | 
			
		||||
        # 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))
 | 
			
		||||
            current_key = None
 | 
			
		||||
 | 
			
		||||
        elif send_buffer:
 | 
			
		||||
        if send_buffer:
 | 
			
		||||
            self.send_key_buffer(keyboard)
 | 
			
		||||
            keyboard.resume_process_key(self, current_key, is_pressed, int_coord)
 | 
			
		||||
            current_key = None
 | 
			
		||||
 | 
			
		||||
        return current_key
 | 
			
		||||
 | 
			
		||||
@@ -226,8 +221,11 @@ class HoldTap(Module):
 | 
			
		||||
        if not self.key_buffer:
 | 
			
		||||
            return
 | 
			
		||||
 | 
			
		||||
        reprocess = False
 | 
			
		||||
        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()
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -172,7 +172,7 @@ class TestHoldTap(unittest.TestCase):
 | 
			
		||||
            'chained 1',
 | 
			
		||||
            [(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.N0},
 | 
			
		||||
                {KC.LCTL, KC.LSFT},
 | 
			
		||||
@@ -224,7 +224,7 @@ class TestHoldTap(unittest.TestCase):
 | 
			
		||||
            'chained 5',
 | 
			
		||||
            [(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.N0},
 | 
			
		||||
                {KC.LCTL, KC.N3},
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user