diff options
author | Devaev Maxim <[email protected]> | 2021-03-26 21:32:21 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2021-03-26 21:32:21 +0300 |
commit | a66221a494e35ab070d13291ce82928797bf95d4 (patch) | |
tree | 3dd496eccf1f3281dad1d545e50a111c28ccdfbc /kvmd/plugins/hid/otg/events.py | |
parent | 1674cf70b3f925fe055398911761542c14d304e9 (diff) |
fixed mouse remap
Diffstat (limited to 'kvmd/plugins/hid/otg/events.py')
-rw-r--r-- | kvmd/plugins/hid/otg/events.py | 10 |
1 files changed, 6 insertions, 4 deletions
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) |