summaryrefslogtreecommitdiff
path: root/sys/dev/usb/ukbd.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/usb/ukbd.c')
-rw-r--r--sys/dev/usb/ukbd.c168
1 files changed, 9 insertions, 159 deletions
diff --git a/sys/dev/usb/ukbd.c b/sys/dev/usb/ukbd.c
index 5214fdda16d..4847b1d95ca 100644
--- a/sys/dev/usb/ukbd.c
+++ b/sys/dev/usb/ukbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ukbd.c,v 1.86 2022/01/09 05:43:00 jsg Exp $ */
+/* $OpenBSD: ukbd.c,v 1.87 2022/09/16 16:30:10 robert Exp $ */
/* $NetBSD: ukbd.c,v 1.85 2003/03/11 16:44:00 augustss Exp $ */
/*
@@ -132,7 +132,6 @@ struct ukbd_softc {
struct hidkbd sc_kbd;
int sc_spl;
struct hid_location sc_apple_fn;
- void (*sc_munge)(void *, uint8_t *, u_int);
#ifdef DDB
struct timeout sc_ddb; /* for entering DDB */
@@ -178,21 +177,9 @@ const struct cfattach ukbd_ca = {
sizeof(struct ukbd_softc), ukbd_match, ukbd_attach, ukbd_detach
};
-struct ukbd_translation {
- uint8_t original;
- uint8_t translation;
-};
-
#ifdef __loongson__
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);
-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
ukbd_match(struct device *parent, void *match, void *aux)
@@ -263,12 +250,12 @@ ukbd_attach(struct device *parent, struct device *self, void *aux)
case USB_PRODUCT_APPLE_GEYSER3_ISO:
case USB_PRODUCT_APPLE_WELLSPRING6_ISO:
case USB_PRODUCT_APPLE_WELLSPRING8_ISO:
- sc->sc_munge = ukbd_apple_iso_munge;
+ kbd->sc_munge = hidkbd_apple_iso_munge;
break;
case USB_PRODUCT_APPLE_WELLSPRING_ISO:
case USB_PRODUCT_APPLE_WELLSPRING4_ISO:
case USB_PRODUCT_APPLE_WELLSPRING4A_ISO:
- sc->sc_munge = ukbd_apple_iso_mba_munge;
+ kbd->sc_munge = hidkbd_apple_iso_mba_munge;
break;
case USB_PRODUCT_APPLE_WELLSPRING_ANSI:
case USB_PRODUCT_APPLE_WELLSPRING_JIS:
@@ -276,10 +263,10 @@ ukbd_attach(struct device *parent, struct device *self, void *aux)
case USB_PRODUCT_APPLE_WELLSPRING4_JIS:
case USB_PRODUCT_APPLE_WELLSPRING4A_ANSI:
case USB_PRODUCT_APPLE_WELLSPRING4A_JIS:
- sc->sc_munge = ukbd_apple_mba_munge;
+ kbd->sc_munge = hidkbd_apple_mba_munge;
break;
default:
- sc->sc_munge = ukbd_apple_munge;
+ kbd->sc_munge = hidkbd_apple_munge;
break;
}
}
@@ -315,7 +302,7 @@ ukbd_attach(struct device *parent, struct device *self, void *aux)
#ifdef __loongson__
if (uha->uaa->vendor == USB_VENDOR_CYPRESS &&
uha->uaa->product == USB_PRODUCT_CYPRESS_LPRDK)
- sc->sc_munge = ukbd_gdium_munge;
+ kbd->sc_munge = ukbd_gdium_munge;
#endif
if (kbd->sc_console_keyboard) {
@@ -362,11 +349,8 @@ ukbd_intr(struct uhidev *addr, void *ibuf, u_int len)
struct ukbd_softc *sc = (struct ukbd_softc *)addr;
struct hidkbd *kbd = &sc->sc_kbd;
- if (kbd->sc_enabled != 0) {
- if (sc->sc_munge != NULL)
- (*sc->sc_munge)(sc, (uint8_t *)ibuf, len);
+ if (kbd->sc_enabled != 0)
hidkbd_input(kbd, (uint8_t *)ibuf, len);
- }
}
int
@@ -515,140 +499,6 @@ ukbd_cnattach(void)
return (0);
}
-uint8_t
-ukbd_translate(const struct ukbd_translation *table, size_t tsize,
- uint8_t keycode)
-{
- for (; tsize != 0; table++, tsize--)
- if (table->original == keycode)
- return table->translation;
- return 0;
-}
-
-void
-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 */
-#ifdef notyet
- { 58, 0 }, /* F1 -> screen brightness down */
- { 59, 0 }, /* F2 -> screen brightness up */
- { 60, 0 }, /* F3 */
- { 61, 0 }, /* F4 */
- { 62, 0 }, /* F5 -> keyboard backlight down */
- { 63, 0 }, /* F6 -> keyboard backlight up */
- { 64, 0 }, /* F7 -> audio back */
- { 65, 0 }, /* F8 -> audio pause/play */
- { 66, 0 }, /* F9 -> audio next */
-#endif
-#ifdef __macppc__
- { 58, 233 }, /* F1 -> screen brightness down */
- { 59, 232 }, /* F2 -> screen brightness up */
- { 60, 127 }, /* F3 -> audio mute */
- { 61, 129 }, /* F4 -> audio lower */
- { 62, 128 }, /* F5 -> audio raise */
-#else
- { 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;
-
- 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;
-
- 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;
-
- 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)
-{
- 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_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__
/*
* Software Fn- translation for Gdium Liberty keyboard.
@@ -662,7 +512,7 @@ ukbd_gdium_munge(void *vsc, uint8_t *ibuf, u_int ilen)
uint8_t *pos, *spos, *epos, xlat;
int fn;
- static const struct ukbd_translation gdium_fn_trans[] = {
+ static const struct hidkbd_translation gdium_fn_trans[] = {
#ifdef notyet
{ 58, 0 }, /* F1 -> toggle camera */
{ 59, 0 }, /* F2 -> toggle wireless */
@@ -707,7 +557,7 @@ ukbd_gdium_munge(void *vsc, uint8_t *ibuf, u_int ilen)
if (fn != 0)
for (pos = spos; pos != epos; pos++) {
- xlat = ukbd_translate(gdium_fn_trans,
+ xlat = hidkbd_translate(gdium_fn_trans,
nitems(gdium_fn_trans), *pos);
if (xlat != 0)
*pos = xlat;