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:
@@ -81,19 +81,6 @@ class _KeyEvent(_BaseEvent):
|
||||
return struct.pack(">BBBxx", 0x11, code, int(self.state))
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class _MouseMoveEvent(_BaseEvent):
|
||||
to_x: int
|
||||
to_y: int
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
assert -32768 <= self.to_x <= 32767
|
||||
assert -32768 <= self.to_y <= 32767
|
||||
|
||||
def make_command(self) -> bytes:
|
||||
return struct.pack(">Bhh", 0x12, self.to_x, self.to_y)
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class _MouseButtonEvent(_BaseEvent):
|
||||
name: str
|
||||
@@ -113,6 +100,19 @@ class _MouseButtonEvent(_BaseEvent):
|
||||
return struct.pack(">BBxxx", 0x13, code)
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class _MouseMoveEvent(_BaseEvent):
|
||||
to_x: int
|
||||
to_y: int
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
assert -32768 <= self.to_x <= 32767
|
||||
assert -32768 <= self.to_y <= 32767
|
||||
|
||||
def make_command(self) -> bytes:
|
||||
return struct.pack(">Bhh", 0x12, self.to_x, self.to_y)
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
class _MouseWheelEvent(_BaseEvent):
|
||||
delta_x: int
|
||||
@@ -248,12 +248,12 @@ class Plugin(BaseHid, multiprocessing.Process): # pylint: disable=too-many-inst
|
||||
async def send_key_event(self, key: str, state: bool) -> None:
|
||||
await self.__queue_event(_KeyEvent(key, state))
|
||||
|
||||
async def send_mouse_move_event(self, to_x: int, to_y: int) -> None:
|
||||
await self.__queue_event(_MouseMoveEvent(to_x, to_y))
|
||||
|
||||
async def send_mouse_button_event(self, button: str, state: bool) -> None:
|
||||
await self.__queue_event(_MouseButtonEvent(button, state))
|
||||
|
||||
async def send_mouse_move_event(self, to_x: int, to_y: int) -> None:
|
||||
await self.__queue_event(_MouseMoveEvent(to_x, to_y))
|
||||
|
||||
async def send_mouse_wheel_event(self, delta_x: int, delta_y: int) -> None:
|
||||
await self.__queue_event(_MouseWheelEvent(delta_x, delta_y))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user