ADB keyboards and kbd

Michael <[email protected]>
Newsgroups gmane.comp.xfree86.devel
Message-ID <20050820114421.02be322d@inishowen>
Hello,

the attached patch fixes a problem with 'kbd' and ADB keyboards.
Apparently these keyboards send a 0 after each caps-lock, but since 0 is
used for 'a' we can't just drop it. This patch adds a remap function
which takes care of that - without it you'd get a spurious 'a' or 'A'
after each caps-lock.
Tested on NetBSD/macppc.

have fun
Michael
bsdadbkbd.patch (application/octet-stream, 1.8 KB)
Index: bsd_KbdMap.c
===================================================================
RCS file: /cvsroot/xsrc/xfree/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_KbdMap.c,v
retrieving revision 1.9
diff -u -w -p -r1.9 bsd_KbdMap.c
--- bsd_KbdMap.c	22 Jul 2005 20:28:09 -0000	1.9
+++ bsd_KbdMap.c	20 Aug 2005 15:16:23 -0000
@@ -24,6 +24,8 @@
 #include "xf86Keymap.h"
 #include "bsd_kbd.h"
 
+Bool ADBScanCode(InputInfoPtr, int *);
+
 #if (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)) && defined(GIO_KEYMAP)
 #define KD_GET_ENTRY(i,n) \
   eascii_to_x[((keymap.key[i].spcl << (n+1)) & 0x100) + keymap.key[i].map[n]]
@@ -1058,7 +1065,7 @@ KbdGetMapping (InputInfoPtr pInfo, KeySy
                     break;
 #ifdef WSKBD_TYPE_ADB	
 	       case WSKBD_TYPE_ADB:
-                    pKbd->scancodeMap = &wsAdb; 
+	            pKbd->RemapScanCode = ADBScanCode;
                     break;
 #endif
 #ifdef WSKBD_TYPE_SUN
@@ -1078,3 +1085,29 @@ KbdGetMapping (InputInfoPtr pInfo, KeySy
   }
   return;
 }
+
+Bool
+ADBScanCode(InputInfoPtr pInfo, int *scanCode)
+{
+    KbdDevPtr pKbd = (KbdDevPtr) pInfo->private;
+
+    /*
+     * we abuse pKbd->scanPrefix to record each scancode so we can weed out the
+     * 0 following every caps-lock which would otherwise result in spurious 'A's
+     */
+    if (*scanCode == 0) {
+        /* drop this event when the previous one was caps-lock */
+        if (pKbd->scanPrefix == 57) {
+	    pKbd->scanPrefix = 0;
+	    return TRUE;	/* let the input handler stop right here */
+	}
+    }
+    
+    /* record the scancode */
+    pKbd->scanPrefix = (*scanCode) & 0x7f;
+    
+    /* do the normal remapping */
+    if (*scanCode >= wsAdb.begin && *scanCode < wsAdb.end)
+        *scanCode = wsAdb.map[*scanCode - wsAdb.begin];
+    return FALSE;	/* continue normal processing */
+}
signature.asc (application/pgp-signature, 478 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (NetBSD)

iQEVAwUBQwdP1cpnzkX8Yg2nAQKu3QgAnQacrEFFBq68RickSAyl3k773+icFJaC
R7/zzbFw7mztEZ17DXB1tRSPA4itUGgLKenI2ZBu6Ep3XCaIeNMPQqcRn1OsLQYT
L72e3DaVAfhspxnVBcClUrH8vypEe/IlPln/Tc5YWd/MRdYBSjmL2mGWKEMb9XbP
XYP4s7Pt2KXzt8iGqKorLZhKYjIeyKwmDwi4QrBBrnTFffPw2lTX8ciu7cnojzlR
mD4BFZi5QbvtLaqDV/p5l5+KqVacL5YFWCU57Sx5/ITAuf4VirO5cM/IEEBLIVsS
Oa4DlNw8ln/dYi9wJjqAZ2rH8aeMtcutDcZCR9zlJ3zMZqeVsv5XdQ==
=J8kY
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.