From: robertkaiser Date: Thu, 13 Mar 2003 18:08:24 +0000 (+0000) Subject: Added keyboard debouncing X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a923d15718f75b20e026835aa9924a1adacf967e;p=users%2Frw%2Farmboot.git Added keyboard debouncing --- diff --git a/drivers/keyboard.c b/drivers/keyboard.c index c7623e5..cd7feb3 100644 --- a/drivers/keyboard.c +++ b/drivers/keyboard.c @@ -81,6 +81,9 @@ struct state const unsigned char *sequenceptr; const struct keyboardmap *kbd_header; unsigned char composebuffer[2]; +#ifdef CFG_DEBOUNCE_TOUT + unsigned char lastkey; +#endif }; #define Status (pSB->status) @@ -94,6 +97,9 @@ struct state #define LookAheadValid (pSB->lookaheadvalid) #define LookAhead (pSB->lookahead) #define KbMapping (pSB->kbd_header) +#ifdef CFG_DEBOUNCE_TOUT +#define LastKey (pSB->lastkey) +#endif static struct state kbdencode_stateblock; #define GetStateBlockAddr() (&kbdencode_stateblock) @@ -331,7 +337,27 @@ nextk: if(!Kbd_tstc()) /* any key available ? */ c &= ~MkBrkMask; /* strip break bit(s) from keycode */ } else if((c = encode(pSB, pKB, c, Released, &SequencePtr)) >= 0) + { + /* + ** debouncing: some keyboards need this... + */ +#ifdef CFG_DEBOUNCE_TOUT + if(c == LastKey) + { + if(get_timer_masked() < CFG_DEBOUNCE_TOUT) + { /* skip this key */ + goto nextk; + } + + } + else + { + reset_timer_masked(); + LastKey = c; + } +#endif return(c); /* normal character: return it */ + } } if(SequencePtr) /* a sequence of characters being output ? */ {