summaryrefslogtreecommitdiff
path: root/kvmd/plugins/hid/serial.py
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-08-18 10:45:15 +0300
committerDevaev Maxim <[email protected]>2020-08-18 10:45:15 +0300
commit28cc3fe99a3e90213f1f01286b5ec55f4f06224c (patch)
treebe3751fb65bc53f2bcf9158e155eebe27208abe6 /kvmd/plugins/hid/serial.py
parent6840c514dc4b1996719787878bbf9d60b402f760 (diff)
mouse buttons 4 and 5
Diffstat (limited to 'kvmd/plugins/hid/serial.py')
-rw-r--r--kvmd/plugins/hid/serial.py20
1 files changed, 14 insertions, 6 deletions
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)