mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-28 16:41:52 +08:00
pikvm/pikvm#880: Fixed mouse position at edges
This commit is contained in:
@@ -590,8 +590,8 @@ class RfbClient(RfbClientStream): # pylint: disable=too-many-instance-attribute
|
||||
move = (self._width, self._height, to_x, to_y)
|
||||
if self.__mouse_move != move:
|
||||
await self._on_mouse_move_event(
|
||||
tools.remap(to_x, 0, self._width, *MouseRange.RANGE),
|
||||
tools.remap(to_y, 0, self._height, *MouseRange.RANGE),
|
||||
tools.remap(to_x, 0, self._width - 1, *MouseRange.RANGE),
|
||||
tools.remap(to_y, 0, self._height - 1, *MouseRange.RANGE),
|
||||
)
|
||||
self.__mouse_move = move
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@ from typing import TypeVar
|
||||
|
||||
# =====
|
||||
def remap(value: int, in_min: int, in_max: int, out_min: int, out_max: int) -> int:
|
||||
return int((value - in_min) * (out_max - out_min) // (in_max - in_min) + out_min)
|
||||
result = int((value - in_min) * (out_max - out_min) // ((in_max - in_min) or 1) + out_min)
|
||||
return min(max(result, out_min), out_max)
|
||||
|
||||
|
||||
# =====
|
||||
|
||||
Reference in New Issue
Block a user