Source-Changes-HG archive

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

[src/netbsd-1-5]: src/sys/arch/hpcmips/vr pull up revision 1.24 (Approved by ...



details:   https://anonhg.NetBSD.org/src/rev/4248062f5f1d
branches:  netbsd-1-5
changeset: 489018:4248062f5f1d
user:      shin <shin%NetBSD.org@localhost>
date:      Thu Aug 10 00:57:45 2000 +0000

description:
pull up revision 1.24 (Approved by releng-1-5):

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 c1634a4f8e69 -r 4248062f5f1d sys/arch/hpcmips/vr/vrkiu.c
--- a/sys/arch/hpcmips/vr/vrkiu.c       Thu Aug 10 00:56:25 2000 +0000
+++ b/sys/arch/hpcmips/vr/vrkiu.c       Thu Aug 10 00:57:45 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vrkiu.c,v 1.22.2.1 2000/08/06 04:27:36 takemura Exp $  */
+/*     $NetBSD: vrkiu.c,v 1.22.2.2 2000/08/10 00:57:45 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