Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/hpcmips/vr detect and eliminate phantom keys.



details:   https://anonhg.NetBSD.org/src/rev/354b76a0e373
branches:  trunk
changeset: 495770:354b76a0e373
user:      shin <shin%NetBSD.org@localhost>
date:      Sat Aug 05 05:55:27 2000 +0000

description:
detect and eliminate phantom keys.

diffstat:

 sys/arch/hpcmips/vr/vrkiu.c |  40 +++++++++++++++++++++++++++++++++++++++-
 1 files changed, 39 insertions(+), 1 deletions(-)

diffs (68 lines):

diff -r 57cbf9a33809 -r 354b76a0e373 sys/arch/hpcmips/vr/vrkiu.c
--- a/sys/arch/hpcmips/vr/vrkiu.c       Sat Aug 05 01:27:12 2000 +0000
+++ b/sys/arch/hpcmips/vr/vrkiu.c       Sat Aug 05 05:55:27 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vrkiu.c,v 1.23 2000/07/22 08:26:00 takemura Exp $      */
+/*     $NetBSD: vrkiu.c,v 1.24 2000/08/05 05:55:27 shin Exp $  */
 
 /*-
  * Copyright (c) 1999 SASAKI Takesi All rights reserved.
@@ -120,6 +120,8 @@
 static int detect_key __P((struct vrkiu_chip *));
 static int vrkiu_getevent __P((struct vrkiu_chip*, u_int*, int*));
 static int vrkiu_putevent __P((struct vrkiu_chip*, u_int, int));
+static int countbits(int);
+static void eliminate_phantom_keys(struct vrkiu_chip*, unsigned short *);
 
 /* wskbd accessopts */
 int vrkiu_enable __P((void *, int));
@@ -540,6 +542,41 @@
 }
 
 static int
+countbits(d)
+       int d;
+{
+       int i, n;
+
+       for (i = 0, n = 0; i < NBBY; i++)
+               if (d & (1 << i))
+                       n++;
+       return n;
+}
+
+static void
+eliminate_phantom_keys(chip, scandata)
+       struct vrkiu_chip* chip;
+       unsigned short *scandata;
+{
+       unsigned char *p, *s;
+       int i, j, mask;
+
+       p = (unsigned char *)scandata;
+       s = (unsigned char *)chip->kc_scandata;
+
+       for (i = 0; i < KIU_NSCANLINE - 1; i++) {
+               if (countbits(p[i]) > 1) {
+                       for (j = i + 1; j < KIU_NSCANLINE; j++) {
+                               if ((mask = p[i] & p[j]) != 0) {
+                                       s[i] |= (p[i] & mask) ^ s[i];
+                                       s[j] |= (p[j] & mask) ^ s[j];
+                               }
+                       }
+               }
+       }
+}
+
+static int
 detect_key(chip)
        struct vrkiu_chip* chip;
 {
@@ -550,6 +587,7 @@
        for (i = 0; i < KIU_NSCANLINE / 2; i++) {
                scandata[i] = vrkiu_read(chip, KIUDATP + i * 2);
        }
+       eliminate_phantom_keys(chip, scandata);
 
        DPRINTF(("%s(%d): detect_key():", __FILE__, __LINE__));
 



Home | Main Index | Thread Index | Old Index