File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5009,11 +5009,14 @@ static void statement_locate(char **p)
50095009}
50105010
50115011#ifdef GFX_VIDEO
5012- /* Read a line from gfx key queue; echo to screen; handle backspace (20). */
5012+ /* Read a line from gfx key queue; echo to screen; handle backspace (20).
5013+ * Debounce: ignore same printable char within ~80ms (key-repeat suppression). */
50135014static int gfx_read_line (char * buf , int size )
50145015{
50155016 int len = 0 ;
50165017 uint8_t b ;
5018+ uint8_t last_printable = 0 ;
5019+ uint32_t last_tick = 0 ;
50175020 buf [0 ] = '\0' ;
50185021 if (size <= 0 ) return 0 ;
50195022 while (len < size - 1 ) {
@@ -5029,9 +5032,16 @@ static int gfx_read_line(char *buf, int size)
50295032 buf [len ] = '\0' ;
50305033 gfx_put_byte ((unsigned char )b );
50315034 }
5035+ last_printable = 0 ;
50325036 continue ;
50335037 }
50345038 if (b >= 32 && b <= 126 ) {
5039+ if (gfx_vs && last_printable == b && (gfx_vs -> ticks60 - last_tick ) < 5 ) {
5040+ /* Debounce: same char within ~80ms, skip (key repeat) */
5041+ continue ;
5042+ }
5043+ last_printable = b ;
5044+ last_tick = gfx_vs ? gfx_vs -> ticks60 : 0 ;
50355045 buf [len ++ ] = (char )b ;
50365046 buf [len ] = '\0' ;
50375047 gfx_put_byte ((unsigned char )b );
Original file line number Diff line number Diff line change @@ -664,8 +664,18 @@ static void keyq_push(GfxVideoState *vs, uint8_t b)
664664 uint8_t next = (uint8_t )(vs -> key_q_tail + 1 );
665665 if (next >= (uint8_t )sizeof (vs -> key_queue )) next = 0 ;
666666 if (next == vs -> key_q_head ) {
667- /* full: drop */
668- return ;
667+ return ; /* full: drop */
668+ }
669+ /* Debounce: suppress key-repeat for printable chars within ~80ms */
670+ if (b >= 32 && b <= 126 ) {
671+ static uint8_t last_b = 0 ;
672+ static uint32_t last_tick = 0 ;
673+ uint32_t t = vs -> ticks60 ;
674+ if (last_b == b && (t - last_tick ) < 5 ) {
675+ return ; /* same char too soon, skip */
676+ }
677+ last_b = b ;
678+ last_tick = t ;
669679 }
670680 vs -> key_queue [vs -> key_q_tail ] = b ;
671681 vs -> key_q_tail = next ;
You can’t perform that action at this time.
0 commit comments