hkbd(4): be more cautious & explicit about Apple vendor checking
Apply the changes to ukbd(4) as well. Signed-off-by: tslight <tslight@pm.com> Reviewed by: wulf MFC after: 1 month Pull Request: https://github.com/freebsd/freebsd-src/pull/1998
This commit is contained in:
committed by
Vladimir Kondratyev
parent
40f55eada5
commit
103325323c
+9
-4
@@ -73,6 +73,8 @@
|
|||||||
#include <dev/hid/hidquirk.h>
|
#include <dev/hid/hidquirk.h>
|
||||||
#include <dev/hid/hidrdesc.h>
|
#include <dev/hid/hidrdesc.h>
|
||||||
|
|
||||||
|
#include "usbdevs.h"
|
||||||
|
|
||||||
#ifdef EVDEV_SUPPORT
|
#ifdef EVDEV_SUPPORT
|
||||||
#include <dev/evdev/input.h>
|
#include <dev/evdev/input.h>
|
||||||
#include <dev/evdev/evdev.h>
|
#include <dev/evdev/evdev.h>
|
||||||
@@ -828,7 +830,10 @@ hkbd_parse_hid(struct hkbd_softc *sc, const uint8_t *ptr, uint32_t len,
|
|||||||
sc->sc_kbd_size = hid_report_size_max(ptr, len,
|
sc->sc_kbd_size = hid_report_size_max(ptr, len,
|
||||||
hid_input, &sc->sc_kbd_id);
|
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 */
|
/* investigate if this is an Apple Keyboard */
|
||||||
|
if (hw->idVendor == USB_VENDOR_APPLE) { /* belt & braces! */
|
||||||
if (hidbus_locate(ptr, len,
|
if (hidbus_locate(ptr, len,
|
||||||
HID_USAGE2(HUP_CONSUMER, HUG_APPLE_EJECT),
|
HID_USAGE2(HUP_CONSUMER, HUG_APPLE_EJECT),
|
||||||
hid_input, tlc_index, 0, &sc->sc_loc_apple_eject, &flags,
|
hid_input, tlc_index, 0, &sc->sc_loc_apple_eject, &flags,
|
||||||
@@ -839,8 +844,8 @@ hkbd_parse_hid(struct hkbd_softc *sc, const uint8_t *ptr, uint32_t len,
|
|||||||
DPRINTFN(1, "Found Apple eject-key\n");
|
DPRINTFN(1, "Found Apple eject-key\n");
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* check the same vendor pages that linux does to find the one apple
|
* check the same vendor pages that linux does to find the one
|
||||||
* uses for the function key.
|
* apple uses for the function key.
|
||||||
*/
|
*/
|
||||||
static const uint16_t apple_pages[] = {
|
static const uint16_t apple_pages[] = {
|
||||||
HUP_APPLE, /* HID_UP_CUSTOM in linux */
|
HUP_APPLE, /* HID_UP_CUSTOM in linux */
|
||||||
@@ -851,8 +856,7 @@ hkbd_parse_hid(struct hkbd_softc *sc, const uint8_t *ptr, uint32_t len,
|
|||||||
for (int i = 0; i < (int)nitems(apple_pages); i++) {
|
for (int i = 0; i < (int)nitems(apple_pages); i++) {
|
||||||
if (hidbus_locate(ptr, len,
|
if (hidbus_locate(ptr, len,
|
||||||
HID_USAGE2(apple_pages[i], 0x0003),
|
HID_USAGE2(apple_pages[i], 0x0003),
|
||||||
hid_input, tlc_index, 0,
|
hid_input, tlc_index, 0, &sc->sc_loc_apple_fn, &flags,
|
||||||
&sc->sc_loc_apple_fn, &flags,
|
|
||||||
&sc->sc_id_apple_fn, NULL)) {
|
&sc->sc_id_apple_fn, NULL)) {
|
||||||
if (flags & HIO_VARIABLE)
|
if (flags & HIO_VARIABLE)
|
||||||
sc->sc_flags |= HKBD_FLAG_APPLE_FN;
|
sc->sc_flags |= HKBD_FLAG_APPLE_FN;
|
||||||
@@ -861,6 +865,7 @@ hkbd_parse_hid(struct hkbd_softc *sc, const uint8_t *ptr, uint32_t len,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* figure out event buffer */
|
/* figure out event buffer */
|
||||||
if (hidbus_locate(ptr, len,
|
if (hidbus_locate(ptr, len,
|
||||||
|
|||||||
@@ -205,6 +205,7 @@ struct ukbd_softc {
|
|||||||
uint16_t sc_inputs;
|
uint16_t sc_inputs;
|
||||||
uint16_t sc_inputhead;
|
uint16_t sc_inputhead;
|
||||||
uint16_t sc_inputtail;
|
uint16_t sc_inputtail;
|
||||||
|
uint16_t sc_vendor_id;
|
||||||
|
|
||||||
uint8_t sc_leds; /* store for async led requests */
|
uint8_t sc_leds; /* store for async led requests */
|
||||||
uint8_t sc_iface_index;
|
uint8_t sc_iface_index;
|
||||||
@@ -1093,6 +1094,7 @@ ukbd_parse_hid(struct ukbd_softc *sc, const uint8_t *ptr, uint32_t len)
|
|||||||
hid_input, &sc->sc_kbd_id);
|
hid_input, &sc->sc_kbd_id);
|
||||||
|
|
||||||
/* investigate if this is an Apple Keyboard */
|
/* investigate if this is an Apple Keyboard */
|
||||||
|
if (sc->sc_vendor_id == USB_VENDOR_APPLE) {
|
||||||
if (hid_locate(ptr, len,
|
if (hid_locate(ptr, len,
|
||||||
HID_USAGE2(HUP_CONSUMER, HUG_APPLE_EJECT),
|
HID_USAGE2(HUP_CONSUMER, HUG_APPLE_EJECT),
|
||||||
hid_input, 0, &sc->sc_loc_apple_eject, &flags,
|
hid_input, 0, &sc->sc_loc_apple_eject, &flags,
|
||||||
@@ -1102,8 +1104,8 @@ ukbd_parse_hid(struct ukbd_softc *sc, const uint8_t *ptr, uint32_t len)
|
|||||||
DPRINTFN(1, "Found Apple eject-key\n");
|
DPRINTFN(1, "Found Apple eject-key\n");
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* check the same vendor pages that linux does to find the one apple
|
* check the same vendor pages that linux does to find the one
|
||||||
* uses for the function key.
|
* apple uses for the function key.
|
||||||
*/
|
*/
|
||||||
static const uint16_t apple_pages[] = {
|
static const uint16_t apple_pages[] = {
|
||||||
HUP_APPLE, /* HID_UP_CUSTOM in linux */
|
HUP_APPLE, /* HID_UP_CUSTOM in linux */
|
||||||
@@ -1112,7 +1114,8 @@ ukbd_parse_hid(struct ukbd_softc *sc, const uint8_t *ptr, uint32_t len)
|
|||||||
0xFFFF /* Original FreeBSD check (Remove?) */
|
0xFFFF /* Original FreeBSD check (Remove?) */
|
||||||
};
|
};
|
||||||
for (int i = 0; i < (int)nitems(apple_pages); i++) {
|
for (int i = 0; i < (int)nitems(apple_pages); i++) {
|
||||||
if (hid_locate(ptr, len, HID_USAGE2(apple_pages[i], 0x0003),
|
if (hid_locate(ptr, len,
|
||||||
|
HID_USAGE2(apple_pages[i], 0x0003),
|
||||||
hid_input, 0, &sc->sc_loc_apple_fn, &flags,
|
hid_input, 0, &sc->sc_loc_apple_fn, &flags,
|
||||||
&sc->sc_id_apple_fn)) {
|
&sc->sc_id_apple_fn)) {
|
||||||
if (flags & HIO_VARIABLE)
|
if (flags & HIO_VARIABLE)
|
||||||
@@ -1122,6 +1125,7 @@ ukbd_parse_hid(struct ukbd_softc *sc, const uint8_t *ptr, uint32_t len)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* figure out event buffer */
|
/* figure out event buffer */
|
||||||
if (hid_locate(ptr, len,
|
if (hid_locate(ptr, len,
|
||||||
@@ -1208,6 +1212,7 @@ ukbd_attach(device_t dev)
|
|||||||
|
|
||||||
sc->sc_udev = uaa->device;
|
sc->sc_udev = uaa->device;
|
||||||
sc->sc_iface = uaa->iface;
|
sc->sc_iface = uaa->iface;
|
||||||
|
sc->sc_vendor_id = uaa->info.idVendor;
|
||||||
sc->sc_iface_index = uaa->info.bIfaceIndex;
|
sc->sc_iface_index = uaa->info.bIfaceIndex;
|
||||||
sc->sc_iface_no = uaa->info.bIfaceNum;
|
sc->sc_iface_no = uaa->info.bIfaceNum;
|
||||||
sc->sc_mode = K_XLATE;
|
sc->sc_mode = K_XLATE;
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
KMOD= hkbd
|
KMOD= hkbd
|
||||||
SRCS= hkbd.c
|
SRCS= hkbd.c
|
||||||
SRCS+= opt_hid.h opt_evdev.h opt_kbd.h opt_hkbd.h
|
SRCS+= opt_hid.h opt_evdev.h opt_kbd.h opt_hkbd.h
|
||||||
SRCS+= bus_if.h device_if.h
|
SRCS+= bus_if.h device_if.h usbdevs.h
|
||||||
|
|
||||||
.include <bsd.kmod.mk>
|
.include <bsd.kmod.mk>
|
||||||
|
|||||||
Reference in New Issue
Block a user