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/plugins | |
parent | 6840c514dc4b1996719787878bbf9d60b402f760 (diff) |
mouse buttons 4 and 5
Diffstat (limited to 'kvmd/plugins')
-rw-r--r-- | kvmd/plugins/hid/otg/mouse.py | 2 | ||||
-rw-r--r-- | kvmd/plugins/hid/serial.py | 20 |
2 files changed, 16 insertions, 6 deletions
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) |