You are not logged in.

#1 2023-02-09 12:20:11

mabalenk
Member
Registered: 2017-04-28
Posts: 36

How to disable media keys (and enable Fn keys) on custom 75% keyboard

I have a new 75% keyboard. It is a James Donkey A3. All is working well apart from the function keys (F1--F12). By default ArchLinux enables the media keys on KDE Plasma start-up. I would like to change this behavior and have the function keys being active by default. I know this is possible for an Apple Aluminium keyboard, for example (Please see Section 4 called "Function keys do not work"). But how do I achieve that on a custom keyboard? At the moment my Fn key, that should switch between the Function and Media keys in not working at all. It would be great to enable it too. Can you please guide me on how to resolve this issue or point me to the relevant documentation? Thank you!

Last edited by mabalenk (2023-02-10 11:13:02)

Offline

#2 2023-02-11 13:45:42

Lone_Wolf
Forum Moderator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,151

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

By default ArchLinux enables the media keys on KDE Plasma start-up

I doubt that as archlinux sets very little by default and many keyboards with mediakeys have the same behavior on other OSes : boot up with media keys enabled by default .

You should try to identify what scancode / keycode that Fn-key transmits first. Start with reading https://wiki.archlinux.org/title/Keyboard_input .

Last edited by Lone_Wolf (2023-02-11 13:46:37)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#3 2023-02-14 11:05:27

mabalenk
Member
Registered: 2017-04-28
Posts: 36

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

Thank you for your suggestions! At first I tried using evtest to identify the scan and keycodes of the Fn key. Running evtest without any arguments results in two keyboards being identified:

/dev/input/event14:     Jamesdonkey A3R
/dev/input/event15:     Jamesdonkey A3R

Executing evtest /dev/input/event14 and pressing the Fn key does not produce any output. Does it mean that the key was not recognised?

Then I tried utilising dmesg to identify the Fn key. This is what I see, when I use sudo dmesg | grep key:

sudo dmesg | grep "key"
6:[    0.000000] x86/fpu: Supporting XSAVE feature 0x200: 'Protection Keys User registers'
641:[    0.287844] Initialise system trusted keyrings
642:[    0.287851] Key type blacklist registered
645:[    0.288537] integrity: Platform Keyring initialized
646:[    0.288539] integrity: Machine keyring initialized
647:[    0.291034] Key type asymmetric registered
648:[    0.291035] Asymmetric key parser 'x509' registered
747:[    0.367092] Loaded X.509 cert 'Build time autogenerated kernel key: a9f1b8c1bf14b376c0ac30939f35ecfe79c07970'
749:[    0.367944] Key type .fscrypt registered
750:[    0.367945] Key type fscrypt-provisioning registered
752:[    0.368172] integrity: Loaded X.509 cert 'ASUSTeK MotherBoard SW Key Certificate: da83b990422ebc8c441f8d8b039a65a2'
754:[    0.368255] integrity: Loaded X.509 cert 'ASUSTeK Notebook SW Key Certificate: b8e581e4df77a5bb4282d5ccfc00c071'
1037:[    5.657590] Asymmetric key parser 'pkcs8' registered
1077:[    6.509369] input: Eee PC WMI hotkeys as /devices/platform/eeepc-wmi/input/input4
1139:[    8.481407] usb 1-2: Manufacturer: Jamesdonkey
1161:[    9.990628] input: Jamesdonkey A3R as /devices/pci0000:00/0000:00:02.1/0000:01:00.0/usb1/1-2/1-2:1.0/0003:05AC:024F.0002/input/input14
1169:[   10.049803] apple 0003:05AC:024F.0002: input,hidraw2: USB HID v1.11 Keyboard [Jamesdonkey A3R] on usb-0000:01:00.0-2/input0
1170:[   10.049916] apple 0003:05AC:024F.0003: Fn key not found (Apple Wireless Keyboard clone?), disabling Fn key handling
1171:[   10.049940] input: Jamesdonkey A3R as /devices/pci0000:00/0000:00:02.1/0000:01:00.0/usb1/1-2/1-2:1.1/0003:05AC:024F.0003/input/input15
1179:[   10.109868] apple 0003:05AC:024F.0003: input,hiddev97,hidraw3: USB HID v1.11 Keyboard [Jamesdonkey A3R] on usb-0000:01:00.0-2/input1
1200:[   29.392929] audit: type=1300 audit(1676370432.536:125): arch=c000003e syscall=1 success=yes exit=4 a0=8 a1=7ffdd935bbb0 a2=4 a3=0 items=0 ppid=1802 pid=3903 auid=1000 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=2 comm="sddm-helper" exe="/usr/lib/sddm/sddm-helper" key=(null)

