hid with granularity prototype

This commit is contained in:
Maxim Devaev
2024-11-03 18:28:28 +02:00
parent 1e277c0f06
commit d93639ba8d
9 changed files with 164 additions and 90 deletions

View File

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

View File

@@ -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),

View File

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

View File

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

View File

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