diff options
author | Devaev Maxim <[email protected]> | 2019-09-24 06:19:29 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2019-09-24 06:19:29 +0300 |
commit | d3d885e1801392fffbd07656f8692c5be6014edd (patch) | |
tree | ce8f5dfed01d9d5f1823b45c82c86635ee2b9786 /kvmd | |
parent | e97a2ea251dc2063998122f750940cf8e690d211 (diff) |
refactoring
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/plugins/atx/__init__.py | 10 | ||||
-rw-r--r-- | kvmd/plugins/hid/__init__.py | 8 | ||||
-rw-r--r-- | kvmd/plugins/hid/serial.py | 36 |
3 files changed, 31 insertions, 23 deletions
diff --git a/kvmd/plugins/atx/__init__.py b/kvmd/plugins/atx/__init__.py index 902e3e7c..f05cef78 100644 --- a/kvmd/plugins/atx/__init__.py +++ b/kvmd/plugins/atx/__init__.py @@ -51,6 +51,11 @@ class BaseAtx(BasePlugin): yield {} raise NotImplementedError + async def cleanup(self) -> None: + pass + + # ===== + async def power_on(self) -> bool: raise NotImplementedError @@ -63,6 +68,8 @@ class BaseAtx(BasePlugin): async def power_reset_hard(self) -> bool: raise NotImplementedError + # ===== + async def click_power(self) -> None: raise NotImplementedError @@ -72,9 +79,6 @@ class BaseAtx(BasePlugin): async def click_reset(self) -> None: raise NotImplementedError - async def cleanup(self) -> None: - pass - # ===== def get_atx_class(name: str) -> Type[BaseAtx]: diff --git a/kvmd/plugins/hid/__init__.py b/kvmd/plugins/hid/__init__.py index cbab9775..bb4ec677 100644 --- a/kvmd/plugins/hid/__init__.py +++ b/kvmd/plugins/hid/__init__.py @@ -43,6 +43,11 @@ class BaseHid(BasePlugin): async def reset(self) -> None: raise NotImplementedError + async def cleanup(self) -> None: + pass + + # ===== + async def send_key_event(self, key: str, state: bool) -> None: raise NotImplementedError @@ -58,9 +63,6 @@ class BaseHid(BasePlugin): async def clear_events(self) -> None: raise NotImplementedError - async def cleanup(self) -> None: - pass - # ===== def get_hid_class(name: str) -> Type[BaseHid]: diff --git a/kvmd/plugins/hid/serial.py b/kvmd/plugins/hid/serial.py index e72961ab..7b7c4275 100644 --- a/kvmd/plugins/hid/serial.py +++ b/kvmd/plugins/hid/serial.py @@ -218,23 +218,6 @@ class Plugin(BaseHid, multiprocessing.Process): # pylint: disable=too-many-inst self.__lock.release() get_logger(0).info("Reset HID performed") - async def send_key_event(self, key: str, state: bool) -> None: - await self.__send_bool_event(_KeyEvent(key, state), self.__pressed_keys) - - async def send_mouse_move_event(self, to_x: int, to_y: int) -> None: - await self.__send_int_event(_MouseMoveEvent(to_x, to_y)) - - async def send_mouse_button_event(self, button: str, state: bool) -> None: - await self.__send_bool_event(_MouseButtonEvent(button, state), self.__pressed_mouse_buttons) - - async def send_mouse_wheel_event(self, delta_y: int) -> None: - await self.__send_int_event(_MouseWheelEvent(0, delta_y)) - - async def clear_events(self) -> None: - if not self.__stop_event.is_set(): - async with self.__lock: - self.__unsafe_clear_events() - @aiotools.atomic async def cleanup(self) -> None: logger = get_logger(0) @@ -252,6 +235,25 @@ class Plugin(BaseHid, multiprocessing.Process): # pylint: disable=too-many-inst finally: gpio.write(self.__reset_pin, False) + # ===== + + async def send_key_event(self, key: str, state: bool) -> None: + await self.__send_bool_event(_KeyEvent(key, state), self.__pressed_keys) + + async def send_mouse_move_event(self, to_x: int, to_y: int) -> None: + await self.__send_int_event(_MouseMoveEvent(to_x, to_y)) + + async def send_mouse_button_event(self, button: str, state: bool) -> None: + await self.__send_bool_event(_MouseButtonEvent(button, state), self.__pressed_mouse_buttons) + + async def send_mouse_wheel_event(self, delta_y: int) -> None: + await self.__send_int_event(_MouseWheelEvent(0, delta_y)) + + async def clear_events(self) -> None: + if not self.__stop_event.is_set(): + async with self.__lock: + self.__unsafe_clear_events() + async def __send_bool_event(self, event: _BoolEvent, pressed: Set[str]) -> None: if not self.__stop_event.is_set(): async with self.__lock: |