# Apple Wireless Keyboard fn (delete, page up, etc) (*SOLVED*)

## OrangeToque

I just got a new Apple Wireless Keyboard (Bluetooth)

Basic keyboard functionality is there, however, the keyboard fn key is not recognized and as such combo keys such as delete, page up, and page down are not functioning, neither are the volume up/down/mute and multimedia keys.

Any ideas for how to get the keys to function?

Thanks

----------

## twam

Support for the new wireless keyboard was added in kernel 2.6.25-rc2.

If you want to get it working without waiting, you must change some vendor ids in the kernel source files. Look here for further information.

----------

## OrangeToque

I've tried the lastest git-sources, and the keys were not recognized.

I've also tried changing the vendor ids to no avail.

Any other thoughts/suggestions ?

Where can/should I post a bug about support inside the kernel?

----------

## twam

In drivers/hid/usbhid/hid-quirks.c you should find

```
#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI  0x022c

#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO   0x022d

#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS   0x022e
```

in kernels >2.6.25-rc2. This product ids should be the same as lsusb reports, e.g. 0x0221 for me:

```
Bus 002 Device 004: ID 05ac:0221 Apple Computer, Inc.
```

To enable Apple fn features, you must set 

```
CONFIG_USB_HIDINPUT_POWERBOOK=y
```

in your kernel config.

----------

## OrangeToque

Tried that several times, no luck.

The keyboard is bluetooth ... could that affect the way the keypresses are processed? 

lsusb does not reveal anything regarding the keyboard,

hidd --show (on the other hand reveals :: )

xx:xx:xx:xx:xx:xx Apple Inc. Keyboard [05ac:022c] connected

basically providing me with the device id of 0x022c which was hardcoded into the hid-quirks.c in the latest git-source (linux-2.6.25-rc2-git4)

Re-compiled that kernel (with the Apple keyboard option) and still no luck.

----------

## twam

I think the problem is that this driver does not work for the bluetooth keyboards. Maybe you should report this and ask on linux-input@vger.kernel.org.

----------

## OrangeToque

I've found a big part of the answer here ::

http://www.unionofopposites.com/tech/applebtkb.shtml

Basically I needed to patch net/bluetooth/hidp/core.c ::

```

--- linux-2.6.24-gentoo-r2/net/bluetooth/hidp/core.c.orig       2007-10-26 10:28:59.000000000 -0700

+++ linux-2.6.24-gentoo-r2/net/bluetooth/hidp/core.c    2007-10-26 10:30:59.000000000 -0700

@@ -686,6 +686,7 @@

 } hidp_blacklist[] = {

        /* Apple wireless Mighty Mouse */

        { 0x05ac, 0x030c, HID_QUIRK_MIGHTYMOUSE | HID_QUIRK_INVERT_HWHEEL },

+       { 0x05ac, 0x022c, HID_QUIRK_POWERBOOK_HAS_FN },

 

        { }     /* Terminating entry */

 };

```

This has enabled basic functionality (Home / End / Delete / Pg up / Pg down) 

Multimedia keys function with kernel 2.6.25 (git sources with the above patch [/code]@ this point) but I think I will be able to patch hid-quirks.c in 2.6.24 to get them to function.

----------

## OrangeToque

I did run into one problem, and thought I should share the fix ::

All of this works in X, but when I switch to a console, the keyboard doesn't work ? worked before @ the console, now it doesn't ( some keys are ignored, others produce numbers ... )

FIX :: removed numlock from startup 

```
rc-update del numlock
```

----------

## OrangeToque

You can apply this patch to line up the multimedia keys across the top of the keyboard ::