As I understand the keyboard wasn't recognised correctly and the function key was disabled. How do I re-enable it?

Offline

#4 2023-02-14 12:05:58

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 22,093

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

Generally speaking Fn keys are more often than not implemented internally by the keyboard/firmware and not necessarily exposed to the OS so all of this can be normal. Do you not have a Fn Lock button or similar? Looking at the keys, try pressing Fn+Win, did the default change? Or does that just send the standard Win+L

Last edited by V1del (2023-02-14 12:08:43)

Offline

#5 2023-02-14 12:10:42

mabalenk
Member
Registered: 2017-04-28
Posts: 36

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

No, I don't have an Fn lock key. I tried pressing Fn+Win, but the default behavior didn't change. I still have media key actions.

Offline

#6 2023-02-14 15:56:55

seth
Member
Registered: 2012-09-03
Posts: 53,108

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

1169:[   10.049803] apple 0003:05AC:024F.0002: input,hidraw2: USB HID v1.11 Keyboard [Jamesdonkey A3R] on usb-0000:01:00.0-2/input0
1170:[   10.049916] apple 0003:05AC:024F.0003: Fn key not found (Apple Wireless Keyboard clone?), disabling Fn key handling

This is from you attempting https://wiki.archlinux.org/title/Apple_ … o_not_work ?

The keyboard seems to come w/ a manual, I'd look into that.
The Fn-lock is often some hidden combination (eg. Fn+CapsLock etc.) and would be documented there.

Offline

#7 2023-02-15 12:59:32

mabalenk
Member
Registered: 2017-04-28
Posts: 36

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

Thank you for your advice! Yes, I tried to change the Fn key mode using the above tip for the Apple Aluminium keyboard. But, of course, this is not an Apple keyboard and this file (/sys/module/hid_apple/parameters/fnmode) does not exist on my system. I read the manual once again. There is no mention of the Fn lock combination. My educated guess is that /dev/input/event14 tries to identify the keyboard as an Apple keyboard, fails and disables the Fn key. Then the keyboard is identified as an Apple clone under /dev/input/event15. But I still don't understand, how to enable the Function keys on this keyboard and ideally have the Fn key working to switch between two modes.

Offline

#8 2023-02-15 14:57:01

seth
Member
Registered: 2012-09-03
Posts: 53,108

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

At the moment my Fn key, that should switch between the Function and Media keys in not working at all.

You mean not even Fn+F1 gets you F1?
Blacklist hid_apple, https://wiki.archlinux.org/title/Kernel … acklisting

Offline

#9 2023-02-15 15:01:49

mabalenk
Member
Registered: 2017-04-28
Posts: 36

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

That's right! Even Fn+F1 doesn't activate F1 for me. I'm trying to black list hid_apple.

Offline

#10 2023-02-15 15:14:19

mabalenk
Member
Registered: 2017-04-28
Posts: 36

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

All right! I blacklisted 'hid_apple'. This way ArchLinux does not recognise my keyboard at all. The keyboard is connected via a USB-C cable, the LEDs are working, when I press the keys. But pressing the keys results in no typing action. I can not even enter my login password.

Offline

#11 2023-02-15 15:44:12

seth
Member
Registered: 2012-09-03
Posts: 53,108

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

Seems it *is* "Apple Wireless Keyboard clone"… hmm
Try to pass

hid_apple.fnmode=2

to the kernel commandline (which is effectively "options hid_apple fnmode=2")

Offline

#12 2023-02-16 12:34:47

mabalenk
Member
Registered: 2017-04-28
Posts: 36

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

I tried passing it to the kernel command line, but it didn't have any effect. The Fn key is still not working and I have media keys being loaded by default. Interesting is that in GRUB the function keys are working normally. When I press F10, GRUB saves my edits and boots the system.

Offline

#13 2023-02-16 12:51:22

seth
Member
Registered: 2012-09-03
Posts: 53,108

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

This is because the keyboard is handled by the hid_apple module, but not actually compatible.
05AC:024F actually /is/ the product/vendor ID of the Apple Aluminium Keyboard which gets misused by your keyboard.
Possibly related is https://lore.kernel.org/all/f82dd7a1-a5 … hat.com/t/

The patch relies on the "Keychron" string showing up, maybe it can be extended to cover your knock-off as well.
https://git.kernel.org/pub/scm/linux/ke … 431d7180b2

The keyboard they're talking about also has a switch to change between mac and pc mode - does yours as well?

