HP Active Pen G2 top pen button is recognized as XF86AudioMicMute
Original bugreport: https://github.com/linuxwacom/input-wacom/issues/49
Issue description this comment:
X (the protocol) has a limitation of 255 for key codes, but keycodes are offset by 8 for historical reasons. So the evdev to keycode mapping is literally "evdev keycode + 8".
KEY_ESC
is thus X key code 9.Next layer is the xkb model which maps that number to a symbolic key:
keycodes/evdev: <FK20> = 198;
i.e. keycode 198 is mapped to FK20 and that is mapped to the symbol:
symbols/inet: key <FK20> { [ XF86AudioMicMute ] };
So this is where your 198 -> microphone mapping comes from.
Note that FK20 is not F20. FK20 is an internal lookup symbol. The actual mapping applied is "198 -> XF86AudioMicMute". F20 mapped to F20 would look like this:
symbols/inet: key <FK20> { [ F20 ] };
If that were the case, xev would show F20 as Keysym.
Why do we map FK20 to micmute? Because we can't use this one:
#define KEY_MICMUTE 248 /* Mute / unmute the microphone */
The keycode is 248 + 8 = 256, outside of what X can deal with. ftr Wayland has 32bits so all this should work fine there.
As for the mutter commit: this is the opposite of what we need. Previously, gnome would assume that both XF86AudioMicMute and F20 trigger the microphone. With that commit, only the former does so which means you could configure your XKB layout to have anything send XF86AudioMicMute. The latter would now just be interpreted as F20.
But the pen itself sends keycode 190 (
KEY_F20
) and because of historical reasons that is mapped to micmute in XKB. So we do get the XF86AudioMicMute symbol, GNOME mutes the microphone, etc.
There's XKB_FIXED_LAYOUT, XKB_FIXED_VARIANT which was intended for similar use-cases. but I can't find anything in the GNOME tree that actually uses it. Adding support for that would be the best solution I think, together with a udev rule to set it for the device. Beyond that...
/me scratches his head and shrugs