From edd5351732ba9a1dde6ebb5ce25f51faa33be7a1 Mon Sep 17 00:00:00 2001 From: tychovrahe Date: Sat, 22 Jun 2024 12:01:58 +0200 Subject: [PATCH] fix(core): fix missing touch events when PRESS_DOWN is missed [no changelog] --- core/embed/trezorhal/stm32f4/touch/ft6x36.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/core/embed/trezorhal/stm32f4/touch/ft6x36.c b/core/embed/trezorhal/stm32f4/touch/ft6x36.c index 2fc78cd17e..7d9f3d1ab0 100644 --- a/core/embed/trezorhal/stm32f4/touch/ft6x36.c +++ b/core/embed/trezorhal/stm32f4/touch/ft6x36.c @@ -418,12 +418,20 @@ uint32_t touch_get_event(void) { // Finger was just lifted up event = TOUCH_END | xy; } else { - // 1. Most likely, we have missed the PRESS_DOWN event. - // Touch duration was too short (< 20ms) to be worth reporting. - // 2. Finger is still lifted up. Since we have already sent the - // TOUCH_END event => no event needed. This should not happen - // since two consecutive LIFT_UPs are not possible due to - // testing the interrupt line before reading the registers. + if (!starving && ((x != driver->last_x) || (y != driver->last_y))) { + // We have missed the PRESS_DOWN event. + // Report the start event only if the coordinates + // have changed and driver is not starving. + // This suggest that the previous touch was very short, + // or/and the driver is not called very frequently. + event = TOUCH_START | xy; + } else { + // Either the driver is starving or the coordinates + // have not changed, which would suggest that the TOUCH_END + // is repeated, so no event is needed -this should not happen + // since two consecutive LIFT_UPs are not possible due to + // testing the interrupt line before reading the registers. + } } }