summaryrefslogtreecommitdiff
path: root/kvmd/plugins
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-12-02 04:52:05 +0300
committerDevaev Maxim <[email protected]>2020-12-02 04:52:05 +0300
commit744fd19db95d4c7650f2e40690a7bb1cbbc97ef2 (patch)
tree8d9351559dbe054dfc82a638f9ed601a6019a987 /kvmd/plugins
parentfd1e0d7296c1259a5cbf810817a812a39f9a0ff0 (diff)
hid busy flag
Diffstat (limited to 'kvmd/plugins')
-rw-r--r--kvmd/plugins/hid/_mcu/__init__.py18
-rw-r--r--kvmd/plugins/hid/bt/__init__.py1
-rw-r--r--kvmd/plugins/hid/otg/__init__.py1
3 files changed, 16 insertions, 4 deletions
diff --git a/kvmd/plugins/hid/_mcu/__init__.py b/kvmd/plugins/hid/_mcu/__init__.py
index 38707572..4d3df434 100644
--- a/kvmd/plugins/hid/_mcu/__init__.py
+++ b/kvmd/plugins/hid/_mcu/__init__.py
@@ -139,6 +139,7 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many-
self.__notifier = aiomulti.AioProcessNotifier()
self.__state_flags = aiomulti.AioSharedFlags({
"online": 0,
+ "busy": 0,
"status": 0,
}, self.__notifier, type=int)
@@ -195,6 +196,7 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many-
return {
"online": online,
+ "busy": bool(state["busy"]),
"keyboard": {
"online": (online and not (pong & 0b00001000)),
"leds": {
@@ -306,9 +308,13 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many-
self.__process_request(conn, REQUEST_PING)
else:
if isinstance(event, _HardResetEvent):
+ self.__set_state_busy(True)
self.__gpio.reset()
- elif not self.__process_request(conn, event.make_request()):
- self.clear_events()
+ else:
+ if isinstance(event, (SetKeyboardOutputEvent, SetMouseOutputEvent)):
+ self.__set_state_busy(True)
+ if not self.__process_request(conn, event.make_request()):
+ self.clear_events()
except Exception:
self.clear_events()
logger.exception("Unexpected error in the HID loop")
@@ -382,10 +388,14 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many-
def __set_state_online(self, online: bool) -> None:
self.__state_flags.update(online=int(online))
+ def __set_state_busy(self, busy: bool) -> None:
+ self.__state_flags.update(busy=int(busy))
+
def __set_state_pong(self, response: bytes) -> None:
status = response[1] << 16
if len(response) > 4:
status |= (response[2] << 8) | response[3]
- self.__state_flags.update(online=1, status=status)
- if response[1] & 0b01000000: # Reset required
+ reset_required = (1 if response[1] & 0b01000000 else 0)
+ self.__state_flags.update(online=1, busy=reset_required, status=status)
+ if reset_required:
self.__gpio.reset()
diff --git a/kvmd/plugins/hid/bt/__init__.py b/kvmd/plugins/hid/bt/__init__.py
index 55c4c979..48242bee 100644
--- a/kvmd/plugins/hid/bt/__init__.py
+++ b/kvmd/plugins/hid/bt/__init__.py
@@ -134,6 +134,7 @@ class Plugin(BaseHid): # pylint: disable=too-many-instance-attributes
outputs: Dict = {"available": [], "active": ""}
return {
"online": True,
+ "busy": False,
"keyboard": {
"online": state["online"],
"leds": {
diff --git a/kvmd/plugins/hid/otg/__init__.py b/kvmd/plugins/hid/otg/__init__.py
index 49fec56c..3a3fc791 100644
--- a/kvmd/plugins/hid/otg/__init__.py
+++ b/kvmd/plugins/hid/otg/__init__.py
@@ -92,6 +92,7 @@ class Plugin(BaseHid):
outputs: Dict = {"available": [], "active": ""}
return {
"online": True,
+ "busy": False,
"keyboard": {
"online": keyboard_state["online"],
"leds": {