Clear HID reports on crash

This commit is contained in:
xs5871 2023-02-24 20:20:22 +00:00 committed by xs5871
parent 013046b44d
commit 94c042fec5

View File

@ -386,6 +386,10 @@ class KMKKeyboard:
self._hid_helper = self._hid_helper(**self._go_args)
self._hid_send_enabled = True
def _deinit_hid(self) -> None:
self._hid_helper.clear_all()
self._hid_helper.send()
def _init_matrix(self) -> None:
if self.matrix is None:
if debug.enabled:
@ -498,8 +502,12 @@ class KMKKeyboard:
def go(self, hid_type=HIDModes.USB, secondary_hid_type=None, **kwargs) -> None:
self._init(hid_type=hid_type, secondary_hid_type=secondary_hid_type, **kwargs)
while True:
self._main_loop()
try:
while True:
self._main_loop()
finally:
debug('Unexpected error: cleaning up')
self._deinit_hid()
def _init(
self,