diff options
Diffstat (limited to 'kvmd/plugins')
-rw-r--r-- | kvmd/plugins/hid/_mcu/proto.py | 6 | ||||
-rw-r--r-- | kvmd/plugins/hid/otg/events.py | 10 |
2 files changed, 10 insertions, 6 deletions
diff --git a/kvmd/plugins/hid/_mcu/proto.py b/kvmd/plugins/hid/_mcu/proto.py index 90f47508..bc3feafa 100644 --- a/kvmd/plugins/hid/_mcu/proto.py +++ b/kvmd/plugins/hid/_mcu/proto.py @@ -25,6 +25,8 @@ import struct from ....keyboard.mappings import KEYMAP +from ....mouse import MouseRange + from .... import tools @@ -143,8 +145,8 @@ class MouseMoveEvent(BaseEvent): to_y: int def __post_init__(self) -> None: - assert -32768 <= self.to_x <= 32767 - assert -32768 <= self.to_y <= 32767 + assert MouseRange.MIN <= self.to_x <= MouseRange.MAX + assert MouseRange.MIN <= self.to_y <= MouseRange.MAX def make_request(self) -> bytes: return _make_request(struct.pack(">Bhh", 0x12, self.to_x, self.to_y)) diff --git a/kvmd/plugins/hid/otg/events.py b/kvmd/plugins/hid/otg/events.py index 09fd2a5a..229f4faa 100644 --- a/kvmd/plugins/hid/otg/events.py +++ b/kvmd/plugins/hid/otg/events.py @@ -31,6 +31,8 @@ from typing import Union from ....keyboard.mappings import OtgKey from ....keyboard.mappings import KEYMAP +from ....mouse import MouseRange + # ===== class BaseEvent: @@ -126,10 +128,10 @@ class MouseMoveEvent(BaseEvent): to_fixed_y: int = 0 def __post_init__(self) -> None: - assert -32768 <= self.to_x <= 32767 - assert -32768 <= self.to_y <= 32767 - object.__setattr__(self, "to_fixed_x", (self.to_x + 32768) // 2) - object.__setattr__(self, "to_fixed_y", (self.to_y + 32768) // 2) + assert MouseRange.MIN <= self.to_x <= MouseRange.MAX + assert MouseRange.MIN <= self.to_y <= MouseRange.MAX + object.__setattr__(self, "to_fixed_x", MouseRange.remap(self.to_x, 0, MouseRange.MAX)) + object.__setattr__(self, "to_fixed_y", MouseRange.remap(self.to_y, 0, MouseRange.MAX)) @dataclasses.dataclass(frozen=True) |