diff options
| author | tslight <tslight@pm.com> | 2026-03-29 13:16:57 +0000 |
|---|---|---|
| committer | Vladimir Kondratyev <wulf@FreeBSD.org> | 2026-03-29 13:16:57 +0000 |
| commit | 103325323c7daf9fe6c9a6c71aa5c90974c9dff4 (patch) | |
| tree | 6fed4ddb324cf984bcdf24b904d8195724f53acc /sys/dev/hid | |
| parent | 40f55eada59250dd5d9580ad3c87a36ae9d6b4a9 (diff) | |
Diffstat (limited to 'sys/dev/hid')
| -rw-r--r-- | sys/dev/hid/hkbd.c | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/sys/dev/hid/hkbd.c b/sys/dev/hid/hkbd.c index a91a01a385e3..9ab02e940089 100644 --- a/sys/dev/hid/hkbd.c +++ b/sys/dev/hid/hkbd.c @@ -73,6 +73,8 @@ #include <dev/hid/hidquirk.h> #include <dev/hid/hidrdesc.h> +#include "usbdevs.h" + #ifdef EVDEV_SUPPORT #include <dev/evdev/input.h> #include <dev/evdev/evdev.h> @@ -828,40 +830,43 @@ hkbd_parse_hid(struct hkbd_softc *sc, const uint8_t *ptr, uint32_t len, sc->sc_kbd_size = hid_report_size_max(ptr, len, hid_input, &sc->sc_kbd_id); + const struct hid_device_info *hw = hid_get_device_info(sc->sc_dev); + /* investigate if this is an Apple Keyboard */ - if (hidbus_locate(ptr, len, - HID_USAGE2(HUP_CONSUMER, HUG_APPLE_EJECT), - hid_input, tlc_index, 0, &sc->sc_loc_apple_eject, &flags, - &sc->sc_id_apple_eject, NULL)) { - if (flags & HIO_VARIABLE) - sc->sc_flags |= HKBD_FLAG_APPLE_EJECT | - HKBD_FLAG_APPLE_SWAP; - DPRINTFN(1, "Found Apple eject-key\n"); - } - /* - * check the same vendor pages that linux does to find the one apple - * uses for the function key. - */ - static const uint16_t apple_pages[] = { - HUP_APPLE, /* HID_UP_CUSTOM in linux */ - HUP_MICROSOFT, /* HID_UP_MSVENDOR in linux */ - HUP_HP, /* HID_UP_HPVENDOR2 in linux */ - 0xFFFF /* Original FreeBSD check (Remove?) */ - }; - for (int i = 0; i < (int)nitems(apple_pages); i++) { + if (hw->idVendor == USB_VENDOR_APPLE) { /* belt & braces! */ if (hidbus_locate(ptr, len, - HID_USAGE2(apple_pages[i], 0x0003), - hid_input, tlc_index, 0, - &sc->sc_loc_apple_fn, &flags, - &sc->sc_id_apple_fn, NULL)) { + HID_USAGE2(HUP_CONSUMER, HUG_APPLE_EJECT), + hid_input, tlc_index, 0, &sc->sc_loc_apple_eject, &flags, + &sc->sc_id_apple_eject, NULL)) { if (flags & HIO_VARIABLE) - sc->sc_flags |= HKBD_FLAG_APPLE_FN; - DPRINTFN(1, "Found Apple FN-key on page 0x%04x\n", - apple_pages[i]); - break; + sc->sc_flags |= HKBD_FLAG_APPLE_EJECT | + HKBD_FLAG_APPLE_SWAP; + DPRINTFN(1, "Found Apple eject-key\n"); + } + /* + * check the same vendor pages that linux does to find the one + * apple uses for the function key. + */ + static const uint16_t apple_pages[] = { + HUP_APPLE, /* HID_UP_CUSTOM in linux */ + HUP_MICROSOFT, /* HID_UP_MSVENDOR in linux */ + HUP_HP, /* HID_UP_HPVENDOR2 in linux */ + 0xFFFF /* Original FreeBSD check (Remove?) */ + }; + for (int i = 0; i < (int)nitems(apple_pages); i++) { + if (hidbus_locate(ptr, len, + HID_USAGE2(apple_pages[i], 0x0003), + hid_input, tlc_index, 0, &sc->sc_loc_apple_fn, &flags, + &sc->sc_id_apple_fn, NULL)) { + if (flags & HIO_VARIABLE) + sc->sc_flags |= HKBD_FLAG_APPLE_FN; + DPRINTFN(1, "Found Apple FN-key on page 0x%04x\n", + apple_pages[i]); + break; + } } } - + /* figure out event buffer */ if (hidbus_locate(ptr, len, HID_USAGE2(HUP_KEYBOARD, 0x00), |
