summaryrefslogtreecommitdiff
path: root/kvmd/apps
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2023-06-07 05:12:22 +0300
committerMaxim Devaev <[email protected]>2023-06-07 05:12:22 +0300
commit9f98a2f701703a3f9f591868547c834463d3d6b1 (patch)
treef2fe4f4541c78edaa6ec791a304d73f0595d4751 /kvmd/apps
parent9c694da00c7d93cbff3aa910ffdeeb8dded691c0 (diff)
binary keyboard protocol
Diffstat (limited to 'kvmd/apps')
-rw-r--r--kvmd/apps/kvmd/api/hid.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/kvmd/apps/kvmd/api/hid.py b/kvmd/apps/kvmd/api/hid.py
index 8143deff..a2ea5d4c 100644
--- a/kvmd/apps/kvmd/api/hid.py
+++ b/kvmd/apps/kvmd/api/hid.py
@@ -154,6 +154,25 @@ class HidApi:
# =====
+ @exposed_ws(1)
+ async def __ws_bin_key_handler(self, _: WsSession, data: bytes) -> None:
+ try:
+ key = valid_hid_key(data[1:].decode("ascii"))
+ state = valid_bool(data[0])
+ except Exception:
+ return
+ if key not in self.__ignore_keys:
+ self.__hid.send_key_events([(key, state)])
+
+ @exposed_ws(2)
+ async def __ws_bin_mouse_button_handler(self, _: WsSession, data: bytes) -> None:
+ try:
+ button = valid_hid_mouse_button(data[1:].decode("ascii"))
+ state = valid_bool(data[0])
+ except Exception:
+ return
+ self.__hid.send_mouse_button_event(button, state)
+
@exposed_ws(3)
async def __ws_bin_mouse_move_handler(self, _: WsSession, data: bytes) -> None:
try: