unit tests for execution in desktop dev environment

This commit is contained in:
Christian Tu
2021-12-05 15:24:51 +01:00
committed by Josh Klar
parent e70ce5f431
commit b6201d43d4
9 changed files with 285 additions and 34 deletions

View File

@@ -373,6 +373,11 @@ class KMKKeyboard:
print('Failed to run post hid function in extension: ', err, ext)
def go(self, hid_type=HIDModes.USB, secondary_hid_type=None, **kwargs):
self._init(hid_type=hid_type, secondary_hid_type=secondary_hid_type, **kwargs)
while True:
self._main_loop()
def _init(self, hid_type=HIDModes.USB, secondary_hid_type=None, **kwargs):
self._go_args = kwargs
self.hid_type = hid_type
self.secondary_hid_type = secondary_hid_type
@@ -398,46 +403,44 @@ class KMKKeyboard:
self._print_debug_cycle(init=True)
while True:
self.current_key = None
self.state_changed = False
self.sandbox.active_layers = self.active_layers.copy()
def _main_loop(self):
self.current_key = None
self.state_changed = False
self.sandbox.active_layers = self.active_layers.copy()
self.before_matrix_scan()
self.before_matrix_scan()
self.matrix_update = (
self.sandbox.matrix_update
) = self.matrix.scan_for_changes()
self.sandbox.secondary_matrix_update = self.secondary_matrix_update
self.matrix_update = self.sandbox.matrix_update = self.matrix.scan_for_changes()
self.sandbox.secondary_matrix_update = self.secondary_matrix_update
self.after_matrix_scan()
self.after_matrix_scan()
self._handle_matrix_report(self.secondary_matrix_update)
self.secondary_matrix_update = None
self._handle_matrix_report(self.matrix_update)
self.matrix_update = None
self._handle_matrix_report(self.secondary_matrix_update)
self.secondary_matrix_update = None
self._handle_matrix_report(self.matrix_update)
self.matrix_update = None
self.before_hid_send()
self.before_hid_send()
if self.hid_pending:
self._send_hid()
self._old_timeouts_len = len(self._timeouts)
self._process_timeouts()
self._new_timeouts_len = len(self._timeouts)
if self._old_timeouts_len != self._new_timeouts_len:
self.state_changed = True
if self.hid_pending:
self._send_hid()
self._old_timeouts_len = len(self._timeouts)
self._process_timeouts()
self._new_timeouts_len = len(self._timeouts)
self.after_hid_send()
if self._old_timeouts_len != self._new_timeouts_len:
self.state_changed = True
if self.hid_pending:
self._send_hid()
if self._trigger_powersave_enable:
self.powersave_enable()
self.after_hid_send()
if self._trigger_powersave_disable:
self.powersave_disable()
if self._trigger_powersave_enable:
self.powersave_enable()
if self._trigger_powersave_disable:
self.powersave_disable()
if self.state_changed:
self._print_debug_cycle()
if self.state_changed:
self._print_debug_cycle()