]> www.infradead.org Git - users/rw/armboot.git/commitdiff
Added keyboard debouncing
authorrobertkaiser <robertkaiser>
Thu, 13 Mar 2003 18:08:24 +0000 (18:08 +0000)
committerrobertkaiser <robertkaiser>
Thu, 13 Mar 2003 18:08:24 +0000 (18:08 +0000)
drivers/keyboard.c

index c7623e58f5bcb03866199837952636f3ec89f81d..cd7feb3eb40610193b8fe438182bbc8c0dcee7a9 100644 (file)
@@ -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 ? */
        {