Linux: Apple Wireless A1314 Fn key not registered, looks like software bug

applebluetoothlinux

I'm trying to set up my Apple Wireless Keyboard with my Kubuntu systems. These are PC hardware powered by Intel Atom and Intel i5 respectively. The keyboard has a US keyboard layout and has model number A1314 written on the back. It takes two AA batteries. I'm saying that because it appears there are multiple types of model A1314.

I have tried this on a 10.04, 11.04, 11.10 and 12.04 system with no success. Every time using a bluetooth dongle and the KDE bluetooth notification tray applet, the keyboard can be connected. In both cases it shows up as "Apple Wireless Keyboard".

Almost everything works as expected, in fact, I'm typing on it right now. But one thing doesn't: The Fn key. I'd like to use Fn + Down Arrow as PgDn / Page Down, I understand this is default behaviour on Apple keyboards. And of course I'd like the same for Page Up, Home and End. I'll stick to Page Down in my example.

I used the xev tool to see the keycodes the system receives, and if I press on Fn nothing happens, and nothing is registered. If I press Fn + Down Arrow, xev only registers the down arrow. Here's the output from my 11.04 system to illustrate:

Press just the Fn key: no output

Press Down Arrow key:
KeyPress event, serial 36, synthetic NO, window 0x4400001,
root 0x15d, subw 0x4400002, time 2699773, (44,45), root:(1352,298),
state 0x10, keycode 116 (keysym 0xff54, Down), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False

KeyRelease event, serial 36, synthetic NO, window 0x4400001,
    root 0x15d, subw 0x4400002, time 2699860, (44,45), root:(1352,298),
    state 0x10, keycode 116 (keysym 0xff54, Down), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

Press Fn+Down Arrow Keys together:

KeyPress event, serial 36, synthetic NO, window 0x4400001,
    root 0x15d, subw 0x4400002, time 2701548, (44,45), root:(1352,298),
    state 0x10, keycode 116 (keysym 0xff54, Down), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 36, synthetic NO, window 0x4400001,
    root 0x15d, subw 0x4400002, time 2701623, (44,45), root:(1352,298),
    state 0x10, keycode 116 (keysym 0xff54, Down), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

I've been searching this forum and other Linux-related forums for hours but I still have not found a solution. I mostly found advice on how to fix this when using an actual apple laptop or desktop, but I don't have that. They said to try something like the following

echo 2 > /sys/module/hid_apple/ ... But since there's no hid_apple directory present on my systems, I've needed to modprobe hid_apple first. That didn't help either.

I'm cool with changing some config files, or compiling my own patched kernel if that's necessary.

I currently have a 10.04 and 12.04 system available to test.

The same issue occurs when hooked up to Windows 7. Fn key still does nothing, not by itself or in combination with other keys. With some AutoHotkey fiddling, I was able to confirm the key is registered as pressed, but ignored by default. A custom AutoHotkey script can fix that. But AutoHotkey is only for Windows, I want my problem fixed on Linux.

Hooked up to an iPad 2 it only works in combination with the F1-F12 keys. Not with the arrow keys. If the screen of the ipad is off, and I press just the Fn key, the screen will come on, so the key itself is registered as pressed.

So to sum up my question: Can anyone help me get Page Up, Page Down, Home and End to work on this keyboard, when that requires me to use an Fn key which is currently not registered?

Edit 4 July 2012: Still no luck. Thought perhaps KDE was interfering something, but here in XFCE the problem persists.

Here is some output from Syslog:

Jul  4 13:15:31 comp kernel: [ 1561.377849] usb 1-1.4: new full-speed USB device number 8 using ehci_hcd
Jul  4 13:15:31 comp kernel: [ 1561.449864] usb 1-1.4: device descriptor read/64, error -32
Jul  4 13:15:31 comp kernel: [ 1561.629402] usb 1-1.4: device descriptor read/64, error -32
Jul  4 13:15:32 comp kernel: [ 1561.805100] usb 1-1.4: new full-speed USB device number 9 using ehci_hcd
Jul  4 13:15:32 comp bluetoothd[911]: HCI dev 0 registered
Jul  4 13:15:32 comp bluetoothd[911]: Listening for HCI events on hci0
Jul  4 13:15:33 comp bluetoothd[911]: HCI dev 0 up
Jul  4 13:15:33 comp bluetoothd[911]: Adapter /org/bluez/911/hci0 has been enabled
Jul  4 13:15:44 comp kernel: [ 1573.712323] input: Apple Wireless Keyboard as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.0/bluetooth/hci0/hci0:42/input8
Jul  4 13:15:44 comp kernel: [ 1573.712569] generic-bluetooth 0005:05AC:0255.0006: input,hidraw3: BLUETOOTH HID v0.50 Keyboard [Apple Wireless Keyboard] on 00:09:DD:50:75:A1

Best Answer

I finally got the fn key working! I had to compile my own kernel module to do so. I think I coulda solved it in an easier way, but here's what I did:

I found this bug: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/942184

The very first patch posted on that page had my solution: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/942184/+attachment/2788714/+files/alu2011.patch

Then I proceeded to patch and modify my modules following the article and first comment on http://www.codewhirl.com/2012/04/how-to-compile-a-single-module-in-ubuntu-linux/

I didn't apply the entire patch, only the lines referring to USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI with ID 0x0255, since this ID was missing in the kernel source I got. I tried this because I noticed the number 0255 in the syslog earlier: generic-bluetooth 0005:05AC:0255.0006: input,hi...

I don't really fully understand how I did it, but it works!

Here's some Xev output, pressing the left arrow key, first with, and then without fn key:

KeyPress event, serial 34, synthetic NO, window 0x3000001,
    root 0x15d, subw 0x3000002, time 1502136, (40,28), root:(1235,427),
    state 0x0, keycode 110 (keysym 0xff50, Home), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 34, synthetic NO, window 0x3000001,
    root 0x15d, subw 0x3000002, time 1502635, (40,28), root:(1235,427),
    state 0x0, keycode 110 (keysym 0xff50, Home), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyPress event, serial 34, synthetic NO, window 0x3000001,
    root 0x15d, subw 0x3000002, time 1504023, (40,28), root:(1235,427),
    state 0x0, keycode 113 (keysym 0xff51, Left), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

KeyRelease event, serial 34, synthetic NO, window 0x3000001,
    root 0x15d, subw 0x3000002, time 1504235, (40,28), root:(1235,427),
    state 0x0, keycode 113 (keysym 0xff51, Left), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

The Fn key is not registered as a separate key I can have fun xmodmapping with, but this is sufficient for my goals, turning an apple keyboard into a happy-hacking-like by remapping a few keys.

It appears this is all a known bug: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/911064

Related Question