diff options
author | Devaev Maxim <[email protected]> | 2020-08-18 10:45:15 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-08-18 10:45:15 +0300 |
commit | 28cc3fe99a3e90213f1f01286b5ec55f4f06224c (patch) | |
tree | be3751fb65bc53f2bcf9158e155eebe27208abe6 /kvmd | |
parent | 6840c514dc4b1996719787878bbf9d60b402f760 (diff) |
mouse buttons 4 and 5
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/apps/vnc/rfb/__init__.py | 2 | ||||
-rw-r--r-- | kvmd/apps/vnc/server.py | 2 | ||||
-rw-r--r-- | kvmd/plugins/hid/otg/mouse.py | 2 | ||||
-rw-r--r-- | kvmd/plugins/hid/serial.py | 20 | ||||
-rw-r--r-- | kvmd/validators/kvm.py | 2 |
5 files changed, 20 insertions, 8 deletions
diff --git a/kvmd/apps/vnc/rfb/__init__.py b/kvmd/apps/vnc/rfb/__init__.py index f10d7da2..27aa41ad 100644 --- a/kvmd/apps/vnc/rfb/__init__.py +++ b/kvmd/apps/vnc/rfb/__init__.py @@ -400,6 +400,8 @@ class RfbClient(RfbClientStream): # pylint: disable=too-many-instance-attribute "left": bool(buttons & 0x1), "right": bool(buttons & 0x4), "middle": bool(buttons & 0x2), + "up": bool(buttons & 0x8), # Back + "down": bool(buttons & 0x10), # Forward }, wheel={ "x": (-4 if buttons & 0x40 else (4 if buttons & 0x20 else 0)), diff --git a/kvmd/apps/vnc/server.py b/kvmd/apps/vnc/server.py index 2ab03f36..cb769481 100644 --- a/kvmd/apps/vnc/server.py +++ b/kvmd/apps/vnc/server.py @@ -114,7 +114,7 @@ class _Client(RfbClient): # pylint: disable=too-many-instance-attributes # Эти состояния шарить не обязательно - бекенд исключает дублирующиеся события. # Все это нужно только чтобы не посылать лишние жсоны в сокет KVMD - self.__mouse_buttons: Dict[str, Optional[bool]] = {"left": None, "right": None, "middle": None} + self.__mouse_buttons: Dict[str, Optional[bool]] = dict.fromkeys(["left", "right", "middle", "up", "down"], None) self.__mouse_move = {"x": -1, "y": -1} self.__lock = asyncio.Lock() diff --git a/kvmd/plugins/hid/otg/mouse.py b/kvmd/plugins/hid/otg/mouse.py index 3c41eb40..adb2469f 100644 --- a/kvmd/plugins/hid/otg/mouse.py +++ b/kvmd/plugins/hid/otg/mouse.py @@ -91,6 +91,8 @@ class MouseProcess(BaseDeviceProcess): "left": 0x1, "right": 0x2, "middle": 0x4, + "up": 0x8, # Back + "down": 0x10, # Forward }[button] self._queue_event(_ButtonEvent(code, state)) diff --git a/kvmd/plugins/hid/serial.py b/kvmd/plugins/hid/serial.py index e9b65479..752870d7 100644 --- a/kvmd/plugins/hid/serial.py +++ b/kvmd/plugins/hid/serial.py @@ -108,17 +108,25 @@ class _MouseButtonEvent(_BaseEvent): state: bool def __post_init__(self) -> None: - assert self.name in ["left", "right", "middle"] + assert self.name in ["left", "right", "middle", "up", "down"] def make_command(self) -> bytes: - (code, state_pressed) = { - "left": (0b10000000, 0b00001000), - "right": (0b01000000, 0b00000100), - "middle": (0b00100000, 0b00000010), + (code, state_pressed, is_main) = { + "left": (0b10000000, 0b00001000, True), + "right": (0b01000000, 0b00000100, True), + "middle": (0b00100000, 0b00000010, True), + "up": (0b10000000, 0b00001000, False), # Back + "down": (0b01000000, 0b00000100, False), # Forward }[self.name] if self.state: code |= state_pressed - return struct.pack(">BBxxx", 0x13, code) + if is_main: + main_code = code + extra_code = 0 + else: + main_code = 0 + extra_code = code + return struct.pack(">BBBxx", 0x13, main_code, extra_code) @dataclasses.dataclass(frozen=True) diff --git a/kvmd/validators/kvm.py b/kvmd/validators/kvm.py index b32a785e..140c282c 100644 --- a/kvmd/validators/kvm.py +++ b/kvmd/validators/kvm.py @@ -80,7 +80,7 @@ def valid_hid_mouse_move(arg: Any) -> int: def valid_hid_mouse_button(arg: Any) -> str: - return check_string_in_list(arg, "HID mouse button", ["left", "right", "middle"]) + return check_string_in_list(arg, "HID mouse button", ["left", "right", "middle", "up", "down"]) def valid_hid_mouse_wheel(arg: Any) -> int: |