mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
hid busy flag
This commit is contained in:
parent
fd1e0d7296
commit
744fd19db9
@ -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,8 +308,12 @@ 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()):
|
||||
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()
|
||||
@ -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()
|
||||
|
||||
@ -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": {
|
||||
|
||||
@ -92,6 +92,7 @@ class Plugin(BaseHid):
|
||||
outputs: Dict = {"available": [], "active": ""}
|
||||
return {
|
||||
"online": True,
|
||||
"busy": False,
|
||||
"keyboard": {
|
||||
"online": keyboard_state["online"],
|
||||
"leds": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user