diff options
author | 2015-01-19 20:16:10 +0000 | |
---|---|---|
committer | 2015-01-19 20:16:10 +0000 | |
commit | ca43f6aa316d38ad41038a5aa2a38a8e4edf8ced (patch) | |
tree | d5d756833340b5a5cfb3ef49497259b9ea5b6e9b | |
parent | Fix bracing in ASSERT_VP_ISLOCKED(vp) macro to not always panic() (diff) | |
download | wireguard-openbsd-ca43f6aa316d38ad41038a5aa2a38a8e4edf8ced.tar.xz wireguard-openbsd-ca43f6aa316d38ad41038a5aa2a38a8e4edf8ced.zip |
`wellspring' Apple keyboards found on Macbook Air need slightly different
processing for Fn-key chords. From William Orr <will@worrbase.com>
-rw-r--r-- | sys/dev/usb/ukbd.c | 75 |
1 files changed, 66 insertions, 9 deletions
diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c index 5420ceec78e..31cc4c9ae9c 100644 --- a/sys/dev/usb/ukbd.c +++ b/sys/dev/usb/ukbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ukbd.c,v 1.69 2014/12/11 18:39:27 mpi Exp $ */ +/* $OpenBSD: ukbd.c,v 1.70 2015/01/19 20:16:10 miod Exp $ */ /* $NetBSD: ukbd.c,v 1.85 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -180,6 +180,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_mba_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); @@ -235,19 +236,29 @@ 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) { - if (iso) + switch (uha->uaa->product) { + case USB_PRODUCT_APPLE_FOUNTAIN_ISO: + case USB_PRODUCT_APPLE_GEYSER_ISO: sc->sc_munge = ukbd_apple_iso_munge; - else + break; + case USB_PRODUCT_APPLE_WELLSPRING4A_ANSI: + case USB_PRODUCT_APPLE_WELLSPRING4A_ISO: + case USB_PRODUCT_APPLE_WELLSPRING4A_JIS: + case USB_PRODUCT_APPLE_WELLSPRING4_ANSI: + case USB_PRODUCT_APPLE_WELLSPRING4_ISO: + case USB_PRODUCT_APPLE_WELLSPRING4_JIS: + case USB_PRODUCT_APPLE_WELLSPRING_ANSI: + case USB_PRODUCT_APPLE_WELLSPRING_ISO: + case USB_PRODUCT_APPLE_WELLSPRING_JIS: + sc->sc_munge = ukbd_apple_mba_munge; + break; + default: sc->sc_munge = ukbd_apple_munge; + break; + } } } } @@ -500,6 +511,52 @@ ukbd_apple_munge(void *vsc, uint8_t *ibuf, u_int ilen) } void +ukbd_apple_mba_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_fn_trans[] = { + { 40, 73 }, /* return -> insert */ + { 42, 76 }, /* backspace -> delete */ +#ifdef notyet + { 58, 0 }, /* F1 -> screen brightness down */ + { 59, 0 }, /* F2 -> screen brightness up */ + { 60, 0 }, /* F3 */ + { 61, 0 }, /* F4 */ + { 62, 0 }, /* F5 */ + { 63, 0 }, /* F6 -> audio back */ + { 64, 0 }, /* F7 -> audio pause/play */ + { 65, 0 }, /* F8 -> audio next */ +#endif + { 66, 127 }, /* F9 -> audio mute */ + { 67, 129 }, /* F10 -> audio lower */ + { 68, 128 }, /* F11 -> audio raise */ +#ifdef notyet + { 69, 0 }, /* F12 -> eject */ +#endif + { 79, 77 }, /* right -> end */ + { 80, 74 }, /* left -> home */ + { 81, 78 }, /* down -> page down */ + { 82, 75 } /* up -> page up */ + }; + + if (!hid_get_data(ibuf, ilen, &sc->sc_apple_fn)) + return; + + spos = ibuf + kbd->sc_keycodeloc.pos / 8; + epos = spos + kbd->sc_nkeycode; + + for (pos = spos; pos != epos; pos++) { + xlat = ukbd_translate(apple_fn_trans, + nitems(apple_fn_trans), *pos); + if (xlat != 0) + *pos = xlat; + } +} + +void ukbd_apple_iso_munge(void *vsc, uint8_t *ibuf, u_int ilen) { struct ukbd_softc *sc = vsc; |