Offline

#14 2023-02-17 10:01:42

mabalenk
Member
Registered: 2017-04-28
Posts: 36

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

My keyboard doesn't have a physical switch. The manual says the key combination Fn+5 will switch between Mac and Win mode. I need to read these articles to understand what to do next. Thank you for your help so far!

Offline

#15 2023-02-17 10:50:33

mabalenk
Member
Registered: 2017-04-28
Posts: 36

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

I see now. I think I can use the same trick and patch the hid_apple.c using the keyboard name property. In my case it shows up as

# Properties:
N: Jamesdonkey A3R

But I don't really know where to start with this. I never patched a Linux kernel before!

Offline

#16 2023-02-17 13:11:58

seth
Member
Registered: 2012-09-03
Posts: 53,108

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

https://wiki.archlinux.org/title/Compile_kernel_module

The manual says the key combination Fn+5 will switch between Mac and Win mode.

Does this work during the early bootphase (grub)?

Offline

#17 2023-02-20 09:49:45

mabalenk
Member
Registered: 2017-04-28
Posts: 36

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

No, it doesn't work in GRUB. I need to hold the key combination "Fn+5" for 5 seconds and ensure the RGB lights blink red four times. This is the sign that the keyboard switched its mode from Win to Mac or Mac to Win. I see no blinking. I assume it didn't change its mode. I looks like I need to go the hard way and try to modify the 'hid-apple.c' file.

Offline

#18 2023-03-06 16:45:17

mabalenk
Member
Registered: 2017-04-28
Posts: 36

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

I'm reading about the kernel module compilation and the Arch Build System. But all this looks overwhelming right now. I think I will need further help and guidance. What I have done so far:

  1. Installed the asp port:

    sudo pacman -S asp
  2. Created the build directory:

    mkdir -p ~/build && cd ~/build
  3. Obtained build system source files:

    asp update linux && asp export linux
  4. Modified PKGBUILD file to create a new pkgbase value:

    pkgbase=linux-jamesdonkey-a3
  5. Downloaded Linux kernel source files:

    makepkg -os --skippgpcheck
makepkg -os --skippgpcheck
==> Making package: linux-jamesdonkey-a3 6.2.2.arch1-1 (Mon Mar  6 16:53:54 2023)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Updating archlinux-linux git repo...
  -> Found config
==> WARNING: Skipping verification of source file PGP signatures.
==> Validating source files with sha256sums...
    archlinux-linux ... Skipped
    config ... Passed
==> Extracting sources...
  -> Creating working copy of archlinux-linux git repo...
Cloning into 'archlinux-linux'...
done.
Updating files: 100% (79704/79704), done.
Updating files: 100% (13293/13293), done.
Switched to a new branch 'makepkg'
==> Starting prepare()...
Setting version...
Setting config...
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/confdata.o
  HOSTCC  scripts/kconfig/expr.o
  LEX     scripts/kconfig/lexer.lex.c
  YACC    scripts/kconfig/parser.tab.[ch]
  HOSTCC  scripts/kconfig/lexer.lex.o
  HOSTCC  scripts/kconfig/menu.o
  HOSTCC  scripts/kconfig/parser.tab.o
  HOSTCC  scripts/kconfig/preprocess.o
  HOSTCC  scripts/kconfig/symbol.o
  HOSTCC  scripts/kconfig/util.o
  HOSTLD  scripts/kconfig/conf
#
# No change to .config
#
Prepared linux-jamesdonkey-a3 version 6.2.2-arch1-1-jamesdonkey-a3
==> Sources are ready.

I believe now I will have to modify the hid-apple.c file and re-compile the entire kernel or only a specific module containing the hid-apple.c file. Finally, I will have to enable this custom kernel or a custom module on my system.

Last edited by mabalenk (2023-03-06 18:57:09)

Offline

#19 2023-03-06 18:33:05

mabalenk
Member
Registered: 2017-04-28
Posts: 36

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

Here are my next steps:

  1. modified the file drivers/hid/hid-apple.c to support another non-Apple keyboard "Jamesdonkey A3R"

  2. prepared modules:

    cd src/archlinux-linux && make -j 15 EXTRAVERSION=-arch1 modules_prepare
  3. compiled hid module:

    make M=drivers/hid
  4. compressed new hid module:

    zstd drivers/hid/hid-apple.ko
  5. copied new hid module into the current kernel:

    sudo cp -f drivers/hid/hid-apple.ko.zst /usr/lib/modules/6.2.2-arch1-1/kernel/drivers/hid/
  6. rebuilt module dependency tree:

    sudo /sbin/depmode -a
  7. added new module to Linux kernel:

    sudo modprobe hid-apple
  8. regenerated initramfs for early boot:

    sudo mkinitcpio -p linux

