summaryrefslogtreecommitdiff
path: root/kvmd/plugins/hid/otg/keyboard.py
diff options
context:
space:
mode:
Diffstat (limited to 'kvmd/plugins/hid/otg/keyboard.py')
-rw-r--r--kvmd/plugins/hid/otg/keyboard.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/kvmd/plugins/hid/otg/keyboard.py b/kvmd/plugins/hid/otg/keyboard.py
index 6cf8f72d..6c9ddfed 100644
--- a/kvmd/plugins/hid/otg/keyboard.py
+++ b/kvmd/plugins/hid/otg/keyboard.py
@@ -65,7 +65,12 @@ class _KeyEvent(BaseEvent):
# =====
class KeyboardProcess(BaseDeviceProcess):
def __init__(self, **kwargs: Any) -> None:
- super().__init__(name="keyboard", **kwargs)
+ super().__init__(
+ name="keyboard",
+ read_size=1,
+ initial_state={"leds": {"caps": False, "scroll": False, "num": False}},
+ **kwargs,
+ )
self.__pressed_modifiers: Set[keymap.OtgKey] = set()
self.__pressed_keys: List[Optional[keymap.OtgKey]] = [None] * 6
@@ -90,6 +95,17 @@ class KeyboardProcess(BaseDeviceProcess):
# =====
+ def _process_read_report(self, report: bytes) -> None:
+ # https://wiki.osdev.org/USB_Human_Interface_Devices#LED_lamps
+ assert len(report) == 1, report
+ self._update_state("leds", {
+ "caps": bool(report[0] & 2),
+ "scroll": bool(report[0] & 4),
+ "num": bool(report[0] & 1),
+ })
+
+ # =====
+
def _process_event(self, event: BaseEvent) -> None:
if isinstance(event, _ClearEvent):
self.__process_clear_event()