diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2012-01-29 11:04:20 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2012-01-29 11:04:20 +0000 |
commit | bd237f627208bd5e18d8a3d86b7b9eff97ab8738 (patch) | |
tree | 00bdb85cf9e8becaea24e742aff1baa38103ff19 /sys/dev/usb | |
parent | 211851c38a62b388d2227bb8425ae0831df2f380 (diff) |
Swap the keycodes of the two swapped keys of Apple ISO keyboards.
This fix the US layout on ISO keyboards and the swapped keys issue under X11.
ok miod@, shadchin@
Diffstat (limited to 'sys/dev/usb')
-rw-r--r-- | sys/dev/usb/ukbd.c | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c index f99b8246411..2a995860874 100644 --- a/sys/dev/usb/ukbd.c +++ b/sys/dev/usb/ukbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ukbd.c,v 1.56 2011/12/04 15:09:35 mpi Exp $ */ +/* $OpenBSD: ukbd.c,v 1.57 2012/01/29 11:04:19 mpi Exp $ */ /* $NetBSD: ukbd.c,v 1.85 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -185,6 +185,7 @@ struct ukbd_translation { void ukbd_gdium_munge(void *, uint8_t *, u_int); #endif void ukbd_apple_munge(void *, uint8_t *, u_int); +void ukbd_apple_iso_munge(void *, uint8_t *, u_int); uint8_t ukbd_translate(const struct ukbd_translation *, size_t, uint8_t); int @@ -231,10 +232,20 @@ ukbd_attach(struct device *parent, struct device *self, void *aux) return; if (uha->uaa->vendor == USB_VENDOR_APPLE) { + int iso = 0; + + if ((uha->uaa->product == USB_PRODUCT_APPLE_FOUNTAIN_ISO) || + (uha->uaa->product == USB_PRODUCT_APPLE_GEYSER_ISO)) + iso = 1; + if (hid_locate(desc, dlen, HID_USAGE2(HUP_APPLE, HUG_FN_KEY), uha->reportid, hid_input, &sc->sc_apple_fn, &qflags)) { - if (qflags & HIO_VARIABLE) - sc->sc_munge = ukbd_apple_munge; + if (qflags & HIO_VARIABLE) { + if (iso) + sc->sc_munge = ukbd_apple_iso_munge; + else + sc->sc_munge = ukbd_apple_munge; + } } } @@ -500,6 +511,31 @@ ukbd_apple_munge(void *vsc, uint8_t *ibuf, u_int ilen) } } +void +ukbd_apple_iso_munge(void *vsc, uint8_t *ibuf, u_int ilen) +{ + struct ukbd_softc *sc = vsc; + struct hidkbd *kbd = &sc->sc_kbd; + uint8_t *pos, *spos, *epos, xlat; + + static const struct ukbd_translation apple_iso_trans[] = { + { 53, 100 }, /* less -> grave */ + { 100, 53 }, + }; + + spos = ibuf + kbd->sc_keycodeloc.pos / 8; + epos = spos + kbd->sc_nkeycode; + + for (pos = spos; pos != epos; pos++) { + xlat = ukbd_translate(apple_iso_trans, + nitems(apple_iso_trans), *pos); + if (xlat != 0) + *pos = xlat; + } + + ukbd_apple_munge(vsc, ibuf, ilen); +} + #ifdef __loongson__ /* * Software Fn- translation for Gdium Liberty keyboard. |