From 86f01f0b36dfe01e3de4706318eff7890090b3b3 Mon Sep 17 00:00:00 2001 From: PartialVolume Date: Fri, 24 Apr 2020 22:50:57 +0100 Subject: [PATCH] Fix nwipes behaviour with repeated S key Prior to this patch if S key held down keyboard would be unresponsive for x seconds. Where x = number of S keystrokes x 3. Now keys are delayed for no longer than 3 seconds while warning message is displayed, long enough for the user to read the warning message. --- src/gui.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gui.c b/src/gui.c index 608f0dd..c83c9f0 100644 --- a/src/gui.c +++ b/src/gui.c @@ -999,7 +999,17 @@ void nwipe_gui_select( int count, nwipe_context_t** c ) nwipe_gui_amend_footer_window( main_window_footer ); doupdate(); - /* Remove the S from keystroke, which will keep us in the drive selection menu */ + /* Remove any repeated S key strokes, without this the gui would hang + * for a period of time, i.e sleep above x number of repeated 's' keystrokes + * which could run into minutes */ + do + { + timeout( 250 ); // block getch() for 250ms. + keystroke = getch(); // Get user input. + timeout( -1 ); // Switch back to blocking mode. + } while( keystroke == 'S' ); + + /* Remove the S from keystroke, which allows us to stay within the selection menu loop */ keystroke = 0; } @@ -1021,7 +1031,7 @@ void nwipe_gui_select( int count, nwipe_context_t** c ) nwipe_gui_amend_footer_window( main_window_footer ); doupdate(); - /* if user insists on holding the s key down, without this the gui would hang + /* Remove any repeated s key strokes, without this the gui would hang * for a period of time, i.e sleep above x number of repeated 's' keystrokes * which could run into minutes */ do