mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
refactoring
This commit is contained in:
@@ -256,22 +256,21 @@ class BaseMcuHid(BaseHid, multiprocessing.Process): # pylint: disable=too-many-
|
|||||||
self.__queue_event(MouseWheelEvent(delta_x, delta_y))
|
self.__queue_event(MouseWheelEvent(delta_x, delta_y))
|
||||||
|
|
||||||
def set_keyboard_output(self, output: str) -> None:
|
def set_keyboard_output(self, output: str) -> None:
|
||||||
# FIXME: Если очистка производится со стороны процесса хида, то возможна гонка между
|
self.__queue_event(SetKeyboardOutputEvent(output), clear=True)
|
||||||
# очисткой и добавлением нового события. Неприятно, но не смертельно.
|
|
||||||
# Починить блокировкой после перехода на асинхронные очереди.
|
|
||||||
tools.clear_queue(self.__events_queue)
|
|
||||||
self.__queue_event(SetKeyboardOutputEvent(output))
|
|
||||||
|
|
||||||
def set_mouse_output(self, output: str) -> None:
|
def set_mouse_output(self, output: str) -> None:
|
||||||
tools.clear_queue(self.__events_queue)
|
self.__queue_event(SetMouseOutputEvent(output), clear=True)
|
||||||
self.__queue_event(SetMouseOutputEvent(output))
|
|
||||||
|
|
||||||
def clear_events(self) -> None:
|
def clear_events(self) -> None:
|
||||||
tools.clear_queue(self.__events_queue)
|
self.__queue_event(ClearEvent(), clear=True)
|
||||||
self.__queue_event(ClearEvent())
|
|
||||||
|
|
||||||
def __queue_event(self, event: BaseEvent) -> None:
|
def __queue_event(self, event: BaseEvent, clear: bool=False) -> None:
|
||||||
if not self.__stop_event.is_set():
|
if not self.__stop_event.is_set():
|
||||||
|
if clear:
|
||||||
|
# FIXME: Если очистка производится со стороны процесса хида, то возможна гонка между
|
||||||
|
# очисткой и добавлением нового события. Неприятно, но не смертельно.
|
||||||
|
# Починить блокировкой после перехода на асинхронные очереди.
|
||||||
|
tools.clear_queue(self.__events_queue)
|
||||||
self.__events_queue.put_nowait(event)
|
self.__events_queue.put_nowait(event)
|
||||||
|
|
||||||
def run(self) -> None: # pylint: disable=too-many-branches
|
def run(self) -> None: # pylint: disable=too-many-branches
|
||||||
|
|||||||
Reference in New Issue
Block a user