Hey, any interest?
On 12/12/2014 08:29 PM, William Orr wrote:
> Hey,
>
> On some macbook airs, the function keys have different functionality when the
> Fn key is pressed. I've added an additional munge function to handle these
> particular cases.
>
> Thanks,
> William Orr
>
> Index: sys/dev/usb/ukbd.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/usb/ukbd.c,v
> retrieving revision 1.69
> diff -u -b -w -p -r1.69 ukbd.c
> --- sys/dev/usb/ukbd.c 11 Dec 2014 18:39:27 -0000 1.69
> +++ sys/dev/usb/ukbd.c 13 Dec 2014 04:18:55 -0000
> @@ -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);
>
> @@ -244,13 +245,29 @@ ukbd_attach(struct device *parent, struc
> 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) {
> + /* Older Macbook Air's have different fn key
> layouts */
> if (iso)
> sc->sc_munge = ukbd_apple_iso_munge;
> - else
> + else {
> + switch (uha->uaa->product) {
> + 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;
> }
> }
> }
> + }
> + }
>
> if (uha->uaa->vendor == USB_VENDOR_TOPRE &&
> uha->uaa->product == USB_PRODUCT_TOPRE_HHKB) {
> @@ -478,6 +495,52 @@ ukbd_apple_munge(void *vsc, uint8_t *ibu
> { 67, 127 }, /* F10 -> audio mute */
> { 68, 129 }, /* F11 -> audio lower */
> { 69, 128 }, /* F12 -> audio raise */
> +#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_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 */
>
signature.asc
Description: OpenPGP digital signature
