binary keyboard protocol

This commit is contained in:
Maxim Devaev
2023-06-07 05:12:22 +03:00
parent 9c694da00c
commit 9f98a2f701
6 changed files with 68 additions and 35 deletions

View File

@@ -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: