3

Apple Magic Keyboard (Wireless) does not function correctly, Fn-key does not work, F1-F12 are no media-keys by default which they should.

The following does not solve it: echo 2 | sudo tee /sys/module/hid_apple/parameters/fnmode

I figured it is not using the same driver for USB & Bluetooth, and this is indeed the case:

  • USB uses: usbhid
  • Bluetooth uses: hid-generic

I stumbled upon this driver repo hid-apple which seems to solve a problem described exactly as the one I have. But it's from 2011 and I'm not sure it will fix it because I already have it running:

$ lsmod | grep hid_apple
hid_apple  16384  0
hid        122880  7 
hidp,usbhid,hid_apple,hid_generic,hid_logitech_dj,hid_logitech_hidpp

So it seems Bluetooth should use the hid_apple or usbhid driver?

If so: How can I configure which driver my Bluetooth keyboard uses?

I also found the following bug which seems to have been fixed in the past. https://bugzilla.kernel.org/show_bug.cgi?id=99881#c41

I'm using Ubuntu 18.04 with kernel 4.17.0-rc4. I am using this kernel because its the only one that makes my Realtek 8822be bluetooth/Wi-Fi chip function.

1
  • I have exactly the same issue ("fn" key works fine with USB, does not work with Bluetooth) and get the same output with lsmod. Running Ubuntu 18.04 with the stock 4.15.0-36 kernel. The keyboard is connected to a PC (not a mac). Oct 24, 2018 at 17:01

3 Answers 3

0

The fn key on my Apple bluetooth keyboard model A1644 would turn down the screen brightness (keysym was XF86MonBrightnessDown). My interest was to change tabs in Firefox with Ctrl+PageDown and Ctrl+PageUp which requires fn and the up/down arrows for (PageUp/PageDown). The solution (inspired by this exchange) was to change fn to a modifier key (Shift, AltGr, or Shift+AltGr) and then set the corresponding keysym for the up/down arrows. I used xev to figure out that the keycode for fn is 232 (and 111 and 116 for up and down arrows, respectively). As mentioned in the link, the first keysym (character or function key name) after the equal sign is the one corresponding to the bare key, then comes the one corresponding to the key with Shift, then AltGr, and finally with Shift+AltGr. Then I used the following for mapping and setting up modifier:

xmodmap -e 'keycode 232 = Mode_switch'
xmodmap -e 'keycode 111 = Up Up Prior'
xmodmap -e 'keycode 116 = Down Down Next'

Instead of the up (111) and down (116) arrows, you could use this for F1-F12.

1
0

Linux kernel 5.6 has patched this. There is also a third-party module hid-apple-patched which includes the fix and allows more options to swap keys and can be installed on any kernel.

-1

Following similar steps mentioned here, I upgraded my Ubuntu kernel to 5.6.3 (5.6 has wifi connection issues), and now my keyboard works smoothly.

Steps mentioned in the above link are as follows (for upgrading to 5.6.3):

  • Depending on your OS type, download and install the packages in turns:

    1. linux-headers-5.6.3-xxxxxx_all.deb
    2. linux-headers-5.6.3-xxx-generic(/lowlatency)_xxx_amd64.deb
    3. linux-modules-5.6.3-xxx-generic(/lowlatency)_xxx_amd64.deb
    4. linux-image-xxx-5.6.3-xxx-generic(/lowlatency)_xxx_amd64.deb

Select generic for a common system, and lowlatency for a low latency system (e.g. for recording audio), amd64 for 64bit system, or armhf, arm64, etc for other OS types.


Alternatively, you can download and install the kernel binaries via terminal commands ( open terminal via Ctrl+Alt+T):

For 64-bit OS:

cd /tmp/

wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.6.3/linux-headers-5.6.3-050603_5.6.3-050603.202004080837_all.deb

wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.6.3/linux-headers-5.6.3-050603-generic_5.6.3-050603.202004080837_amd64.deb

wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.6.3/linux-image-unsigned-5.6.3-050603-generic_5.6.3-050603.202004080837_amd64.deb

wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v5.6.3/linux-modules-5.6.3-050603-generic_5.6.3-050603.202004080837_amd64.deb

sudo dpkg -i *.deb

I used this to sign my kernel because it was complaining about the invalid signature on booting up (due to having the Secure Boot activated). A similar and more detailed instruction for signing modules has been mentioned in the ubuntu blog in here.

2
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    – Pilot6
    Apr 11, 2020 at 8:11
  • Thanks for your feedback. Updated the instruction to include more details and added a more reliable link for the second part from the ubuntu blog.
    – Amirsalar
    Apr 12, 2020 at 19:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .