summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
authorMaxim Devaev <[email protected]>2024-11-03 18:28:28 +0200
committerMaxim Devaev <[email protected]>2024-11-03 18:28:28 +0200
commitd93639ba8dcd003f82221f4ed99159755f2213c3 (patch)
treecc3291955215ec1455f26922f50de27563d47a5f /kvmd
parent1e277c0f06f25e67a35a1b2910ed59333f97f6c0 (diff)
hid with granularity prototype
Diffstat (limited to 'kvmd')
-rw-r--r--kvmd/apps/vnc/server.py6
-rw-r--r--kvmd/plugins/hid/__init__.py13
-rw-r--r--kvmd/plugins/hid/_mcu/__init__.py1
-rw-r--r--kvmd/plugins/hid/bt/__init__.py1
-rw-r--r--kvmd/plugins/hid/ch9329/__init__.py1
-rw-r--r--kvmd/plugins/hid/otg/__init__.py1
6 files changed, 22 insertions, 1 deletions
diff --git a/kvmd/apps/vnc/server.py b/kvmd/apps/vnc/server.py
index c14bb21f..e8524a38 100644
--- a/kvmd/apps/vnc/server.py
+++ b/kvmd/apps/vnc/server.py
@@ -189,7 +189,11 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes
self.__shared_params.name = name
elif event_type == "hid_state":
- if self._encodings.has_leds_state:
+ if (
+ self._encodings.has_leds_state
+ and ("keyboard" in event)
+ and ("leds" in event["keyboard"])
+ ):
await self._send_leds_state(**event["keyboard"]["leds"])
# =====
diff --git a/kvmd/plugins/hid/__init__.py b/kvmd/plugins/hid/__init__.py
index f7debe1d..73ff5d04 100644
--- a/kvmd/plugins/hid/__init__.py
+++ b/kvmd/plugins/hid/__init__.py
@@ -101,6 +101,19 @@ class BaseHid(BasePlugin): # pylint: disable=too-many-instance-attributes
raise NotImplementedError
async def poll_state(self) -> AsyncGenerator[dict, None]:
+ # ==== Granularity table ====
+ # - enabled -- Full
+ # - online -- Partial
+ # - busy -- Partial
+ # - connected -- Partial, nullable
+ # - keyboard.online -- Partial
+ # - keyboard.outputs -- Partial
+ # - keyboard.leds -- Partial
+ # - mouse.online -- Partial
+ # - mouse.outputs -- Partial, follows with absolute
+ # - mouse.absolute -- Partial, follows with outputs
+ # ===========================
+
yield {}
raise NotImplementedError
diff --git a/kvmd/plugins/hid/_mcu/__init__.py b/kvmd/plugins/hid/_mcu/__init__.py
index a4c903b7..d6f04f76 100644
--- a/kvmd/plugins/hid/_mcu/__init__.py
+++ b/kvmd/plugins/hid/_mcu/__init__.py
@@ -217,6 +217,7 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many-
mouse_outputs["active"] = active_mouse
return {
+ "enabled": True,
"online": online,
"busy": bool(state["busy"]),
"connected": (bool(outputs2 & 0b01000000) if outputs2 & 0b10000000 else None),
diff --git a/kvmd/plugins/hid/bt/__init__.py b/kvmd/plugins/hid/bt/__init__.py
index 4d0effb5..0c95a6d5 100644
--- a/kvmd/plugins/hid/bt/__init__.py
+++ b/kvmd/plugins/hid/bt/__init__.py
@@ -141,6 +141,7 @@ class Plugin(BaseHid): # pylint: disable=too-many-instance-attributes
state = await self.__server.get_state()
outputs: dict = {"available": [], "active": ""}
return {
+ "enabled": True,
"online": True,
"busy": False,
"connected": None,
diff --git a/kvmd/plugins/hid/ch9329/__init__.py b/kvmd/plugins/hid/ch9329/__init__.py
index c5d10688..1b235090 100644
--- a/kvmd/plugins/hid/ch9329/__init__.py
+++ b/kvmd/plugins/hid/ch9329/__init__.py
@@ -104,6 +104,7 @@ class Plugin(BaseHid, multiprocessing.Process): # pylint: disable=too-many-inst
absolute = self.__mouse.is_absolute()
leds = await self.__keyboard.get_leds()
return {
+ "enabled": True,
"online": state["online"],
"busy": False,
"connected": None,
diff --git a/kvmd/plugins/hid/otg/__init__.py b/kvmd/plugins/hid/otg/__init__.py
index c95fb7fb..25424257 100644
--- a/kvmd/plugins/hid/otg/__init__.py
+++ b/kvmd/plugins/hid/otg/__init__.py
@@ -134,6 +134,7 @@ class Plugin(BaseHid): # pylint: disable=too-many-instance-attributes
keyboard_state = await self.__keyboard_proc.get_state()
mouse_state = await self.__mouse_current.get_state()
return {
+ "enabled": True,
"online": True,
"busy": False,
"connected": None,