```
--- linux-2.6.24-gentoo-r1/drivers/hid/hid-input.c   2008-01-24 15:58:37.000000000 -0700

+++ linux/drivers/hid/hid-input.c   2008-02-22 09:34:08.000000000 -0700

@@ -101,22 +101,24 @@

 #define POWERBOOK_FLAG_FKEY 0x01

 

 static struct hidinput_key_translation powerbook_fn_keys[] = {

-   { KEY_BACKSPACE, KEY_DELETE },

-   { KEY_F1,       KEY_BRIGHTNESSDOWN,     POWERBOOK_FLAG_FKEY },

-   { KEY_F2,       KEY_BRIGHTNESSUP,       POWERBOOK_FLAG_FKEY },

-   { KEY_F3,       KEY_MUTE,               POWERBOOK_FLAG_FKEY },

-   { KEY_F4,       KEY_VOLUMEDOWN,         POWERBOOK_FLAG_FKEY },

-   { KEY_F5,       KEY_VOLUMEUP,           POWERBOOK_FLAG_FKEY },

-   { KEY_F6,       KEY_NUMLOCK,            POWERBOOK_FLAG_FKEY },

-   { KEY_F7,       KEY_SWITCHVIDEOMODE,    POWERBOOK_FLAG_FKEY },

-   { KEY_F8,       KEY_KBDILLUMTOGGLE,     POWERBOOK_FLAG_FKEY },

-   { KEY_F9,       KEY_KBDILLUMDOWN,       POWERBOOK_FLAG_FKEY },

-   { KEY_F10,      KEY_KBDILLUMUP,         POWERBOOK_FLAG_FKEY },

-   { KEY_UP,       KEY_PAGEUP },

-   { KEY_DOWN,     KEY_PAGEDOWN },

-   { KEY_LEFT,     KEY_HOME },

-   { KEY_RIGHT,    KEY_END },

-   { }

+        { KEY_BACKSPACE, KEY_DELETE },

+        { KEY_F1,       KEY_BRIGHTNESSDOWN,     POWERBOOK_FLAG_FKEY },

+        { KEY_F2,       KEY_BRIGHTNESSUP,       POWERBOOK_FLAG_FKEY },

+        { KEY_F3,       KEY_CYCLEWINDOWS,       POWERBOOK_FLAG_FKEY }, /* ExposÃ© */

+        { KEY_F4,       KEY_WWW,                POWERBOOK_FLAG_FKEY }, /* Dashboard */

+        { KEY_F5,       KEY_FN_F5 },

+        { KEY_F6,       KEY_FN_F6 },

+        { KEY_F7,       KEY_PREVIOUSSONG,       POWERBOOK_FLAG_FKEY },

+        { KEY_F8,       KEY_PLAYPAUSE,          POWERBOOK_FLAG_FKEY },

+        { KEY_F9,       KEY_NEXTSONG,           POWERBOOK_FLAG_FKEY },

+        { KEY_F10,      KEY_MUTE,               POWERBOOK_FLAG_FKEY },

+        { KEY_F11,      KEY_VOLUMEDOWN,         POWERBOOK_FLAG_FKEY },

+        { KEY_F12,      KEY_VOLUMEUP,           POWERBOOK_FLAG_FKEY },

+        { KEY_UP,       KEY_PAGEUP },

+        { KEY_DOWN,     KEY_PAGEDOWN },

+        { KEY_LEFT,     KEY_HOME },

+        { KEY_RIGHT,    KEY_END },

+        { }

 };

 

 static struct hidinput_key_translation powerbook_numlock_keys[] = {

```

----------

## RobbaZ

Hi! Maybe this isn't the best place to ask those infos.. I've the same keyboard but I've a lot of problem with bluetooth connection... 

I've tried to follow this guide: http://gentoo-wiki.com/HOWTO_Use_an_Apple_wireless,_Bluetooth_keyboard but the keyboard is very unresponsive! (sometimes works so slow, sometimes doesn't work at all)

Pleeease.. Can you post me what version of bluez-* are you using and some guide-lines to have it working?

Thank you!

----------

## OrangeToque

Sure.

I'm using::

bluez-utils-3.27

bluez-libs-3.27

The most important part for me is that I am using the old-daemons use flag.

Then I'm using the hidd rc-script to handle the bluetooth connection and input with the keyboard.

Basically follow the directions in the gentoo wiki, except there is no need to add the HIDD_ENABLED=TRUE to your /etc/conf.d/bluetooth, instead, you should startup the HIDD service @ boot ::

```
rc-update add hidd default
```

My config file for hidd is a follows ::

/etc/conf.d/hidd#

```
Bluetooth hidd daemon configuraton file

# Arguments to hidd

HIDD_OPTIONS="--encrypt --connect xx:xx:xx:xx:xx:xx --server --master -t 0"

```

where xx:xx:xx:xx:xx:xx is the address of my keyboard.

In order to pair your device the first time, newer versions of bluez will require either bluez-gnome (which I used (version 0.23)) or kdebluetooth (which I haven't tried and can not verify)

I hope this helps.

----------

## RobbaZ

thank you so much!! Now I've got it working!!  :Smile: 

I have only some problems with the FN-key (maybe I must patch my italian layout) but I can see the keycode (464) with "showkey" command..

Thank you!

Bye

----------

