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
This commit is contained in:
Aidan MacDonald 2022-04-23 23:38:36 +01:00 committed by Solomon Peachy
parent 67233114f7
commit 94468f693f

View file

@ -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 */ /* switch to point mode because that's more intuitive */
enum touchscreen_mode old_mode = touchscreen_get_mode(); enum touchscreen_mode old_mode = touchscreen_get_mode();
touchscreen_set_mode(TOUCHSCREEN_POINT); touchscreen_set_mode(TOUCHSCREEN_POINT);
action_gesture_reset();
#endif #endif
/* make sure to eat any extranous keypresses */ /* 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 #ifdef HAVE_TOUCHSCREEN
case ACTION_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; if (gevent.y > yn[0].vp.height/2)
short int x, y;
btn = action_get_touchscreen_press_in_vp(&x, &y, &(yn[0].vp));
if (btn == BUTTON_REL)
{ {
if (y > yn[0].vp.height/2) if (gevent.x <= yn[0].vp.width/2)
{ result = YESNO_YES;
if (x <= yn[0].vp.width/2) else
result = YESNO_YES; result = YESNO_NO;
else
result = YESNO_NO;
}
} }
} }
break; } break;
#endif #endif
case ACTION_YESNO_ACCEPT: case ACTION_YESNO_ACCEPT:
result = YESNO_YES; result = YESNO_YES;