keyboard_comm: require unlock when setting RESET keycode

main
Ilya Zhuravlev 2021-02-01 12:17:34 -05:00
parent c27b57cacc
commit d2a2ee0b9e
2 changed files with 11 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import json
import lzma
from collections import OrderedDict
from keycodes import RESET_KEYCODE
from kle_serial import Serial as KleSerial
from unlocker import Unlocker
from util import MSG_LEN, hid_send, chunks
@ -208,6 +209,9 @@ class Keyboard:
key = (layer, row, col)
if self.layout[key] != code:
if code == RESET_KEYCODE:
Unlocker.get().perform_unlock(self)
self.usb_send(self.dev, struct.pack(">BBBBH", CMD_VIA_SET_KEYCODE, layer, row, col, code), retries=20)
self.layout[key] = code
@ -217,6 +221,9 @@ class Keyboard:
key = (layer, index, direction)
if self.encoder_layout[key] != code:
if code == RESET_KEYCODE:
Unlocker.get().perform_unlock(self)
self.usb_send(self.dev, struct.pack(">BBBBBH", CMD_VIA_VIAL_PREFIX, CMD_VIAL_SET_ENCODER,
layer, index, direction, code), retries=20)
self.encoder_layout[key] = code

View File

@ -227,8 +227,11 @@ def LT(layer):
return QK_LAYER_TAP | (((layer) & 0xF) << 8)
RESET_KEYCODE = 0x5C00
KEYCODES_QUANTUM = [
K(0x5C00, "RESET", "Reset", "Reboot to bootloader"),
K(RESET_KEYCODE, "RESET", "Reset", "Reboot to bootloader"),
K(QK_ONE_SHOT_MOD | MOD_LSFT, "OSM(MOD_LSFT)", "OSM\nLSft", "Enable Left Shift for one keypress"),
K(QK_ONE_SHOT_MOD | MOD_LCTL, "OSM(MOD_LCTL)", "OSM\nLCtl", "Enable Left Control for one keypress"),
K(QK_ONE_SHOT_MOD | MOD_LALT, "OSM(MOD_LALT)", "OSM\nLAlt", "Enable Left Alt for one keypress"),