Last edited by mabalenk (2023-03-06 22:48:36)

Offline

#20 2023-03-06 20:04:19

mabalenk
Member
Registered: 2017-04-28
Posts: 36

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

Doing all this rendered my JamesDonkey keyboard unusable. It works in GRUB, but none of the keys are operational at SDDM login screen. After logging in with another keyboard and examining the dmesg output, this is what I see:

1167:[    9.987533] hid_apple: version magic '6.2.2-arch1-1-jamesdonkey-a3 SMP preempt mod_unload ' should be '6.2.2-arch1-1 SMP preempt mod_unload '
1168:[    9.987578] hid_apple: version magic '6.2.2-arch1-1-jamesdonkey-a3 SMP preempt mod_unload ' should be '6.2.2-arch1-1 SMP preempt mod_unload '

I believe this happens because I renamed the pkgbase into "pkgbase=linux-jamesdonkey-a3". Maybe I should have left it intact? I will revert the name and re-do all the steps.

Offline

#21 2023-03-06 20:26:27

mabalenk
Member
Registered: 2017-04-28
Posts: 36

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

I noticed another thing. The following warning is issued when I compile the hid module:

MODPOST drivers/hid/Module.symvers
WARNING: Module.symvers is missing.
         Modules may not have dependencies or modversions.
         You may get many unresolved symbol warnings.
WARNING: modpost: "init_wait_entry" [drivers/hid/uhid.ko] undefined!
WARNING: modpost: "schedule" [drivers/hid/uhid.ko] undefined!
WARNING: modpost: "prepare_to_wait_event" [drivers/hid/uhid.ko] undefined!
WARNING: modpost: "finish_wait" [drivers/hid/uhid.ko] undefined!
WARNING: modpost: "__check_object_size" [drivers/hid/uhid.ko] undefined!
WARNING: modpost: "_copy_to_user" [drivers/hid/uhid.ko] undefined!
WARNING: modpost: "kfree" [drivers/hid/uhid.ko] undefined!
WARNING: modpost: "__stack_chk_fail" [drivers/hid/uhid.ko] undefined!
WARNING: modpost: "misc_deregister" [drivers/hid/uhid.ko] undefined!
WARNING: modpost: "_dev_warn" [drivers/hid/uhid.ko] undefined!
WARNING: modpost: suppressed 3006 unresolved symbol warnings because there were too many)

Here is another one:

Skipping BTF generation for drivers/hid/hid-axff.ko due to unavailability of vmlinux
  CC [M]  drivers/hid/hid-apple.mod.o
  LD [M]  drivers/hid/hid-apple.ko
  BTF [M] drivers/hid/hid-apple.ko

Offline

#22 2023-03-06 23:35:57

seth
Member
Registered: 2012-09-03
Posts: 53,108

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

hid is built-in w/ the default kernel config, did the symbol fixed hid_apple module load?
Otherwise try

modprobe hid_apple --force-vermagic

Offline

#23 2023-05-04 13:42:14

sorat0mo
Member
Registered: 2023-05-04
Posts: 1

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

Hello everyone. I am also a frustrated owner of the Jamesdonkey A3R, discovering the keyboard refuse to work properly on Linux but has no problem on Windows.

I can see that all previous comments tried to concentrate on solving the issue by recompiling the hid-apple module or looking at lsusb results. But if the kernel devs circumvented this for Keychron boards by flipping a fnmode switch, could this also be done for our keyboards?

I changed my keywords slightly and I found the following superuser question:
https://superuser.com/questions/79822/h … d-in-linux

I followed the highest rated answer by user Cynyr, but I input the value 2 instead of 0. And the F5 key is usable again for me smile
This does not fix the driver issues, but hey, it works at least.

Last edited by sorat0mo (2023-05-04 13:48:30)

Offline

#24 2023-05-18 09:53:37

rflow
Member
Registered: 2023-05-18
Posts: 1

Re: How to disable media keys (and enable Fn keys) on custom 75% keyboard

Thank you, sorat0mo! This method saved my Fn keys.

Following other answers to the superuser question, I added "options hid_apple fnmode=2" to /etc/modprobe.d/hid_apple.conf to persist this configuration.
It appears that the hid_apple kernel module is not included in the initramfs image, so I think updating the image is unnecessary.

Offline

Board footer

Powered by FluxBB