From e5e9f62e313b5704d010e36ee29ca1d5990d56e3 Mon Sep 17 00:00:00 2001 From: Duncan Tourolle Date: Sun, 23 Nov 2025 14:19:29 +0100 Subject: [PATCH] Fix issue with detouch being logged as touch at 0,0 --- src/dreader_hal/touch/ft5xx6.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/dreader_hal/touch/ft5xx6.py b/src/dreader_hal/touch/ft5xx6.py index bd2741c..b5755a6 100644 --- a/src/dreader_hal/touch/ft5xx6.py +++ b/src/dreader_hal/touch/ft5xx6.py @@ -76,6 +76,7 @@ class FT5xx6TouchDriver: self._initialized = False self._last_num_touches = 0 self._tracking_touch = False + self._last_touch_pos = (0, 0) # Track last known touch position for drag_end async def initialize(self) -> None: """ @@ -206,6 +207,7 @@ class FT5xx6TouchDriver: # Handle single-touch gestures with our gesture detector if num_touches == 1: x, y = record.t1x, record.t1y + self._last_touch_pos = (x, y) # Track position for drag_end # Touch down if self._last_num_touches == 0: @@ -233,10 +235,10 @@ class FT5xx6TouchDriver: elif num_touches == 0 and self._last_num_touches > 0: # Get last known position if self._last_num_touches == 1: - # Single finger up + # Single finger up - use last tracked position gesture = self.gesture_detector.on_touch_up( - self.gesture_detector.current_pos[0] if self.gesture_detector.current_pos else 0, - self.gesture_detector.current_pos[1] if self.gesture_detector.current_pos else 0, + self._last_touch_pos[0], + self._last_touch_pos[1], finger=0 ) self._tracking_touch = False