Subject: Re: us.swapctrlcaps keymap
To: None <itojun@iijlab.net>
From: Nathan J. Williams <nathanw@wasabisystems.com>
List: port-macppc
Date: 06/14/2002 13:12:29
itojun@iijlab.net writes:
> >The hardware generates one event for each cycle of the LOCK key (press +
> >release => down; press + release => up). It's the ADB code that converts
> >each of the down and up events into a pair of press/release events (so
> >that console drivers and X servers don't get totally confused). The
> >problem remains though: the nearest you can get to mapping CTRL onto LOCK
> >is a CTRL key that locks (just like the LOCK behaviour). Not very useful.
> >
> >Sorry for the (my) confusion.
>
> thanks for explanation, i've put it into port-macppc FAQ.
> guess i need a soldering iron...
Actually, I abused the akbd code into not being a locking CTRL key,
but being a CTRL key that still lights up (and occasionlly
locks.. some multi-keypress bug, I think).
Index: akbd.c
===================================================================
RCS file: /cvsroot/syssrc/sys/arch/macppc/dev/akbd.c,v
retrieving revision 1.23
diff -c -r1.23 akbd.c
*** akbd.c 2002/03/17 19:40:44 1.23
--- akbd.c 2002/06/14 17:11:16
***************
*** 498,521 ****
--- 498,549 ----
}
}
+ #define FIXCAPS
+
int
kbd_intr(arg)
void *arg;
{
adb_event_t *event = arg;
int key;
+ #ifdef FIXCAPS
+ static int shift;
+ #endif
struct akbd_softc *sc = akbd_cd.cd_devs[0];
key = event->u.k.key;
+ #ifdef FIXCAPS
+ /* Caps lock is weird. The key sequence generated is:
+ * press: down(57) [57] (LED turns on)
+ * release: up(127) [255]
+ * press: up(127) [255]
+ * release: up(57) [185] (LED turns off)
+ */
+ if ((key == 57) || (key == 185))
+ shift = 0;
+
+ if (key == 255) {
+ if (shift == 0) {
+ key = 185;
+ shift = 1;
+ } else {
+ key = 57;
+ shift = 0;
+ }
+ }
+
+ #endif
switch (key) {
+ #ifndef FIXCAPS
case 57: /* Caps Lock pressed */
case 185: /* Caps Lock released */
key = ADBK_KEYDOWN(ADBK_KEYVAL(key));
kbd_passup(sc,key);
key = ADBK_KEYUP(ADBK_KEYVAL(key));
break;
+ #endif
case 245:
if (pcmcia_soft_eject)
pm_eject_pcmcia(0);