diff options
author | Maxim Devaev <[email protected]> | 2023-06-01 16:54:08 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2023-07-10 03:02:28 +0300 |
commit | ce81c872eaf8422beae9e33ffce133957f26a797 (patch) | |
tree | 871bdef52c69a1a436c00a3820b06c63ce8967ea /kvmd/plugins | |
parent | 5a36dec615b0c50f845455777a4cc2b1b8408478 (diff) |
ch9329: fixed mac issue (thanks @jacobb)
Diffstat (limited to 'kvmd/plugins')
-rw-r--r-- | kvmd/plugins/hid/ch9329/mouse.py | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/kvmd/plugins/hid/ch9329/mouse.py b/kvmd/plugins/hid/ch9329/mouse.py index 83c4eef3..ea21150a 100644 --- a/kvmd/plugins/hid/ch9329/mouse.py +++ b/kvmd/plugins/hid/ch9329/mouse.py @@ -58,11 +58,11 @@ class Mouse: # pylint: disable=too-many-instance-attributes self.__buttons |= code else: self.__buttons &= ~code - if not self.__absolute: - self.__to_x = (0, 0) - self.__to_y = (0, 0) self.__wheel_y = 0 - return self.__make_absolute_cmd() + if not self.__absolute: + return self.__make_relative_cmd() + else: + return self.__make_absolute_cmd() def process_move(self, to_x: int, to_y: int) -> list[int]: self.__to_x = self.__fix_absolute(to_x) @@ -79,7 +79,16 @@ class Mouse: # pylint: disable=too-many-instance-attributes _ = delta_x assert -127 <= delta_y <= 127 self.__wheel_y = (1 if delta_y > 0 else 255) - return self.__make_absolute_cmd() + if not self.__absolute: + return self.__make_relative_cmd() + else: + return self.__make_absolute_cmd() + + def process_relative(self, delta_x: int, delta_y: int) -> list[int]: + self.__delta_x = self.__fix_relative(delta_x) + self.__delta_y = self.__fix_relative(delta_y) + self.__wheel_y = 0 + return self.__make_relative_cmd() def __make_absolute_cmd(self) -> list[int]: return [ @@ -89,16 +98,14 @@ class Mouse: # pylint: disable=too-many-instance-attributes self.__to_y[1], self.__to_y[0], self.__wheel_y, ] - - def process_relative(self, delta_x: int, delta_y: int) -> list[int]: - delta_x = self.__fix_relative(delta_x) - delta_y = self.__fix_relative(delta_y) + + def __make_relative_cmd(self) -> list[int]: return [ 0, 0x05, 0x05, 0x01, self.__buttons, - delta_x, delta_y, + self.__delta_x, self.__delta_y, self.__wheel_y, - ] + ] def __fix_relative(self, value: int) -> int: assert -127 <= value <= 127 |