dekuNukem / USB4VC

USB Keyboard/Mouse/Gamepads on Retro Computers!
MIT License
192 stars 12 forks source link

Keyboard function keys recognized as media keys - Keychron K5 SE #10

Open Raging-Flame opened 11 months ago

Raging-Flame commented 11 months ago

After using USB4VC with different keyboards (USB, BT, combined mouse and KB dongles) and all of them working perfectly, I just got a Keychron K5 SE keyboard, which has the following issue.

Function keys do not work and using the option "Show Event Codes" shows, that they are recognized as media keys (volume controls and so on) instead of as function keys. Pressing the FN key and then any of the function keys still shows them as media key via Show Event Codes. The keyboard has an option to switch its standard function key behaviour between function keys and media keys but this doesn't help as the USB4VC doesn't recognize button presses at all when switching the keyboard to the other mode.

I guess, normally keyboards "hardmap" function keys as said function keys but this keyboard (an maybe others too) might hardmap them as media keys.

Is there a way to manually map the keys like it is for gamepads? If not, maybe the USB4VC Configurator app for gamepads could be expanded to also offer this functionality for keyboards.

megatog615 commented 8 months ago

Yeah... happens with Keychron C1 as well.

megatog615 commented 7 months ago

Add this to a new file called /etc/modprobe.d/hid_apple.conf : options hid_apple fnmode=2

This changes the behavior of the hid_apple driver(which non-QMK Keychron boards use regardless if they're in Mac or Windows mode) so that the function keys are read as function keys first. Use FN + function keys to restore the media key behavior. I already had this fix on my Linux PC but I forgot that USB4VC is technically a Linux box 😅.

Raging-Flame commented 7 months ago

Add this to a new file called /etc/modprobe.d/hid_apple.conf : options hid_apple fnmode=2

This changes the behavior of the hid_apple driver(which non-QMK Keychron boards use regardless if they're in Mac or Windows mode) so that the function keys are read as function keys first. Use FN + function keys to restore the media key behavior. I already had this fix on my Linux PC but I forgot that USB4VC is technically a Linux box 😅.

While connected to the USB4VC, the K5 SE in Windows mode causes the function keys behave only as media keys (backlight brightness for example) if FN is held down, while in Mac mode it's reversed. The problem, that the F1 to F12 keys aren't recognized as such remains, even if I add the hid_apple.conf to the boot partitions on the USB4VC microSD card. This file also doesn't change FN-key behaviour.

Also with the K5 SE in Windows mode, you can keep FN+X+L pressed for 4 seconds to change FN-key behaviour, which also works for USB4VC, but doesn't help with the issue of not getting F1 to F12 to work. Very odd that the keyboard always sends media key events to the USB4VC, while it works fine under Windows and Linux.

megatog615 commented 7 months ago

You need to add it to /etc/modprobe.d/ in the rootfs partition not boot.

Raging-Flame commented 7 months ago

You need to add it to /etc/modprobe.d/ in the rootfs partition not boot.

Just did this now and it indeed works, yay! Thanks for the solution. :D

Under Linux Mint 21.2 the keyboard worked out of the box the way it should. I wonder if they accounted for these problems with Keychron keyboards already, even though it runs kernel 5.15 and I read only 5.19 resolved (to a dregree at least) issues with Keychron keyboards.