started on multikey

This commit is contained in:
2022-02-05 09:57:34 +01:00
parent df1522df6c
commit 71ba995142
12 changed files with 24 additions and 8 deletions

0
code.py Executable file → Normal file
View File

View File

@@ -1,7 +1,6 @@
from nmlkpy.key_codes.se import SE
from nmlkpy.key_types.keycode import Keycode, Modifier
from nmlkpy.key_types.keycode import Keycode, Modifier, Multikey
from nmlkpy.key_types.layer import Hold, Toggle
from nmlkpy.layer_manager import LayerManager
keymap = [[
Hold(1), Toggle(2), Toggle(3), Toggle(4),
@@ -9,7 +8,7 @@ keymap = [[
Keycode(SE.LEFT), Keycode(SE.DOWN), Keycode(
SE.UP), Keycode(SE.RIGHT),
Keycode(SE.ENTER), Keycode(SE.J), Keycode(
SE.K), Modifier(SE.LEFT_SHIFT)
SE.K), Multikey(SE.G, SE.A, SE.C, SE.P, SE.ENTER)
], [
Hold(1), Toggle(2), Toggle(3), Toggle(4),
Keycode(SE.ONE), Hold(1), Keycode(SE.C), Keycode(SE.D),

0
lib/adafruit_mcp230xx/mcp23016.mpy Executable file → Normal file
View File

0
lib/adafruit_mcp230xx/mcp23s08.mpy Normal file → Executable file
View File

0
lib/adafruit_mcp230xx/mcp23sxx.mpy Executable file → Normal file
View File

0
lib/adafruit_mcp230xx/mcp23xxx.mpy Normal file → Executable file
View File

0
nmlkpy/__init__.py Normal file → Executable file
View File

0
nmlkpy/boot.py Normal file → Executable file
View File

0
nmlkpy/key_codes/se.py Normal file → Executable file
View File

View File

@@ -17,11 +17,6 @@ class KeyChanges:
class KeyBase:
#identifier: KeyIdentifier
# def enrich(self, identifier: KeyIdentifier):
# assert identifier is not None
# self.identifier = identifier
def calculate_changes(self, pin: PinState, custom_state: object) -> KeyChanges:
raise NotImplementedError()

View File

@@ -39,3 +39,25 @@ class Modifier(KeycodeBase):
def self_test(self, keymap):
if not self.keycode in _VALID_MODIFIERS:
raise Exception("Keycode is not valid")
class Multikey(KeyBase):
"""Basic press and release functionality that appends a keycode to the report when active"""
keycodes: list[int]
def __init__(self, *keycodes: int):
self.keycodes = list(keycodes)
def calculate_changes(self, pin: PinState, custom_state: object) -> KeyChanges:
assert pin is not None
changes = KeyChanges()
if pin.is_pressed():
for keycode in self.keycodes:
changes.keymap_delta.press(keycode)
else:
for keycode in self.keycodes:
changes.keymap_delta.unpress(keycode)
return changes
def self_test(self, keymap):
pass

0
nmlkpy/keymap_manager.py Executable file → Normal file
View File