diff --git a/apps/action.c b/apps/action.c index d657deb7fd..4566c82288 100644 --- a/apps/action.c +++ b/apps/action.c @@ -1204,6 +1204,7 @@ void action_wait_for_release(void) { if (!(action_last.button & BUTTON_REL)) action_last.wait_for_release = true; + button_clear_pressed(); } int get_action(int context, int timeout) diff --git a/apps/gui/yesno.c b/apps/gui/yesno.c index e3b22115df..7232b315ec 100644 --- a/apps/gui/yesno.c +++ b/apps/gui/yesno.c @@ -253,7 +253,6 @@ enum yesno_res gui_syncyesno_run_w_tmo(int ticks, enum yesno_res tmo_default_res /* make sure to eat any extranous keypresses */ action_wait_for_release(); - button_clear_queue(); /* hook into UI update events to avoid the dialog disappearing * in case the skin decides to do a full refresh */ diff --git a/firmware/drivers/button_queue.c b/firmware/drivers/button_queue.c index 85ad251443..9767a1a08b 100644 --- a/firmware/drivers/button_queue.c +++ b/firmware/drivers/button_queue.c @@ -185,6 +185,20 @@ void button_clear_queue(void) queue_clear(&button_queue); } +/* clears anything but release and sysevents */ +void button_clear_pressed(void) +{ + long button; + for (int count = queue_count(&button_queue); count > 0; count--) + { + button = button_get(false); + if (button & (BUTTON_REL | SYS_EVENT)) + { + button_queue_post(button, button_data); + } + } +} + long button_get_w_tmo(int ticks) { struct queue_event ev; diff --git a/firmware/export/button.h b/firmware/export/button.h index d45b9844bc..e3c3126a1b 100644 --- a/firmware/export/button.h +++ b/firmware/export/button.h @@ -71,6 +71,7 @@ int button_queue_count(void); bool button_queue_empty(void); bool button_queue_full(void); void button_clear_queue(void); +void button_clear_pressed(void); long button_get(bool block); long button_get_w_tmo(int ticks); intptr_t button_get_data(void);