summaryrefslogtreecommitdiff
path: root/kvmd/apps
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2024-12-30 18:55:59 +0200
committerMaxim Devaev <[email protected]>2024-12-30 18:55:59 +0200
commitfed3bf1efdea7528919eb9f318c5ada2dcf35410 (patch)
treef1bd27d882b85cf845b92b489b1c494c4d1dd715 /kvmd/apps
parentd52bb34bb9f5bc669f6b915ba585461356128e39 (diff)
pikvm/pikvm#1334: Bad link mode for keyboard events
Diffstat (limited to 'kvmd/apps')
-rw-r--r--kvmd/apps/kvmd/api/hid.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/kvmd/apps/kvmd/api/hid.py b/kvmd/apps/kvmd/api/hid.py
index 5ba22abb..98b96313 100644
--- a/kvmd/apps/kvmd/api/hid.py
+++ b/kvmd/apps/kvmd/api/hid.py
@@ -149,16 +149,17 @@ class HidApi:
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])
+ state = bool(data[0] & 0b01)
+ finish = bool(data[0] & 0b10)
except Exception:
return
- self.__hid.send_key_event(key, state)
+ self.__hid.send_key_event(key, state, finish)
@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])
+ state = bool(data[0] & 0b01)
except Exception:
return
self.__hid.send_mouse_button_event(button, state)
@@ -183,7 +184,7 @@ class HidApi:
def __process_ws_bin_delta_request(self, data: bytes, handler: Callable[[Iterable[tuple[int, int]], bool], None]) -> None:
try:
- squash = valid_bool(data[0])
+ squash = bool(data[0] & 0b01)
data = data[1:]
deltas: list[tuple[int, int]] = []
for index in range(0, len(data), 2):
@@ -200,9 +201,10 @@ class HidApi:
try:
key = valid_hid_key(event["key"])
state = valid_bool(event["state"])
+ finish = valid_bool(event.get("finish", False))
except Exception:
return
- self.__hid.send_key_event(key, state)
+ self.__hid.send_key_event(key, state, finish)
@exposed_ws("mouse_button")
async def __ws_mouse_button_handler(self, _: WsSession, event: dict) -> None:
@@ -249,9 +251,10 @@ class HidApi:
key = valid_hid_key(req.query.get("key"))
if "state" in req.query:
state = valid_bool(req.query["state"])
- self.__hid.send_key_event(key, state)
+ finish = valid_bool(req.query.get("finish", False))
+ self.__hid.send_key_event(key, state, finish)
else:
- await self.__hid.send_key_events([(key, True), (key, False)], slow=True)
+ self.__hid.send_key_event(key, True, True)
return make_json_response()
@exposed_http("POST", "/hid/events/send_mouse_button")