Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions display_rotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,17 +356,20 @@ def touch_worker(cmd_q: "queue.Queue[str]", stop_evt: threading.Event, touch_wid
print(f"[rotator] Touch controls listening on {device} (width {device_touch_width})", flush=True)

last_x = device_touch_min + (device_touch_width // 2)
min_seen = device_touch_min
max_seen = device_touch_min + device_touch_width - 1
touch_down = False
last_tap_ts = None
last_emit = 0.0

def emit_tap(tap_x: int, now: float) -> None:
nonlocal last_tap_ts, last_emit
relative_x = tap_x - device_touch_min
width = max(2, max_seen - min_seen + 1)
relative_x = tap_x - min_seen
if relative_x < 0:
relative_x = 0
elif relative_x >= device_touch_width:
relative_x = device_touch_width - 1
elif relative_x >= width:
relative_x = width - 1

if last_tap_ts is not None and (now - last_tap_ts) <= DOUBLE_TAP_WINDOW_SECS:
if (now - last_emit) >= tap_debounce_secs:
Expand Down Expand Up @@ -395,6 +398,10 @@ def emit_tap(tap_x: int, now: float) -> None:

if ev_type == EV_ABS and ev_code in (ABS_X, ABS_MT_POSITION_X):
last_x = ev_value
if ev_value < min_seen:
min_seen = ev_value
if ev_value > max_seen:
max_seen = ev_value
elif ev_type == EV_KEY and ev_code == BTN_TOUCH:
if ev_value == 1:
touch_down = True
Expand Down