add continue-with-module-nr-idx to key processing
This commit is contained in:
parent
f62d32157a
commit
9d555209b8
@ -158,8 +158,8 @@ class KMKKeyboard:
|
||||
def debug_enabled(self, enabled):
|
||||
debug.enabled = enabled
|
||||
|
||||
def pre_process_key(self, key, is_pressed, int_coord=None):
|
||||
for module in self.modules:
|
||||
def pre_process_key(self, key, is_pressed, int_coord=None, index=0):
|
||||
for module in self.modules[index:]:
|
||||
try:
|
||||
key = module.process_key(self, key, is_pressed, int_coord)
|
||||
if key is None:
|
||||
|
@ -81,6 +81,7 @@ class Combos(Module):
|
||||
)
|
||||
|
||||
def during_bootup(self, keyboard):
|
||||
self._next_module = keyboard.modules.index(self) + 1
|
||||
self.reset(keyboard)
|
||||
|
||||
def before_matrix_scan(self, keyboard):
|
||||
@ -263,9 +264,7 @@ class Combos(Module):
|
||||
if new_key is None:
|
||||
new_key = keyboard._find_key_in_map(int_coord)
|
||||
|
||||
keyboard._coordkeys_pressed[int_coord] = new_key
|
||||
|
||||
keyboard.process_key(new_key, is_pressed)
|
||||
keyboard.pre_process_key(new_key, is_pressed, int_coord, self._next_module)
|
||||
keyboard._send_hid()
|
||||
|
||||
def activate(self, keyboard, combo):
|
||||
|
@ -49,7 +49,7 @@ class HoldTap(Module):
|
||||
)
|
||||
|
||||
def during_bootup(self, keyboard):
|
||||
return
|
||||
self._next_module = keyboard.modules.index(self) + 1
|
||||
|
||||
def before_matrix_scan(self, keyboard):
|
||||
return
|
||||
@ -176,25 +176,24 @@ class HoldTap(Module):
|
||||
del self.key_states[key]
|
||||
|
||||
def send_key_buffer(self, keyboard):
|
||||
key_buffer = self.key_buffer
|
||||
self.key_buffer = []
|
||||
for (int_coord, key) in key_buffer:
|
||||
for (int_coord, key) in self.key_buffer:
|
||||
new_key = keyboard._find_key_in_map(int_coord)
|
||||
keyboard.pre_process_key(new_key, True, int_coord)
|
||||
keyboard.pre_process_key(new_key, True, int_coord, self._next_module)
|
||||
|
||||
keyboard._send_hid()
|
||||
self.key_buffer.clear()
|
||||
|
||||
def ht_activate_hold(self, key, keyboard, *args, **kwargs):
|
||||
keyboard.process_key(key.meta.hold, True)
|
||||
keyboard.pre_process_key(key.meta.hold, True, index=self._next_module)
|
||||
|
||||
def ht_deactivate_hold(self, key, keyboard, *args, **kwargs):
|
||||
keyboard.process_key(key.meta.hold, False)
|
||||
keyboard.pre_process_key(key.meta.hold, False, index=self._next_module)
|
||||
|
||||
def ht_activate_tap(self, key, keyboard, *args, **kwargs):
|
||||
keyboard.process_key(key.meta.tap, True)
|
||||
keyboard.pre_process_key(key.meta.tap, True, index=self._next_module)
|
||||
|
||||
def ht_deactivate_tap(self, key, keyboard, *args, **kwargs):
|
||||
keyboard.process_key(key.meta.tap, False)
|
||||
keyboard.pre_process_key(key.meta.tap, False, index=self._next_module)
|
||||
|
||||
def ht_activate_on_interrupt(self, key, keyboard, *args, **kwargs):
|
||||
if key.meta.prefer_hold:
|
||||
|
@ -87,20 +87,6 @@ class Layers(HoldTap):
|
||||
|
||||
return current_key
|
||||
|
||||
def send_key_buffer(self, keyboard):
|
||||
for (int_coord, old_key) in self.key_buffer:
|
||||
new_key = keyboard._find_key_in_map(int_coord)
|
||||
|
||||
# adding keys late to _coordkeys_pressed isn't pretty,
|
||||
# but necessary to mitigate race conditions when multiple
|
||||
# keys are pressed during a tap-interrupted hold-tap.
|
||||
keyboard._coordkeys_pressed[int_coord] = new_key
|
||||
new_key.on_press(keyboard)
|
||||
|
||||
keyboard._send_hid()
|
||||
|
||||
self.key_buffer.clear()
|
||||
|
||||
def _df_pressed(self, key, keyboard, *args, **kwargs):
|
||||
'''
|
||||
Switches the default layer
|
||||
|
Loading…
Reference in New Issue
Block a user