summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgenmap.py16
-rw-r--r--hid/src/keymap.h.mako4
-rw-r--r--keymap.in181
-rw-r--r--kvmd/keymap.py437
-rw-r--r--kvmd/keymap.py.mako14
-rw-r--r--testenv/linters/vulture-wl.py12
6 files changed, 470 insertions, 194 deletions
diff --git a/genmap.py b/genmap.py
index 856af8bb..a94b50fd 100755
--- a/genmap.py
+++ b/genmap.py
@@ -33,9 +33,11 @@ import mako.template
# =====
@dataclasses.dataclass(frozen=True)
class _KeyMapping:
- serial_hid_code: int
- serial_hid_key: str
web_key: str
+ serial_code: int
+ arduino_key: str
+ otg_code: int
+ otg_is_modifier: bool
def _read_keymap_in(path: str) -> List[_KeyMapping]:
@@ -45,11 +47,13 @@ def _read_keymap_in(path: str) -> List[_KeyMapping]:
line = line.strip()
if len(line) > 0 and not line.startswith("#"):
parts = list(map(str.strip, line.split()))
- if len(parts) >= 3:
+ if len(parts) >= 5:
keymap.append(_KeyMapping(
- serial_hid_code=int(parts[0]),
- serial_hid_key=parts[1],
- web_key=parts[2],
+ web_key=parts[0],
+ serial_code=int(parts[1]),
+ arduino_key=parts[2],
+ otg_code=int(parts[3], 16),
+ otg_is_modifier=(parts[4].lower() == "m"),
))
return keymap
diff --git a/hid/src/keymap.h.mako b/hid/src/keymap.h.mako
index 7eb4d5d0..b52375a5 100644
--- a/hid/src/keymap.h.mako
+++ b/hid/src/keymap.h.mako
@@ -29,8 +29,8 @@
<%! import operator %>
INLINE KeyboardKeycode keymap(uint8_t code) {
switch(code) {
-% for km in sorted(keymap, key=operator.attrgetter("serial_hid_key")):
- case ${km.serial_hid_code}: return ${km.serial_hid_key};
+% for km in sorted(keymap, key=operator.attrgetter("arduino_key")):
+ case ${km.serial_code}: return ${km.arduino_key};
% endfor
default: return KEY_ERROR_UNDEFINED;
}
diff --git a/keymap.in b/keymap.in
index 1ba187ae..9ac296b9 100644
--- a/keymap.in
+++ b/keymap.in
@@ -20,98 +20,99 @@
# ========================================================================== #
-# https://github.com/NicoHood/HID/blob/master/src/HID-APIs/ImprovedKeylayouts.h
# https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code
+# https://github.com/NicoHood/HID/blob/master/src/HID-APIs/ImprovedKeylayouts.h
+# https://gist.github.com/MightyPork/6da26e382a7ad91b5496ee55fdc73db2
-# ----------------------------------
-# KVMD | Arduino HID | JS
-# ----------------------------------
-1 KEY_A KeyA
-2 KEY_B KeyB
-3 KEY_C KeyC
-4 KEY_D KeyD
-5 KEY_E KeyE
-6 KEY_F KeyF
-7 KEY_G KeyG
-8 KEY_H KeyH
-9 KEY_I KeyI
-10 KEY_J KeyJ
-11 KEY_K KeyK
-12 KEY_L KeyL
-13 KEY_M KeyM
-14 KEY_N KeyN
-15 KEY_O KeyO
-16 KEY_P KeyP
-17 KEY_Q KeyQ
-18 KEY_R KeyR
-19 KEY_S KeyS
-20 KEY_T KeyT
-21 KEY_U KeyU
-22 KEY_V KeyV
-23 KEY_W KeyW
-24 KEY_X KeyX
-25 KEY_Y KeyY
-26 KEY_Z KeyZ
-27 KEY_1 Digit1
-28 KEY_2 Digit2
-29 KEY_3 Digit3
-30 KEY_4 Digit4
-31 KEY_5 Digit5
-32 KEY_6 Digit6
-33 KEY_7 Digit7
-34 KEY_8 Digit8
-35 KEY_9 Digit9
-36 KEY_0 Digit0
-37 KEY_ENTER Enter
-38 KEY_ESC Escape
-39 KEY_BACKSPACE Backspace
-40 KEY_TAB Tab
-41 KEY_SPACE Space
-42 KEY_MINUS Minus
-43 KEY_EQUAL Equal
-44 KEY_LEFT_BRACE BracketLeft
-45 KEY_RIGHT_BRACE BracketRight
-46 KEY_BACKSLASH Backslash
-47 KEY_SEMICOLON Semicolon
-48 KEY_QUOTE Quote
-49 KEY_TILDE Backquote
-50 KEY_COMMA Comma
-51 KEY_PERIOD Period
-52 KEY_SLASH Slash
-53 KEY_CAPS_LOCK CapsLock
-54 KEY_F1 F1
-55 KEY_F2 F2
-56 KEY_F3 F3
-57 KEY_F4 F4
-58 KEY_F5 F5
-59 KEY_F6 F6
-60 KEY_F7 F7
-61 KEY_F8 F8
-62 KEY_F9 F9
-63 KEY_F10 F10
-64 KEY_F11 F11
-65 KEY_F12 F12
-66 KEY_PRINT PrintScreen
-67 KEY_INSERT Insert
-68 KEY_HOME Home
-69 KEY_PAGE_UP PageUp
-70 KEY_DELETE Delete
-71 KEY_END End
-72 KEY_PAGE_DOWN PageDown
-73 KEY_RIGHT_ARROW ArrowRight
-74 KEY_LEFT_ARROW ArrowLeft
-75 KEY_DOWN_ARROW ArrowDown
-76 KEY_UP_ARROW ArrowUp
-77 KEY_LEFT_CTRL ControlLeft
-78 KEY_LEFT_SHIFT ShiftLeft
-79 KEY_LEFT_ALT AltLeft
-80 KEY_LEFT_GUI MetaLeft
-81 KEY_RIGHT_CTRL ControlRight
-82 KEY_RIGHT_SHIFT ShiftRight
-83 KEY_RIGHT_ALT AltRight
-84 KEY_RIGHT_GUI MetaRight
-85 KEY_PAUSE Pause
-86 KEY_SCROLL_LOCK ScrollLock
+# -----------------------------------------------------------------------------------
+# Web | Serial code | Arduino key | OTG code + modifier flag
+# -----------------------------------------------------------------------------------
+KeyA 1 KEY_A 0x04 -
+KeyB 2 KEY_B 0x05 -
+KeyC 3 KEY_C 0x06 -
+KeyD 4 KEY_D 0x07 -
+KeyE 5 KEY_E 0x08 -
+KeyF 6 KEY_F 0x09 -
+KeyG 7 KEY_G 0x0a -
+KeyH 8 KEY_H 0x0b -
+KeyI 9 KEY_I 0x0c -
+KeyJ 10 KEY_J 0x0d -
+KeyK 11 KEY_K 0x0e -
+KeyL 12 KEY_L 0x0f -
+KeyM 13 KEY_M 0x10 -
+KeyN 14 KEY_N 0x11 -
+KeyO 15 KEY_O 0x12 -
+KeyP 16 KEY_P 0x13 -
+KeyQ 17 KEY_Q 0x14 -
+KeyR 18 KEY_R 0x15 -
+KeyS 19 KEY_S 0x16 -
+KeyT 20 KEY_T 0x17 -
+KeyU 21 KEY_U 0x18 -
+KeyV 22 KEY_V 0x19 -
+KeyW 23 KEY_W 0x1a -
+KeyX 24 KEY_X 0x1b -
+KeyY 25 KEY_Y 0x1c -
+KeyZ 26 KEY_Z 0x1d -
+Digit1 27 KEY_1 0x1e -
+Digit2 28 KEY_2 0x1f -
+Digit3 29 KEY_3 0x20 -
+Digit4 30 KEY_4 0x21 -
+Digit5 31 KEY_5 0x22 -
+Digit6 32 KEY_6 0x23 -
+Digit7 33 KEY_7 0x24 -
+Digit8 34 KEY_8 0x25 -
+Digit9 35 KEY_9 0x26 -
+Digit0 36 KEY_0 0x27 -
+Enter 37 KEY_ENTER 0x28 -
+Escape 38 KEY_ESC 0x29 -
+Backspace 39 KEY_BACKSPACE 0x2a -
+Tab 40 KEY_TAB 0x2b -
+Space 41 KEY_SPACE 0x2c -
+Minus 42 KEY_MINUS 0x2d -
+Equal 43 KEY_EQUAL 0x2e -
+BracketLeft 44 KEY_LEFT_BRACE 0x2f -
+BracketRight 45 KEY_RIGHT_BRACE 0x30 -
+Backslash 46 KEY_BACKSLASH 0x31 -
+Semicolon 47 KEY_SEMICOLON 0x33 -
+Quote 48 KEY_QUOTE 0x34 -
+Backquote 49 KEY_TILDE 0x35 -
+Comma 50 KEY_COMMA 0x36 -
+Period 51 KEY_PERIOD 0x37 -
+Slash 52 KEY_SLASH 0x38 -
+CapsLock 53 KEY_CAPS_LOCK 0x39 -
+F1 54 KEY_F1 0x3a -
+F2 55 KEY_F2 0x3b -
+F3 56 KEY_F3 0x3c -
+F4 57 KEY_F4 0x3d -
+F5 58 KEY_F5 0x3e -
+F6 59 KEY_F6 0x3f -
+F7 60 KEY_F7 0x40 -
+F8 61 KEY_F8 0x41 -
+F9 62 KEY_F9 0x42 -
+F10 63 KEY_F10 0x43 -
+F11 64 KEY_F11 0x44 -
+F12 65 KEY_F12 0x45 -
+PrintScreen 66 KEY_PRINT 0x46 -
+Insert 67 KEY_INSERT 0x49 -
+Home 68 KEY_HOME 0x4a -
+PageUp 69 KEY_PAGE_UP 0x4b -
+Delete 70 KEY_DELETE 0x4c -
+End 71 KEY_END 0x4d -
+PageDown 72 KEY_PAGE_DOWN 0x4e -
+ArrowRight 73 KEY_RIGHT_ARROW 0x4f -
+ArrowLeft 74 KEY_LEFT_ARROW 0x50 -
+ArrowDown 75 KEY_DOWN_ARROW 0x51 -
+ArrowUp 76 KEY_UP_ARROW 0x52 -
+ControlLeft 77 KEY_LEFT_CTRL 0x01 m
+ShiftLeft 78 KEY_LEFT_SHIFT 0x02 m
+AltLeft 79 KEY_LEFT_ALT 0x04 m
+MetaLeft 80 KEY_LEFT_GUI 0x08 m
+ControlRight 81 KEY_RIGHT_CTRL 0x10 m
+ShiftRight 82 KEY_RIGHT_SHIFT 0x20 m
+AltRight 83 KEY_RIGHT_ALT 0x40 m
+MetaRight 84 KEY_RIGHT_GUI 0x80 m
+Pause 85 KEY_PAUSE 0x48 -
+ScrollLock 86 KEY_SCROLL_LOCK 0x47 -
# KEY_NON_US_NUM
# KEY_NUM_LOCK
# KEYPAD_DIVIDE
diff --git a/kvmd/keymap.py b/kvmd/keymap.py
index be32bae2..3b4a713e 100644
--- a/kvmd/keymap.py
+++ b/kvmd/keymap.py
@@ -32,96 +32,361 @@ class SerialKey:
@dataclasses.dataclass(frozen=True)
+class OtgKey:
+ code: int
+ is_modifier: bool
+
+
[email protected](frozen=True)
class Key:
serial: SerialKey
+ otg: OtgKey
# =====
KEYMAP: Dict[str, Key] = {
- "AltLeft": Key(serial=SerialKey(code=79)),
- "AltRight": Key(serial=SerialKey(code=83)),
- "ArrowDown": Key(serial=SerialKey(code=75)),
- "ArrowLeft": Key(serial=SerialKey(code=74)),
- "ArrowRight": Key(serial=SerialKey(code=73)),
- "ArrowUp": Key(serial=SerialKey(code=76)),
- "Backquote": Key(serial=SerialKey(code=49)),
- "Backslash": Key(serial=SerialKey(code=46)),
- "Backspace": Key(serial=SerialKey(code=39)),
- "BracketLeft": Key(serial=SerialKey(code=44)),
- "BracketRight": Key(serial=SerialKey(code=45)),
- "CapsLock": Key(serial=SerialKey(code=53)),
- "Comma": Key(serial=SerialKey(code=50)),
- "ControlLeft": Key(serial=SerialKey(code=77)),
- "ControlRight": Key(serial=SerialKey(code=81)),
- "Delete": Key(serial=SerialKey(code=70)),
- "Digit0": Key(serial=SerialKey(code=36)),
- "Digit1": Key(serial=SerialKey(code=27)),
- "Digit2": Key(serial=SerialKey(code=28)),
- "Digit3": Key(serial=SerialKey(code=29)),
- "Digit4": Key(serial=SerialKey(code=30)),
- "Digit5": Key(serial=SerialKey(code=31)),
- "Digit6": Key(serial=SerialKey(code=32)),
- "Digit7": Key(serial=SerialKey(code=33)),
- "Digit8": Key(serial=SerialKey(code=34)),
- "Digit9": Key(serial=SerialKey(code=35)),
- "End": Key(serial=SerialKey(code=71)),
- "Enter": Key(serial=SerialKey(code=37)),
- "Equal": Key(serial=SerialKey(code=43)),
- "Escape": Key(serial=SerialKey(code=38)),
- "F1": Key(serial=SerialKey(code=54)),
- "F10": Key(serial=SerialKey(code=63)),
- "F11": Key(serial=SerialKey(code=64)),
- "F12": Key(serial=SerialKey(code=65)),
- "F2": Key(serial=SerialKey(code=55)),
- "F3": Key(serial=SerialKey(code=56)),
- "F4": Key(serial=SerialKey(code=57)),
- "F5": Key(serial=SerialKey(code=58)),
- "F6": Key(serial=SerialKey(code=59)),
- "F7": Key(serial=SerialKey(code=60)),
- "F8": Key(serial=SerialKey(code=61)),
- "F9": Key(serial=SerialKey(code=62)),
- "Home": Key(serial=SerialKey(code=68)),
- "Insert": Key(serial=SerialKey(code=67)),
- "KeyA": Key(serial=SerialKey(code=1)),
- "KeyB": Key(serial=SerialKey(code=2)),
- "KeyC": Key(serial=SerialKey(code=3)),
- "KeyD": Key(serial=SerialKey(code=4)),
- "KeyE": Key(serial=SerialKey(code=5)),
- "KeyF": Key(serial=SerialKey(code=6)),
- "KeyG": Key(serial=SerialKey(code=7)),
- "KeyH": Key(serial=SerialKey(code=8)),
- "KeyI": Key(serial=SerialKey(code=9)),
- "KeyJ": Key(serial=SerialKey(code=10)),
- "KeyK": Key(serial=SerialKey(code=11)),
- "KeyL": Key(serial=SerialKey(code=12)),
- "KeyM": Key(serial=SerialKey(code=13)),
- "KeyN": Key(serial=SerialKey(code=14)),
- "KeyO": Key(serial=SerialKey(code=15)),
- "KeyP": Key(serial=SerialKey(code=16)),
- "KeyQ": Key(serial=SerialKey(code=17)),
- "KeyR": Key(serial=SerialKey(code=18)),
- "KeyS": Key(serial=SerialKey(code=19)),
- "KeyT": Key(serial=SerialKey(code=20)),
- "KeyU": Key(serial=SerialKey(code=21)),
- "KeyV": Key(serial=SerialKey(code=22)),
- "KeyW": Key(serial=SerialKey(code=23)),
- "KeyX": Key(serial=SerialKey(code=24)),
- "KeyY": Key(serial=SerialKey(code=25)),
- "KeyZ": Key(serial=SerialKey(code=26)),
- "MetaLeft": Key(serial=SerialKey(code=80)),
- "MetaRight": Key(serial=SerialKey(code=84)),
- "Minus": Key(serial=SerialKey(code=42)),
- "PageDown": Key(serial=SerialKey(code=72)),
- "PageUp": Key(serial=SerialKey(code=69)),
- "Pause": Key(serial=SerialKey(code=85)),
- "Period": Key(serial=SerialKey(code=51)),
- "PrintScreen": Key(serial=SerialKey(code=66)),
- "Quote": Key(serial=SerialKey(code=48)),
- "ScrollLock": Key(serial=SerialKey(code=86)),
- "Semicolon": Key(serial=SerialKey(code=47)),
- "ShiftLeft": Key(serial=SerialKey(code=78)),
- "ShiftRight": Key(serial=SerialKey(code=82)),
- "Slash": Key(serial=SerialKey(code=52)),
- "Space": Key(serial=SerialKey(code=41)),
- "Tab": Key(serial=SerialKey(code=40)),
+ "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),
+ ),
}
diff --git a/kvmd/keymap.py.mako b/kvmd/keymap.py.mako
index 06b0c7d9..219cb186 100644
--- a/kvmd/keymap.py.mako
+++ b/kvmd/keymap.py.mako
@@ -32,13 +32,23 @@ class SerialKey:
@dataclasses.dataclass(frozen=True)
+class OtgKey:
+ code: int
+ is_modifier: bool
+
+
[email protected](frozen=True)
class Key:
serial: SerialKey
+ otg: OtgKey
<%! import operator %>
# =====
KEYMAP: Dict[str, Key] = {
-% for km in sorted(keymap, key=operator.attrgetter("web_key")):
- "${km.web_key}": Key(serial=SerialKey(code=${km.serial_hid_code})),
+% for km in sorted(keymap, key=operator.attrgetter("serial_code")):
+ "${km.web_key}": Key(
+ serial=SerialKey(code=${km.serial_code}),
+ otg=OtgKey(code=${km.otg_code}, is_modifier=${km.otg_is_modifier}),
+ ),
% endfor
}
diff --git a/testenv/linters/vulture-wl.py b/testenv/linters/vulture-wl.py
index 377c71a6..27112cb5 100644
--- a/testenv/linters/vulture-wl.py
+++ b/testenv/linters/vulture-wl.py
@@ -1,15 +1,11 @@
-_MassStorageDeviceInfo.manufacturer
-_MassStorageDeviceInfo.product
-_MassStorageDeviceInfo.real
-_MassStorageDeviceInfo.hw
-_MassStorageDeviceInfo.image
-
IpmiServer.handle_raw_request
fake_rpi.RPi.GPIO
-_KeyMapping.serial_hid_code
-_KeyMapping.serial_hid_key
_KeyMapping.web_key
+_KeyMapping.serial_code
+_KeyMapping.arduino_key
+_KeyMapping.otg_code
+_KeyMapping.otg_is_modifier
_ScriptWriter.get_args