main_window/keyboard_comm: allow resuming interrupted unlock

main
Ilya Zhuravlev 2021-01-07 09:17:52 -05:00
parent bdb9e9ff64
commit 69cd27ad55
2 changed files with 13 additions and 0 deletions

View File

@ -309,6 +309,14 @@ class Keyboard:
data = self.usb_send(self.dev, struct.pack("BB", CMD_VIA_VIAL_PREFIX, CMD_VIAL_GET_UNLOCK_STATUS))
return data[0]
def get_unlock_in_progress(self):
# VIA keyboards are never being unlocked
if self.vial_protocol < 0:
return 0
data = self.usb_send(self.dev, struct.pack("BB", CMD_VIA_VIAL_PREFIX, CMD_VIAL_GET_UNLOCK_STATUS))
return data[1]
def get_unlock_keys(self):
""" Return keys users have to hold to unlock the keyboard as a list of rowcols """

View File

@ -158,6 +158,11 @@ class MainWindow(QMainWindow):
# don't show "Security" menu for bootloader mode, as the bootloader is inherently insecure
self.security_menu.menuAction().setVisible(isinstance(self.current_device, VialKeyboard))
# if unlock process was interrupted, we must finish it first
if isinstance(self.current_device, VialKeyboard) and self.current_device.keyboard.get_unlock_in_progress():
Unlocker.get().perform_unlock(self.current_device.keyboard)
self.current_device.keyboard.reload()
for e in [self.layout_editor, self.keymap_editor, self.firmware_flasher, self.macro_recorder]:
e.rebuild(self.current_device)