Thread (11 messages) 11 messages, 2 authors, 2022-07-31

Re: fn-key issue with hid_apple and keychron keyboards

flat view

From: Hans de Goede <hidden>
Date: 2021-05-17 09:50:12

Hi Bastian,

On 5/17/21 9:46 AM, Bastian Venthur wrote:
Hello Hans,

I'm writing you because apparently you provided the patch [1] for Linux "Disable Fn-key key-re-mapping on clone keyboards" -- which seems related to a bug I've found with Keychron C1 keyboard.

I'm really sorry if you're not the right contact for those kind of issues, and would be very happy if you could point me to the correct ones.
It is usually a good idea to at least Cc the relevant linux mailinglist on
questions like this. I've added the linux-input list to the Cc now.
I recently got a Keychron C1 keyboard (but I gather, other Keyboards from this company are affected as well). The keyboard has a physical switch for "Windows" and "Mac" modes, however in both cases the kernel recognizes it as an Apple keyboard and loads the "hid-apple" module. However it does *not* recognize the 'Fn' key and disables it. But the keyboard has one and I have to enable it manually either via:

# as root:
echo 2 > /sys/module/hid_apple/parameters/fnmode

or permanently:

options hid_apple fnmode=2
in /etc/modprobe.d/hid_apple.conf

Without this, I cannot use the Function-keys, they will always be used as Multimedia-keys, regardless if you press Fn + F1 or not.

Here's the relevant dmesg output when i plug the keyboard in.

[    6.234069] apple 0003:05AC:024F.0004: input,hidraw3: USB HID v1.11 Keyboard [Keychron Keychron C1] on usb-0000:06:00.4-1.2.1.2/input0
[    6.234261] apple 0003:05AC:024F.0005: Fn key not found (Apple Wireless Keyboard clone?), disabling Fn key handling
[    6.294181] apple 0003:05AC:024F.0005: input,hidraw4: USB HID v1.11 Keyboard [Keychron Keychron C1] on usb-0000:06:00.4-1.2.1.2/input1
Ok, so the keyboard presents itself as 2 interfaces. and the "Fn key not found" message
is only being printed for the second interface. So I guess that the trouble F1-F12 keys
are actually coming out of the first interface (the 0003:05AC:024F.0004 device above).

What my patch does it completely disables the fnmode handling, similar to setting the
fnmode parameter to 0, but unlike my (Maxxter KB-BT-001 Bluetooth keyboard) "clone" your
keyboard does actually advertise a Mac style Fn key in its descriptors, at least for the
first interface so it is treated as a standard Mac keyboard where the non Fn behavior of
the F-keys is to send the multimedia events. Normally pressing Fn + F1 - F-12 should then
result in the kernel actually sending F1-F12 and setting fnmode=2 should just invert when
you need to press Fn.

Basically the way the actual mac keyboards work is the simply always send F1 - F12 events
and a separate Fn event and leave it up to the OS to translate this to either plain
F1 - F12 or to the multimedia codes. Where as normal keyboards handle the Fn press
internally and actually send different "scancodes" over the wire to the computer when
Fn + F1 - F12 is pressed.

But if I understand you correctly then the Fn translation hid-apple is doing to make
things work as expected with Mac keyboards is not working for you, IOW with fnmode=1
pressing Fn + F1 does not result in F1 being send, correct ?  This means that your
keyboard behaves more like a normal keyboard instead of as an apple keyboard.

I also wonder if the Fn key sends any events at all (or if it is fully handled internally)...
I have no idea how to fix this, but I can provide additional information if needed.
Please become root ("sudo su -") and then do:

/sys/kernel/debug/hid/0003:05AC:024F.*/rdesc > Keychron-C1-rdesc

And attach the generated Keychron-C1-rdesc file to your next email.

Also please as root run:

sudo evemu-record

And then select the device belonging to your keyboard and press F1, Fn and Fn + F1,
please repeat this for all input devices belonging to your keyboard and then
copy and paste the output of each run into your next email.

Regards,

Hans
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help