summaryrefslogtreecommitdiff
path: root/kvmd
diff options
context:
space:
mode:
authorDevaev Maxim <[email protected]>2020-11-05 13:01:26 +0300
committerDevaev Maxim <[email protected]>2020-11-05 13:01:26 +0300
commitae6d8258af6a800ca2f2107290114c80e326247f (patch)
tree89f32c5e8bc01260fcd29a5f96d4a86d2c0912b0 /kvmd
parentdc3259c169a4b1602ee1c7810d67aef16edd9f57 (diff)
squash relative events
Diffstat (limited to 'kvmd')
-rw-r--r--kvmd/apps/kvmd/api/hid.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/kvmd/apps/kvmd/api/hid.py b/kvmd/apps/kvmd/api/hid.py
index 82d7219d..1f51a0e4 100644
--- a/kvmd/apps/kvmd/api/hid.py
+++ b/kvmd/apps/kvmd/api/hid.py
@@ -24,7 +24,6 @@ import os
import stat
import functools
-from typing import Tuple
from typing import Dict
from typing import Set
from typing import Callable
@@ -159,10 +158,22 @@ class HidApi:
(valid_hid_mouse_delta(delta["x"]), valid_hid_mouse_delta(delta["y"]))
for delta in (raw_delta if isinstance(raw_delta, list) else [raw_delta])
]
+ squash = valid_bool(event.get("squash", False))
except Exception:
return
- for delta_xy in deltas:
- handler(*delta_xy)
+ if squash:
+ prev = (0, 0)
+ for cur in deltas:
+ if abs(prev[0] + cur[0]) > 127 or abs(prev[1] + cur[1]) > 127:
+ handler(*prev)
+ prev = cur
+ else:
+ prev = (prev[0] + cur[0], prev[1] + cur[1])
+ if prev[0] or prev[1]:
+ handler(*prev)
+ else:
+ for xy in deltas:
+ handler(*xy)
# =====