Start of internal keycodes
This commit is contained in:
parent
f84c58a03e
commit
d0f35100b3
5
.gitignore
vendored
5
.gitignore
vendored
@ -106,6 +106,7 @@ venv.bak/
|
||||
.ampy
|
||||
.submodules
|
||||
.circuitpy-deps
|
||||
|
||||
.idea/
|
||||
.micropython-deps
|
||||
|
||||
# Pycharms cruft
|
||||
.idea
|
||||
|
@ -21,7 +21,7 @@ def main():
|
||||
KC.BACKSPACE],
|
||||
[KC.TAB, KC.A, KC.O, KC.E, KC.U, KC.I, KC.D, KC.H, KC.T, KC.N, KC.S, KC.ENTER],
|
||||
[KC.SHIFT, KC.SEMICOLON, KC.Q, KC.J, KC.K, KC.X, KC.B, KC.M, KC.W, KC.V, KC.Z, KC.SLASH],
|
||||
[KC.CTRL, KC.GUI, KC.ALT, KC.A, KC.A, KC.SPACE, KC.SPACE, KC.A, KC.LEFT, KC.DOWN,
|
||||
[KC.CTRL, KC.GUI, KC.ALT, KC.RESET, KC.A, KC.SPACE, KC.SPACE, KC.A, KC.LEFT, KC.DOWN,
|
||||
KC.UP, KC.RIGHT],
|
||||
]
|
||||
|
||||
|
11
kmk/common/internal_keycodes.py
Normal file
11
kmk/common/internal_keycodes.py
Normal file
@ -0,0 +1,11 @@
|
||||
def process(self, state, key):
|
||||
self.logger.warning(key)
|
||||
if key.code == 1000:
|
||||
reset(self)
|
||||
|
||||
|
||||
def reset(self):
|
||||
self.logger.debug('Rebooting to bootloader')
|
||||
import machine
|
||||
machine.bootloader()
|
||||
return self
|
@ -312,6 +312,15 @@ class Keycodes(KeycodeCategory):
|
||||
KC_MEDIA_FAST_FORWARD = KC_MFFD = Keycode(187, False)
|
||||
KC_MEDIA_REWIND = KC_MRWD = Keycode(189, False)
|
||||
|
||||
class KMK(KeycodeCategory):
|
||||
KC_RESET = Keycode(1000, False)
|
||||
KC_DEBUG = Keycode(1001, False)
|
||||
KC_GESC = Keycode(1002, False)
|
||||
KC_LSPO = Keycode(1003, False)
|
||||
KC_RSPC = Keycode(1004, False)
|
||||
KC_LEAD = Keycode(1005, False)
|
||||
KC_LOCK = Keycode(1006, False)
|
||||
|
||||
|
||||
ALL_KEYS = KC = AttrDict({
|
||||
k.replace('KC_', ''): v
|
||||
|
@ -3,6 +3,7 @@ import string
|
||||
|
||||
from pyb import USB_HID, delay
|
||||
|
||||
import kmk.common.internal_keycodes as internal_keycodes
|
||||
from kmk.common.event_defs import KEY_DOWN_EVENT, KEY_UP_EVENT
|
||||
from kmk.common.keycodes import Keycodes, char_lookup
|
||||
|
||||
@ -49,19 +50,26 @@ class HIDHelper:
|
||||
|
||||
def _subscription(self, state, action):
|
||||
if action['type'] == KEY_DOWN_EVENT:
|
||||
if action['keycode'].is_modifier:
|
||||
self.add_modifier(action['keycode'])
|
||||
self.send()
|
||||
# If keycode is 1000 or over, these are internal keys
|
||||
if action['keycode'].code < 1000:
|
||||
if action['keycode'].is_modifier:
|
||||
self.add_modifier(action['keycode'])
|
||||
self.send()
|
||||
else:
|
||||
self.add_key(action['keycode'])
|
||||
self.send()
|
||||
else:
|
||||
self.add_key(action['keycode'])
|
||||
self.send()
|
||||
self.logger.warning('Should be processing')
|
||||
internal_keycodes.process(self, state, action['keycode'])
|
||||
elif action['type'] == KEY_UP_EVENT:
|
||||
if action['keycode'].is_modifier:
|
||||
self.remove_modifier(action['keycode'])
|
||||
self.send()
|
||||
else:
|
||||
self.remove_key(action['keycode'])
|
||||
self.send()
|
||||
# If keycode is 1000 or over, these are internal keys
|
||||
if action['keycode'].code < 1000:
|
||||
if action['keycode'].is_modifier:
|
||||
self.remove_modifier(action['keycode'])
|
||||
self.send()
|
||||
else:
|
||||
self.remove_key(action['keycode'])
|
||||
self.send()
|
||||
|
||||
def send(self):
|
||||
self.logger.debug('Sending HID report: {}'.format(self._evt))
|
||||
|
Loading…
Reference in New Issue
Block a user