mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 17:20: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.__notifier = aiomulti.AioProcessNotifier()
|
||||||
self.__state_flags = aiomulti.AioSharedFlags({
|
self.__state_flags = aiomulti.AioSharedFlags({
|
||||||
"online": 0,
|
"online": 0,
|
||||||
|
"busy": 0,
|
||||||
"status": 0,
|
"status": 0,
|
||||||
}, self.__notifier, type=int)
|
}, self.__notifier, type=int)
|
||||||
|
|
||||||
@ -195,6 +196,7 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many-
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
"online": online,
|
"online": online,
|
||||||
|
"busy": bool(state["busy"]),
|
||||||
"keyboard": {
|
"keyboard": {
|
||||||
"online": (online and not (pong & 0b00001000)),
|
"online": (online and not (pong & 0b00001000)),
|
||||||
"leds": {
|
"leds": {
|
||||||
@ -306,8 +308,12 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many-
|
|||||||
self.__process_request(conn, REQUEST_PING)
|
self.__process_request(conn, REQUEST_PING)
|
||||||
else:
|
else:
|
||||||
if isinstance(event, _HardResetEvent):
|
if isinstance(event, _HardResetEvent):
|
||||||
|
self.__set_state_busy(True)
|
||||||
self.__gpio.reset()
|
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()
|
self.clear_events()
|
||||||
except Exception:
|
except Exception:
|
||||||
self.clear_events()
|
self.clear_events()
|
||||||
@ -382,10 +388,14 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many-
|
|||||||
def __set_state_online(self, online: bool) -> None:
|
def __set_state_online(self, online: bool) -> None:
|
||||||
self.__state_flags.update(online=int(online))
|
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:
|
def __set_state_pong(self, response: bytes) -> None:
|
||||||
status = response[1] << 16
|
status = response[1] << 16
|
||||||
if len(response) > 4:
|
if len(response) > 4:
|
||||||
status |= (response[2] << 8) | response[3]
|
status |= (response[2] << 8) | response[3]
|
||||||
self.__state_flags.update(online=1, status=status)
|
reset_required = (1 if response[1] & 0b01000000 else 0)
|
||||||
if response[1] & 0b01000000: # Reset required
|
self.__state_flags.update(online=1, busy=reset_required, status=status)
|
||||||
|
if reset_required:
|
||||||
self.__gpio.reset()
|
self.__gpio.reset()
|
||||||
|
|||||||
@ -134,6 +134,7 @@ class Plugin(BaseHid): # pylint: disable=too-many-instance-attributes
|
|||||||
outputs: Dict = {"available": [], "active": ""}
|
outputs: Dict = {"available": [], "active": ""}
|
||||||
return {
|
return {
|
||||||
"online": True,
|
"online": True,
|
||||||
|
"busy": False,
|
||||||
"keyboard": {
|
"keyboard": {
|
||||||
"online": state["online"],
|
"online": state["online"],
|
||||||
"leds": {
|
"leds": {
|
||||||
|
|||||||
@ -92,6 +92,7 @@ class Plugin(BaseHid):
|
|||||||
outputs: Dict = {"available": [], "active": ""}
|
outputs: Dict = {"available": [], "active": ""}
|
||||||
return {
|
return {
|
||||||
"online": True,
|
"online": True,
|
||||||
|
"busy": False,
|
||||||
"keyboard": {
|
"keyboard": {
|
||||||
"online": keyboard_state["online"],
|
"online": keyboard_state["online"],
|
||||||
"leds": {
|
"leds": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user