unlocker: flip around the lock/unlock logic
parent
9a4825a124
commit
b3080ec028
|
|
@ -27,7 +27,7 @@ CMD_VIAL_GET_SIZE = 0x01
|
|||
CMD_VIAL_GET_DEFINITION = 0x02
|
||||
CMD_VIAL_GET_ENCODER = 0x03
|
||||
CMD_VIAL_SET_ENCODER = 0x04
|
||||
CMD_VIAL_GET_LOCK = 0x05
|
||||
CMD_VIAL_GET_UNLOCK_STATUS = 0x05
|
||||
CMD_VIAL_UNLOCK_START = 0x06
|
||||
CMD_VIAL_UNLOCK_POLL = 0x07
|
||||
CMD_VIAL_LOCK = 0x08
|
||||
|
|
@ -295,14 +295,14 @@ class Keyboard:
|
|||
keyboard_id = data[4:12]
|
||||
return keyboard_id
|
||||
|
||||
def get_lock(self):
|
||||
data = self.usb_send(self.dev, struct.pack("BB", CMD_VIA_VIAL_PREFIX, CMD_VIAL_GET_LOCK))
|
||||
def get_unlock_status(self):
|
||||
data = self.usb_send(self.dev, struct.pack("BB", CMD_VIA_VIAL_PREFIX, CMD_VIAL_GET_UNLOCK_STATUS))
|
||||
return data[0]
|
||||
|
||||
def get_lock_keys(self):
|
||||
def get_unlock_keys(self):
|
||||
""" Return keys users have to hold to unlock the keyboard as a list of rowcols """
|
||||
|
||||
data = self.usb_send(self.dev, struct.pack("BB", CMD_VIA_VIAL_PREFIX, CMD_VIAL_GET_LOCK))
|
||||
data = self.usb_send(self.dev, struct.pack("BB", CMD_VIA_VIAL_PREFIX, CMD_VIAL_GET_UNLOCK_STATUS))
|
||||
rowcol = []
|
||||
for x in range(15):
|
||||
row = data[2 + x * 2]
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class Unlocker(QWidget):
|
|||
self.keyboard_reference.set_keys(keyboard.keys, keyboard.encoders)
|
||||
|
||||
# use "active" background to indicate keys to hold
|
||||
lock_keys = keyboard.get_lock_keys()
|
||||
lock_keys = keyboard.get_unlock_keys()
|
||||
for w in self.keyboard_reference.widgets:
|
||||
if (w.desc.row, w.desc.col) in lock_keys:
|
||||
w.setActive(True)
|
||||
|
|
@ -59,8 +59,8 @@ class Unlocker(QWidget):
|
|||
|
||||
def perform_unlock(self, keyboard):
|
||||
# if it's already unlocked, don't need to do anything
|
||||
lock = keyboard.get_lock()
|
||||
if lock == 0:
|
||||
unlock = keyboard.get_unlock_status()
|
||||
if unlock == 1:
|
||||
return
|
||||
|
||||
self.update_reference(keyboard)
|
||||
|
|
|
|||
Loading…
Reference in New Issue