Mac USB keyboards
Rui Paulo
rpaulo at fnop.net
Fri May 11 00:20:47 UTC 2007
Hi,
I'm having some troubles with the Fn key on Apple keyboards.
According to the Linux source, I need to find the hid like this:
/*
* Locate the Fn key on Apple keyboards.
*/
[...]
if (hid_locate(desc, size, HID_USAGE2(HUP_CUSTOM, HUC_FNKEY),
hid_input, &sc->sc_loc_fn, &flags)) {
printf("%s: Fn key.\n",
device_get_nameunit(sc->sc_dev));
sc->sc_flags |= UKBD_FN;
} else
printf("%s: Fn key not found.\n",
device_get_nameunit(sc->sc_dev));
[...]
The key is found.
The problem is: during the interrupt routine, I have to read the data
on that HID location to figure out whether the Fn key is pressed or
not.
Should be something like:
if (sc && sc->sc_flags & UKBD_FN) {
sc->sc_fn = hid_get_data(ibuf, &sc->sc_loc_fn);
if (sc->sc_fn)
printf("Fn key value %d\n", sc->sc_fn);
}
Now the fun part:
When I press Fn + key1, it doesn't print anything, but if I press Fn +
key1 + key2 (all at the same time), sc_fn value is 1.
Now the wildest part:
key1 and key2 are not random keys.
Here's a table for clarity:
key1 | key2
Up Down
Left Right
These keys, when Fn is pressed, should map to Page up, Page down, Home
and End.
Now the wildest-funnier part:
When I press Fn + Fkey (F1-F12) it doesn't work.
It also doesn't work for Fn + Fkey1 + Fkey2
It only works for Fn + Fkey1 + Fkey2 + Fkey3 + Fkey4
So, I'm cleary doing something plain dumb reagarding to HID functions.
Does the code I posted makes sense?
There are only two HID descriptors in this keyboard:
HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_KEYBOARD) 0x00010006
HID_USAGE2(HUP_CUSTOM, HUC_FNKEY) 0xffff0003
Any ideas?
Thanks in advance.
More information about the freebsd-usb
mailing list