From 94468f693fbc825020c17d1b8b59a2926b570112 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Sat, 23 Apr 2022 23:38:36 +0100 Subject: [PATCH] touchscreen: Port yes/no screen to gesture API Use the gesture API in the yes/no screen to suppress bogus touches and generally improve reliability. Change-Id: I44adf95255f07d81188fd249dc00a91519ca7b99 --- apps/gui/yesno.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/apps/gui/yesno.c b/apps/gui/yesno.c index 0487a100d8..c1e722da10 100644 --- a/apps/gui/yesno.c +++ b/apps/gui/yesno.c @@ -249,6 +249,7 @@ enum yesno_res gui_syncyesno_run_w_tmo(int ticks, enum yesno_res tmo_default_res /* switch to point mode because that's more intuitive */ enum touchscreen_mode old_mode = touchscreen_get_mode(); touchscreen_set_mode(TOUCHSCREEN_POINT); + action_gesture_reset(); #endif /* make sure to eat any extranous keypresses */ @@ -277,22 +278,20 @@ enum yesno_res gui_syncyesno_run_w_tmo(int ticks, enum yesno_res tmo_default_res { #ifdef HAVE_TOUCHSCREEN case ACTION_TOUCHSCREEN: + { + struct gesture_event gevent; + if (action_gesture_get_event_in_vp(&gevent, &yn[0].vp) && + gevent.id == GESTURE_TAP) { - int btn; - short int x, y; - btn = action_get_touchscreen_press_in_vp(&x, &y, &(yn[0].vp)); - if (btn == BUTTON_REL) + if (gevent.y > yn[0].vp.height/2) { - if (y > yn[0].vp.height/2) - { - if (x <= yn[0].vp.width/2) - result = YESNO_YES; - else - result = YESNO_NO; - } + if (gevent.x <= yn[0].vp.width/2) + result = YESNO_YES; + else + result = YESNO_NO; } } - break; + } break; #endif case ACTION_YESNO_ACCEPT: result = YESNO_YES;