diff options
-rwxr-xr-x | genmap.py | 6 | ||||
-rw-r--r-- | hid/src/ps2/keymap.h.mako | 4 | ||||
-rw-r--r-- | hid/src/usb/keymap.h.mako | 4 | ||||
-rw-r--r-- | keymap.csv | 2 | ||||
-rw-r--r-- | kvmd/keyboard/mappings.py | 216 | ||||
-rw-r--r-- | kvmd/keyboard/mappings.py.mako | 8 | ||||
-rw-r--r-- | kvmd/plugins/hid/_mcu/__init__.py | 2 | ||||
-rw-r--r-- | testenv/linters/vulture-wl.py | 2 | ||||
-rw-r--r-- | testenv/tests/keyboard/test_keymap.py | 2 |
9 files changed, 123 insertions, 123 deletions
@@ -61,7 +61,7 @@ class _X11Key: @dataclasses.dataclass(frozen=True) class _KeyMapping: web_name: str - serial_code: int + mcu_code: int arduino_name: str otg_key: _OtgKey ps2_key: _Ps2Key @@ -115,7 +115,7 @@ def _read_keymap_csv(path: str) -> List[_KeyMapping]: if len(row) >= 6: keymap.append(_KeyMapping( web_name=row["web_name"], - serial_code=int(row["serial_code"]), + mcu_code=int(row["mcu_code"]), arduino_name=row["arduino_name"], otg_key=_parse_otg_key(row["otg_key"]), ps2_key=_parse_ps2_key(row["ps2_key"]), @@ -144,7 +144,7 @@ def main() -> None: # Fields list: # - Web - # - Serial code + # - MCU code # - Arduino name # - OTG code (^ for mod) # - PS/2 key diff --git a/hid/src/ps2/keymap.h.mako b/hid/src/ps2/keymap.h.mako index 70da2f36..cec7cb8a 100644 --- a/hid/src/ps2/keymap.h.mako +++ b/hid/src/ps2/keymap.h.mako @@ -39,8 +39,8 @@ INLINE void keymapPs2(uint8_t code, Ps2KeyType *ps2_type, uint8_t *ps2_code) { *ps2_code = 0; switch (code) { -% for km in sorted(keymap, key=operator.attrgetter("serial_code")): - case ${km.serial_code}: *ps2_type = PS2_KEY_TYPE_${km.ps2_key.type.upper()}; *ps2_code = ${km.ps2_key.code}; return; // ${km.arduino_name} +% for km in sorted(keymap, key=operator.attrgetter("mcu_code")): + case ${km.mcu_code}: *ps2_type = PS2_KEY_TYPE_${km.ps2_key.type.upper()}; *ps2_code = ${km.ps2_key.code}; return; // ${km.arduino_name} % endfor } } diff --git a/hid/src/usb/keymap.h.mako b/hid/src/usb/keymap.h.mako index 5df3a7f5..8cd94fd9 100644 --- a/hid/src/usb/keymap.h.mako +++ b/hid/src/usb/keymap.h.mako @@ -29,8 +29,8 @@ <%! import operator %> INLINE KeyboardKeycode keymapUsb(uint8_t code) { switch (code) { -% for km in sorted(keymap, key=operator.attrgetter("serial_code")): - case ${km.serial_code}: return ${km.arduino_name}; +% for km in sorted(keymap, key=operator.attrgetter("mcu_code")): + case ${km.mcu_code}: return ${km.arduino_name}; % endfor default: return KEY_ERROR_UNDEFINED; } @@ -1,4 +1,4 @@ -web_name,serial_code,arduino_name,otg_key,ps2_key,at1_code,x11_names +web_name,mcu_code,arduino_name,otg_key,ps2_key,at1_code,x11_names KeyA,1,KEY_A,0x04,reg:0x1c,0x1e,"^XK_A,XK_a" KeyB,2,KEY_B,0x05,reg:0x32,0x30,"^XK_B,XK_b" KeyC,3,KEY_C,0x06,reg:0x21,0x2e,"^XK_C,XK_c" diff --git a/kvmd/keyboard/mappings.py b/kvmd/keyboard/mappings.py index 0185a0bc..a841e8b8 100644 --- a/kvmd/keyboard/mappings.py +++ b/kvmd/keyboard/mappings.py @@ -27,7 +27,7 @@ from typing import Dict # ===== @dataclasses.dataclass(frozen=True) -class SerialKey: +class McuKey: code: int @@ -39,117 +39,117 @@ class OtgKey: @dataclasses.dataclass(frozen=True) class Key: - serial: SerialKey + mcu: McuKey otg: OtgKey KEYMAP: Dict[str, Key] = { - "KeyA": Key(serial=SerialKey(code=1), otg=OtgKey(code=4, is_modifier=False)), - "KeyB": Key(serial=SerialKey(code=2), otg=OtgKey(code=5, is_modifier=False)), - "KeyC": Key(serial=SerialKey(code=3), otg=OtgKey(code=6, is_modifier=False)), - "KeyD": Key(serial=SerialKey(code=4), otg=OtgKey(code=7, is_modifier=False)), - "KeyE": Key(serial=SerialKey(code=5), otg=OtgKey(code=8, is_modifier=False)), - "KeyF": Key(serial=SerialKey(code=6), otg=OtgKey(code=9, is_modifier=False)), - "KeyG": Key(serial=SerialKey(code=7), otg=OtgKey(code=10, is_modifier=False)), - "KeyH": Key(serial=SerialKey(code=8), otg=OtgKey(code=11, is_modifier=False)), - "KeyI": Key(serial=SerialKey(code=9), otg=OtgKey(code=12, is_modifier=False)), - "KeyJ": Key(serial=SerialKey(code=10), otg=OtgKey(code=13, is_modifier=False)), - "KeyK": Key(serial=SerialKey(code=11), otg=OtgKey(code=14, is_modifier=False)), - "KeyL": Key(serial=SerialKey(code=12), otg=OtgKey(code=15, is_modifier=False)), - "KeyM": Key(serial=SerialKey(code=13), otg=OtgKey(code=16, is_modifier=False)), - "KeyN": Key(serial=SerialKey(code=14), otg=OtgKey(code=17, is_modifier=False)), - "KeyO": Key(serial=SerialKey(code=15), otg=OtgKey(code=18, is_modifier=False)), - "KeyP": Key(serial=SerialKey(code=16), otg=OtgKey(code=19, is_modifier=False)), - "KeyQ": Key(serial=SerialKey(code=17), otg=OtgKey(code=20, is_modifier=False)), - "KeyR": Key(serial=SerialKey(code=18), otg=OtgKey(code=21, is_modifier=False)), - "KeyS": Key(serial=SerialKey(code=19), otg=OtgKey(code=22, is_modifier=False)), - "KeyT": Key(serial=SerialKey(code=20), otg=OtgKey(code=23, is_modifier=False)), - "KeyU": Key(serial=SerialKey(code=21), otg=OtgKey(code=24, is_modifier=False)), - "KeyV": Key(serial=SerialKey(code=22), otg=OtgKey(code=25, is_modifier=False)), - "KeyW": Key(serial=SerialKey(code=23), otg=OtgKey(code=26, is_modifier=False)), - "KeyX": Key(serial=SerialKey(code=24), otg=OtgKey(code=27, is_modifier=False)), - "KeyY": Key(serial=SerialKey(code=25), otg=OtgKey(code=28, is_modifier=False)), - "KeyZ": Key(serial=SerialKey(code=26), otg=OtgKey(code=29, is_modifier=False)), - "Digit1": Key(serial=SerialKey(code=27), otg=OtgKey(code=30, is_modifier=False)), - "Digit2": Key(serial=SerialKey(code=28), otg=OtgKey(code=31, is_modifier=False)), - "Digit3": Key(serial=SerialKey(code=29), otg=OtgKey(code=32, is_modifier=False)), - "Digit4": Key(serial=SerialKey(code=30), otg=OtgKey(code=33, is_modifier=False)), - "Digit5": Key(serial=SerialKey(code=31), otg=OtgKey(code=34, is_modifier=False)), - "Digit6": Key(serial=SerialKey(code=32), otg=OtgKey(code=35, is_modifier=False)), - "Digit7": Key(serial=SerialKey(code=33), otg=OtgKey(code=36, is_modifier=False)), - "Digit8": Key(serial=SerialKey(code=34), otg=OtgKey(code=37, is_modifier=False)), - "Digit9": Key(serial=SerialKey(code=35), otg=OtgKey(code=38, is_modifier=False)), - "Digit0": Key(serial=SerialKey(code=36), otg=OtgKey(code=39, is_modifier=False)), - "Enter": Key(serial=SerialKey(code=37), otg=OtgKey(code=40, is_modifier=False)), - "Escape": Key(serial=SerialKey(code=38), otg=OtgKey(code=41, is_modifier=False)), - "Backspace": Key(serial=SerialKey(code=39), otg=OtgKey(code=42, is_modifier=False)), - "Tab": Key(serial=SerialKey(code=40), otg=OtgKey(code=43, is_modifier=False)), - "Space": Key(serial=SerialKey(code=41), otg=OtgKey(code=44, is_modifier=False)), - "Minus": Key(serial=SerialKey(code=42), otg=OtgKey(code=45, is_modifier=False)), - "Equal": Key(serial=SerialKey(code=43), otg=OtgKey(code=46, is_modifier=False)), - "BracketLeft": Key(serial=SerialKey(code=44), otg=OtgKey(code=47, is_modifier=False)), - "BracketRight": Key(serial=SerialKey(code=45), otg=OtgKey(code=48, is_modifier=False)), - "Backslash": Key(serial=SerialKey(code=46), otg=OtgKey(code=49, is_modifier=False)), - "Semicolon": Key(serial=SerialKey(code=47), otg=OtgKey(code=51, is_modifier=False)), - "Quote": Key(serial=SerialKey(code=48), otg=OtgKey(code=52, is_modifier=False)), - "Backquote": Key(serial=SerialKey(code=49), otg=OtgKey(code=53, is_modifier=False)), - "Comma": Key(serial=SerialKey(code=50), otg=OtgKey(code=54, is_modifier=False)), - "Period": Key(serial=SerialKey(code=51), otg=OtgKey(code=55, is_modifier=False)), - "Slash": Key(serial=SerialKey(code=52), otg=OtgKey(code=56, is_modifier=False)), - "CapsLock": Key(serial=SerialKey(code=53), otg=OtgKey(code=57, is_modifier=False)), - "F1": Key(serial=SerialKey(code=54), otg=OtgKey(code=58, is_modifier=False)), - "F2": Key(serial=SerialKey(code=55), otg=OtgKey(code=59, is_modifier=False)), - "F3": Key(serial=SerialKey(code=56), otg=OtgKey(code=60, is_modifier=False)), - "F4": Key(serial=SerialKey(code=57), otg=OtgKey(code=61, is_modifier=False)), - "F5": Key(serial=SerialKey(code=58), otg=OtgKey(code=62, is_modifier=False)), - "F6": Key(serial=SerialKey(code=59), otg=OtgKey(code=63, is_modifier=False)), - "F7": Key(serial=SerialKey(code=60), otg=OtgKey(code=64, is_modifier=False)), - "F8": Key(serial=SerialKey(code=61), otg=OtgKey(code=65, is_modifier=False)), - "F9": Key(serial=SerialKey(code=62), otg=OtgKey(code=66, is_modifier=False)), - "F10": Key(serial=SerialKey(code=63), otg=OtgKey(code=67, is_modifier=False)), - "F11": Key(serial=SerialKey(code=64), otg=OtgKey(code=68, is_modifier=False)), - "F12": Key(serial=SerialKey(code=65), otg=OtgKey(code=69, is_modifier=False)), - "PrintScreen": Key(serial=SerialKey(code=66), otg=OtgKey(code=70, is_modifier=False)), - "Insert": Key(serial=SerialKey(code=67), otg=OtgKey(code=73, is_modifier=False)), - "Home": Key(serial=SerialKey(code=68), otg=OtgKey(code=74, is_modifier=False)), - "PageUp": Key(serial=SerialKey(code=69), otg=OtgKey(code=75, is_modifier=False)), - "Delete": Key(serial=SerialKey(code=70), otg=OtgKey(code=76, is_modifier=False)), - "End": Key(serial=SerialKey(code=71), otg=OtgKey(code=77, is_modifier=False)), - "PageDown": Key(serial=SerialKey(code=72), otg=OtgKey(code=78, is_modifier=False)), - "ArrowRight": Key(serial=SerialKey(code=73), otg=OtgKey(code=79, is_modifier=False)), - "ArrowLeft": Key(serial=SerialKey(code=74), otg=OtgKey(code=80, is_modifier=False)), - "ArrowDown": Key(serial=SerialKey(code=75), otg=OtgKey(code=81, is_modifier=False)), - "ArrowUp": Key(serial=SerialKey(code=76), otg=OtgKey(code=82, is_modifier=False)), - "ControlLeft": Key(serial=SerialKey(code=77), otg=OtgKey(code=1, is_modifier=True)), - "ShiftLeft": Key(serial=SerialKey(code=78), otg=OtgKey(code=2, is_modifier=True)), - "AltLeft": Key(serial=SerialKey(code=79), otg=OtgKey(code=4, is_modifier=True)), - "MetaLeft": Key(serial=SerialKey(code=80), otg=OtgKey(code=8, is_modifier=True)), - "ControlRight": Key(serial=SerialKey(code=81), otg=OtgKey(code=16, is_modifier=True)), - "ShiftRight": Key(serial=SerialKey(code=82), otg=OtgKey(code=32, is_modifier=True)), - "AltRight": Key(serial=SerialKey(code=83), otg=OtgKey(code=64, is_modifier=True)), - "MetaRight": Key(serial=SerialKey(code=84), otg=OtgKey(code=128, is_modifier=True)), - "Pause": Key(serial=SerialKey(code=85), otg=OtgKey(code=72, is_modifier=False)), - "ScrollLock": Key(serial=SerialKey(code=86), otg=OtgKey(code=71, is_modifier=False)), - "NumLock": Key(serial=SerialKey(code=87), otg=OtgKey(code=83, is_modifier=False)), - "ContextMenu": Key(serial=SerialKey(code=88), otg=OtgKey(code=101, is_modifier=False)), - "NumpadDivide": Key(serial=SerialKey(code=89), otg=OtgKey(code=84, is_modifier=False)), - "NumpadMultiply": Key(serial=SerialKey(code=90), otg=OtgKey(code=85, is_modifier=False)), - "NumpadSubtract": Key(serial=SerialKey(code=91), otg=OtgKey(code=86, is_modifier=False)), - "NumpadAdd": Key(serial=SerialKey(code=92), otg=OtgKey(code=87, is_modifier=False)), - "NumpadEnter": Key(serial=SerialKey(code=93), otg=OtgKey(code=88, is_modifier=False)), - "Numpad1": Key(serial=SerialKey(code=94), otg=OtgKey(code=89, is_modifier=False)), - "Numpad2": Key(serial=SerialKey(code=95), otg=OtgKey(code=90, is_modifier=False)), - "Numpad3": Key(serial=SerialKey(code=96), otg=OtgKey(code=91, is_modifier=False)), - "Numpad4": Key(serial=SerialKey(code=97), otg=OtgKey(code=92, is_modifier=False)), - "Numpad5": Key(serial=SerialKey(code=98), otg=OtgKey(code=93, is_modifier=False)), - "Numpad6": Key(serial=SerialKey(code=99), otg=OtgKey(code=94, is_modifier=False)), - "Numpad7": Key(serial=SerialKey(code=100), otg=OtgKey(code=95, is_modifier=False)), - "Numpad8": Key(serial=SerialKey(code=101), otg=OtgKey(code=96, is_modifier=False)), - "Numpad9": Key(serial=SerialKey(code=102), otg=OtgKey(code=97, is_modifier=False)), - "Numpad0": Key(serial=SerialKey(code=103), otg=OtgKey(code=98, is_modifier=False)), - "NumpadDecimal": Key(serial=SerialKey(code=104), otg=OtgKey(code=99, is_modifier=False)), - "Power": Key(serial=SerialKey(code=105), otg=OtgKey(code=102, is_modifier=False)), - "IntlBackslash": Key(serial=SerialKey(code=106), otg=OtgKey(code=100, is_modifier=False)), + "KeyA": Key(mcu=McuKey(code=1), otg=OtgKey(code=4, is_modifier=False)), + "KeyB": Key(mcu=McuKey(code=2), otg=OtgKey(code=5, is_modifier=False)), + "KeyC": Key(mcu=McuKey(code=3), otg=OtgKey(code=6, is_modifier=False)), + "KeyD": Key(mcu=McuKey(code=4), otg=OtgKey(code=7, is_modifier=False)), + "KeyE": Key(mcu=McuKey(code=5), otg=OtgKey(code=8, is_modifier=False)), + "KeyF": Key(mcu=McuKey(code=6), otg=OtgKey(code=9, is_modifier=False)), + "KeyG": Key(mcu=McuKey(code=7), otg=OtgKey(code=10, is_modifier=False)), + "KeyH": Key(mcu=McuKey(code=8), otg=OtgKey(code=11, is_modifier=False)), + "KeyI": Key(mcu=McuKey(code=9), otg=OtgKey(code=12, is_modifier=False)), + "KeyJ": Key(mcu=McuKey(code=10), otg=OtgKey(code=13, is_modifier=False)), + "KeyK": Key(mcu=McuKey(code=11), otg=OtgKey(code=14, is_modifier=False)), + "KeyL": Key(mcu=McuKey(code=12), otg=OtgKey(code=15, is_modifier=False)), + "KeyM": Key(mcu=McuKey(code=13), otg=OtgKey(code=16, is_modifier=False)), + "KeyN": Key(mcu=McuKey(code=14), otg=OtgKey(code=17, is_modifier=False)), + "KeyO": Key(mcu=McuKey(code=15), otg=OtgKey(code=18, is_modifier=False)), + "KeyP": Key(mcu=McuKey(code=16), otg=OtgKey(code=19, is_modifier=False)), + "KeyQ": Key(mcu=McuKey(code=17), otg=OtgKey(code=20, is_modifier=False)), + "KeyR": Key(mcu=McuKey(code=18), otg=OtgKey(code=21, is_modifier=False)), + "KeyS": Key(mcu=McuKey(code=19), otg=OtgKey(code=22, is_modifier=False)), + "KeyT": Key(mcu=McuKey(code=20), otg=OtgKey(code=23, is_modifier=False)), + "KeyU": Key(mcu=McuKey(code=21), otg=OtgKey(code=24, is_modifier=False)), + "KeyV": Key(mcu=McuKey(code=22), otg=OtgKey(code=25, is_modifier=False)), + "KeyW": Key(mcu=McuKey(code=23), otg=OtgKey(code=26, is_modifier=False)), + "KeyX": Key(mcu=McuKey(code=24), otg=OtgKey(code=27, is_modifier=False)), + "KeyY": Key(mcu=McuKey(code=25), otg=OtgKey(code=28, is_modifier=False)), + "KeyZ": Key(mcu=McuKey(code=26), otg=OtgKey(code=29, is_modifier=False)), + "Digit1": Key(mcu=McuKey(code=27), otg=OtgKey(code=30, is_modifier=False)), + "Digit2": Key(mcu=McuKey(code=28), otg=OtgKey(code=31, is_modifier=False)), + "Digit3": Key(mcu=McuKey(code=29), otg=OtgKey(code=32, is_modifier=False)), + "Digit4": Key(mcu=McuKey(code=30), otg=OtgKey(code=33, is_modifier=False)), + "Digit5": Key(mcu=McuKey(code=31), otg=OtgKey(code=34, is_modifier=False)), + "Digit6": Key(mcu=McuKey(code=32), otg=OtgKey(code=35, is_modifier=False)), + "Digit7": Key(mcu=McuKey(code=33), otg=OtgKey(code=36, is_modifier=False)), + "Digit8": Key(mcu=McuKey(code=34), otg=OtgKey(code=37, is_modifier=False)), + "Digit9": Key(mcu=McuKey(code=35), otg=OtgKey(code=38, is_modifier=False)), + "Digit0": Key(mcu=McuKey(code=36), otg=OtgKey(code=39, is_modifier=False)), + "Enter": Key(mcu=McuKey(code=37), otg=OtgKey(code=40, is_modifier=False)), + "Escape": Key(mcu=McuKey(code=38), otg=OtgKey(code=41, is_modifier=False)), + "Backspace": Key(mcu=McuKey(code=39), otg=OtgKey(code=42, is_modifier=False)), + "Tab": Key(mcu=McuKey(code=40), otg=OtgKey(code=43, is_modifier=False)), + "Space": Key(mcu=McuKey(code=41), otg=OtgKey(code=44, is_modifier=False)), + "Minus": Key(mcu=McuKey(code=42), otg=OtgKey(code=45, is_modifier=False)), + "Equal": Key(mcu=McuKey(code=43), otg=OtgKey(code=46, is_modifier=False)), + "BracketLeft": Key(mcu=McuKey(code=44), otg=OtgKey(code=47, is_modifier=False)), + "BracketRight": Key(mcu=McuKey(code=45), otg=OtgKey(code=48, is_modifier=False)), + "Backslash": Key(mcu=McuKey(code=46), otg=OtgKey(code=49, is_modifier=False)), + "Semicolon": Key(mcu=McuKey(code=47), otg=OtgKey(code=51, is_modifier=False)), + "Quote": Key(mcu=McuKey(code=48), otg=OtgKey(code=52, is_modifier=False)), + "Backquote": Key(mcu=McuKey(code=49), otg=OtgKey(code=53, is_modifier=False)), + "Comma": Key(mcu=McuKey(code=50), otg=OtgKey(code=54, is_modifier=False)), + "Period": Key(mcu=McuKey(code=51), otg=OtgKey(code=55, is_modifier=False)), + "Slash": Key(mcu=McuKey(code=52), otg=OtgKey(code=56, is_modifier=False)), + "CapsLock": Key(mcu=McuKey(code=53), otg=OtgKey(code=57, is_modifier=False)), + "F1": Key(mcu=McuKey(code=54), otg=OtgKey(code=58, is_modifier=False)), + "F2": Key(mcu=McuKey(code=55), otg=OtgKey(code=59, is_modifier=False)), + "F3": Key(mcu=McuKey(code=56), otg=OtgKey(code=60, is_modifier=False)), + "F4": Key(mcu=McuKey(code=57), otg=OtgKey(code=61, is_modifier=False)), + "F5": Key(mcu=McuKey(code=58), otg=OtgKey(code=62, is_modifier=False)), + "F6": Key(mcu=McuKey(code=59), otg=OtgKey(code=63, is_modifier=False)), + "F7": Key(mcu=McuKey(code=60), otg=OtgKey(code=64, is_modifier=False)), + "F8": Key(mcu=McuKey(code=61), otg=OtgKey(code=65, is_modifier=False)), + "F9": Key(mcu=McuKey(code=62), otg=OtgKey(code=66, is_modifier=False)), + "F10": Key(mcu=McuKey(code=63), otg=OtgKey(code=67, is_modifier=False)), + "F11": Key(mcu=McuKey(code=64), otg=OtgKey(code=68, is_modifier=False)), + "F12": Key(mcu=McuKey(code=65), otg=OtgKey(code=69, is_modifier=False)), + "PrintScreen": Key(mcu=McuKey(code=66), otg=OtgKey(code=70, is_modifier=False)), + "Insert": Key(mcu=McuKey(code=67), otg=OtgKey(code=73, is_modifier=False)), + "Home": Key(mcu=McuKey(code=68), otg=OtgKey(code=74, is_modifier=False)), + "PageUp": Key(mcu=McuKey(code=69), otg=OtgKey(code=75, is_modifier=False)), + "Delete": Key(mcu=McuKey(code=70), otg=OtgKey(code=76, is_modifier=False)), + "End": Key(mcu=McuKey(code=71), otg=OtgKey(code=77, is_modifier=False)), + "PageDown": Key(mcu=McuKey(code=72), otg=OtgKey(code=78, is_modifier=False)), + "ArrowRight": Key(mcu=McuKey(code=73), otg=OtgKey(code=79, is_modifier=False)), + "ArrowLeft": Key(mcu=McuKey(code=74), otg=OtgKey(code=80, is_modifier=False)), + "ArrowDown": Key(mcu=McuKey(code=75), otg=OtgKey(code=81, is_modifier=False)), + "ArrowUp": Key(mcu=McuKey(code=76), otg=OtgKey(code=82, is_modifier=False)), + "ControlLeft": Key(mcu=McuKey(code=77), otg=OtgKey(code=1, is_modifier=True)), + "ShiftLeft": Key(mcu=McuKey(code=78), otg=OtgKey(code=2, is_modifier=True)), + "AltLeft": Key(mcu=McuKey(code=79), otg=OtgKey(code=4, is_modifier=True)), + "MetaLeft": Key(mcu=McuKey(code=80), otg=OtgKey(code=8, is_modifier=True)), + "ControlRight": Key(mcu=McuKey(code=81), otg=OtgKey(code=16, is_modifier=True)), + "ShiftRight": Key(mcu=McuKey(code=82), otg=OtgKey(code=32, is_modifier=True)), + "AltRight": Key(mcu=McuKey(code=83), otg=OtgKey(code=64, is_modifier=True)), + "MetaRight": Key(mcu=McuKey(code=84), otg=OtgKey(code=128, is_modifier=True)), + "Pause": Key(mcu=McuKey(code=85), otg=OtgKey(code=72, is_modifier=False)), + "ScrollLock": Key(mcu=McuKey(code=86), otg=OtgKey(code=71, is_modifier=False)), + "NumLock": Key(mcu=McuKey(code=87), otg=OtgKey(code=83, is_modifier=False)), + "ContextMenu": Key(mcu=McuKey(code=88), otg=OtgKey(code=101, is_modifier=False)), + "NumpadDivide": Key(mcu=McuKey(code=89), otg=OtgKey(code=84, is_modifier=False)), + "NumpadMultiply": Key(mcu=McuKey(code=90), otg=OtgKey(code=85, is_modifier=False)), + "NumpadSubtract": Key(mcu=McuKey(code=91), otg=OtgKey(code=86, is_modifier=False)), + "NumpadAdd": Key(mcu=McuKey(code=92), otg=OtgKey(code=87, is_modifier=False)), + "NumpadEnter": Key(mcu=McuKey(code=93), otg=OtgKey(code=88, is_modifier=False)), + "Numpad1": Key(mcu=McuKey(code=94), otg=OtgKey(code=89, is_modifier=False)), + "Numpad2": Key(mcu=McuKey(code=95), otg=OtgKey(code=90, is_modifier=False)), + "Numpad3": Key(mcu=McuKey(code=96), otg=OtgKey(code=91, is_modifier=False)), + "Numpad4": Key(mcu=McuKey(code=97), otg=OtgKey(code=92, is_modifier=False)), + "Numpad5": Key(mcu=McuKey(code=98), otg=OtgKey(code=93, is_modifier=False)), + "Numpad6": Key(mcu=McuKey(code=99), otg=OtgKey(code=94, is_modifier=False)), + "Numpad7": Key(mcu=McuKey(code=100), otg=OtgKey(code=95, is_modifier=False)), + "Numpad8": Key(mcu=McuKey(code=101), otg=OtgKey(code=96, is_modifier=False)), + "Numpad9": Key(mcu=McuKey(code=102), otg=OtgKey(code=97, is_modifier=False)), + "Numpad0": Key(mcu=McuKey(code=103), otg=OtgKey(code=98, is_modifier=False)), + "NumpadDecimal": Key(mcu=McuKey(code=104), otg=OtgKey(code=99, is_modifier=False)), + "Power": Key(mcu=McuKey(code=105), otg=OtgKey(code=102, is_modifier=False)), + "IntlBackslash": Key(mcu=McuKey(code=106), otg=OtgKey(code=100, is_modifier=False)), } diff --git a/kvmd/keyboard/mappings.py.mako b/kvmd/keyboard/mappings.py.mako index 399ed75e..5f0fc9ad 100644 --- a/kvmd/keyboard/mappings.py.mako +++ b/kvmd/keyboard/mappings.py.mako @@ -27,7 +27,7 @@ from typing import Dict # ===== @dataclasses.dataclass(frozen=True) -class SerialKey: +class McuKey: code: int @@ -39,13 +39,13 @@ class OtgKey: @dataclasses.dataclass(frozen=True) class Key: - serial: SerialKey + mcu: McuKey otg: OtgKey <%! import operator %> KEYMAP: Dict[str, Key] = { -% for km in sorted(keymap, key=operator.attrgetter("serial_code")): - "${km.web_name}": Key(serial=SerialKey(code=${km.serial_code}), otg=OtgKey(code=${km.otg_key.code}, is_modifier=${km.otg_key.is_modifier})), +% for km in sorted(keymap, key=operator.attrgetter("mcu_code")): + "${km.web_name}": Key(mcu=McuKey(code=${km.mcu_code}), otg=OtgKey(code=${km.otg_key.code}, is_modifier=${km.otg_key.is_modifier})), % endfor } diff --git a/kvmd/plugins/hid/_mcu/__init__.py b/kvmd/plugins/hid/_mcu/__init__.py index bc978499..71981e0d 100644 --- a/kvmd/plugins/hid/_mcu/__init__.py +++ b/kvmd/plugins/hid/_mcu/__init__.py @@ -93,7 +93,7 @@ class _KeyEvent(_BaseEvent): assert self.name in KEYMAP def make_command(self) -> bytes: - code = KEYMAP[self.name].serial.code + code = KEYMAP[self.name].mcu.code return struct.pack(">BBBxx", 0x11, code, int(self.state)) diff --git a/testenv/linters/vulture-wl.py b/testenv/linters/vulture-wl.py index 608f0aab..8d353b08 100644 --- a/testenv/linters/vulture-wl.py +++ b/testenv/linters/vulture-wl.py @@ -21,7 +21,7 @@ IpmiServer.handle_raw_request _AtxApiPart.switch_power _KeyMapping.web_name -_KeyMapping.serial_code +_KeyMapping.mcu_code _KeyMapping.arduino_name _KeyMapping.otg_key _KeyMapping.ps2_key diff --git a/testenv/tests/keyboard/test_keymap.py b/testenv/tests/keyboard/test_keymap.py index 9a397c6e..ad26d780 100644 --- a/testenv/tests/keyboard/test_keymap.py +++ b/testenv/tests/keyboard/test_keymap.py @@ -27,7 +27,7 @@ from kvmd.keyboard.mappings import KEYMAP # ===== def test_ok__keymap() -> None: - assert KEYMAP["KeyA"].serial.code == 1 + assert KEYMAP["KeyA"].mcu.code == 1 def test_fail__keymap() -> None: |