On Wed, Feb 18, 2015 at 10:33:57PM -0800, William Orr wrote: > Hey, > > Any interest?
I'm interested in this. Your diff looks reasonable, so I applied it and it compiled fine, but the less and grave keys are still wrong exchanged on my MacBookAir4,2. Looks like usbdevs says I have a USB_PRODUCT_APPLE_WELLSPRING6_ISO: port 2 addr 7: full speed, power 40 mA, config 1, Apple Internal Keyboard / Trackpad(0x024d), Apple Inc.(0x05ac), rev 2.09 So I guess some more case's are required in the diff below? > Thanks, > William Orr > > On 2/4/15 9:37 AM, William Orr wrote: > > Hey, > > > > This implements some of Alexey's comments as well as munging the grave key > > for > > macbook airs. Tested on a mba with a WELLSPRING ANSI keyboard. > > > > Thanks, > > William Orr > > > > Index: sys/dev/usb/ukbd.c > > =================================================================== > > RCS file: /cvs/src/sys/dev/usb/ukbd.c,v > > retrieving revision 1.70 > > diff -u -b -w -p -r1.70 ukbd.c > > --- sys/dev/usb/ukbd.c 19 Jan 2015 20:16:10 -0000 1.70 > > +++ sys/dev/usb/ukbd.c 4 Feb 2015 05:18:47 -0000 > > @@ -182,6 +182,11 @@ void ukbd_gdium_munge(void *, uint8_t *, > > 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); > > +void ukbd_apple_iso_mba_munge(void *, uint8_t *, u_int); > > + > > +void ukbd_apple_translate(void *, uint8_t *, u_int, > > + const struct ukbd_translation *, u_int); > > + > > uint8_t ukbd_translate(const struct ukbd_translation *, size_t, > > uint8_t); > > > > int > > @@ -244,14 +249,16 @@ ukbd_attach(struct device *parent, struc > > case USB_PRODUCT_APPLE_GEYSER_ISO: > > sc->sc_munge = ukbd_apple_iso_munge; > > break; > > - case USB_PRODUCT_APPLE_WELLSPRING4A_ANSI: > > case USB_PRODUCT_APPLE_WELLSPRING4A_ISO: > > + case USB_PRODUCT_APPLE_WELLSPRING4_ISO: > > + case USB_PRODUCT_APPLE_WELLSPRING_ISO: > > + sc->sc_munge = ukbd_apple_iso_mba_munge; > > + break; > > + case USB_PRODUCT_APPLE_WELLSPRING4A_ANSI: > > 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; > > @@ -461,12 +468,28 @@ ukbd_translate(const struct ukbd_transla > > } > > > > void > > -ukbd_apple_munge(void *vsc, uint8_t *ibuf, u_int ilen) > > +ukbd_apple_translate(void *vsc, uint8_t *ibuf, u_int ilen, > > + const struct ukbd_translation* trans, u_int tlen) > > { > > struct ukbd_softc *sc = vsc; > > struct hidkbd *kbd = &sc->sc_kbd; > > uint8_t *pos, *spos, *epos, xlat; > > > > + spos = ibuf + kbd->sc_keycodeloc.pos / 8; > > + epos = spos + kbd->sc_nkeycode; > > + > > + for (pos = spos; pos != epos; pos++) { > > + xlat = ukbd_translate(trans, tlen, *pos); > > + if (xlat != 0) > > + *pos = xlat; > > + } > > +} > > + > > +void > > +ukbd_apple_munge(void *vsc, uint8_t *ibuf, u_int ilen) > > +{ > > + struct ukbd_softc *sc = vsc; > > + > > static const struct ukbd_translation apple_fn_trans[] = { > > { 40, 73 }, /* return -> insert */ > > { 42, 76 }, /* backspace -> delete */ > > @@ -499,23 +522,14 @@ ukbd_apple_munge(void *vsc, uint8_t *ibu > > 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; > > - } > > + ukbd_apple_translate(vsc, ibuf, ilen, apple_fn_trans, > > + nitems(apple_fn_trans)); > > } > > > > 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 */ > > @@ -545,40 +559,34 @@ ukbd_apple_mba_munge(void *vsc, uint8_t > > 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; > > - } > > + ukbd_apple_translate(vsc, ibuf, ilen, apple_fn_trans, > > + nitems(apple_fn_trans)); > > } > > > > 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_translate(vsc, ibuf, ilen, apple_iso_trans, > > + nitems(apple_iso_trans)); > > + ukbd_apple_munge(vsc, ibuf, ilen); > > } > > > > - ukbd_apple_munge(vsc, ibuf, ilen); > > +void > > +ukbd_apple_iso_mba_munge(void *vsc, uint8_t *ibuf, u_int ilen) > > +{ > > + static const struct ukbd_translation apple_iso_trans[] = { > > + { 53, 100 }, /* less -> grave */ > > + { 100, 53 }, > > + }; > > + > > + ukbd_apple_translate(vsc, ibuf, ilen, apple_iso_trans, > > + nitems(apple_iso_trans)); > > + ukbd_apple_mba_munge(vsc, ibuf, ilen); > > } > > > > #ifdef __loongson__ > > >