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_DEFINITION = 0x02
|
||||||
CMD_VIAL_GET_ENCODER = 0x03
|
CMD_VIAL_GET_ENCODER = 0x03
|
||||||
CMD_VIAL_SET_ENCODER = 0x04
|
CMD_VIAL_SET_ENCODER = 0x04
|
||||||
CMD_VIAL_GET_LOCK = 0x05
|
CMD_VIAL_GET_UNLOCK_STATUS = 0x05
|
||||||
CMD_VIAL_UNLOCK_START = 0x06
|
CMD_VIAL_UNLOCK_START = 0x06
|
||||||
CMD_VIAL_UNLOCK_POLL = 0x07
|
CMD_VIAL_UNLOCK_POLL = 0x07
|
||||||
CMD_VIAL_LOCK = 0x08
|
CMD_VIAL_LOCK = 0x08
|
||||||
|
|
@ -295,14 +295,14 @@ class Keyboard:
|
||||||
keyboard_id = data[4:12]
|
keyboard_id = data[4:12]
|
||||||
return keyboard_id
|
return keyboard_id
|
||||||
|
|
||||||
def get_lock(self):
|
def get_unlock_status(self):
|
||||||
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))
|
||||||
return data[0]
|
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 """
|
""" 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 = []
|
rowcol = []
|
||||||
for x in range(15):
|
for x in range(15):
|
||||||
row = data[2 + x * 2]
|
row = data[2 + x * 2]
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ class Unlocker(QWidget):
|
||||||
self.keyboard_reference.set_keys(keyboard.keys, keyboard.encoders)
|
self.keyboard_reference.set_keys(keyboard.keys, keyboard.encoders)
|
||||||
|
|
||||||
# use "active" background to indicate keys to hold
|
# 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:
|
for w in self.keyboard_reference.widgets:
|
||||||
if (w.desc.row, w.desc.col) in lock_keys:
|
if (w.desc.row, w.desc.col) in lock_keys:
|
||||||
w.setActive(True)
|
w.setActive(True)
|
||||||
|
|
@ -59,8 +59,8 @@ class Unlocker(QWidget):
|
||||||
|
|
||||||
def perform_unlock(self, keyboard):
|
def perform_unlock(self, keyboard):
|
||||||
# if it's already unlocked, don't need to do anything
|
# if it's already unlocked, don't need to do anything
|
||||||
lock = keyboard.get_lock()
|
unlock = keyboard.get_unlock_status()
|
||||||
if lock == 0:
|
if unlock == 1:
|
||||||
return
|
return
|
||||||
|
|
||||||
self.update_reference(keyboard)
|
self.update_reference(keyboard)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue