Repository navigation
Add HID driver to filter BTN_0 (FN key) events on Surface devices - #1870
Merged
Merged
Conversation
Fixes linux-surface#1851 - FN key causing focus to get stuck in KWin Wayland The Surface Aggregator Module firmware incorrectly reports the FN key as BTN_0 (button 256). This can get stuck in pressed state, flooding the input system and breaking focus tracking in compositors. This patch adds a new HID driver (hid-surface.c) that filters BTN_0 events while allowing all other keyboard/touchpad functionality to work normally. Tested on Surface Laptop 4 AMD with KDE Plasma Wayland.
The fix also applies to kernel 6.17.1 - tested and confirmed bug exists there too.
Member
|
Added to our kernel repo in linux-surface/kernel@7dcd050. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1851 - FN key causing focus to get stuck in KWin Wayland
The Surface Aggregator Module firmware incorrectly reports the FN key as BTN_0 (button 256) through runtime HID events. This button can get stuck in pressed state, flooding the input system (~29 events per second), which breaks focus tracking in KWin Wayland compositor.
Solution
This PR adds kernel patches for 6.16 and 6.17 that create a HID driver (
hid-surface.c) to filter BTN_0 events using theeventcallback. This prevents BTN_0 from reaching the input subsystem while allowing all other keyboard/touchpad functionality to work normally.Testing Results
Hardware: Surface Laptop 4 AMD (Ryzen 5)
OS: Arch Linux
Desktop: KDE Plasma 6.4.5 Wayland
Tested on Kernel 6.16.9-arch1-1-surface
Tested on Kernel 6.17.1-arch1-1-surface
Technical Details
Key insight: BTN_0 is NOT in the HID descriptor - it's generated dynamically at runtime from HID reports. This is why the fix required using the
eventcallback rather thaninput_mapping.Why it affects KWin Wayland specifically: X11 and GNOME Wayland handle stuck button events more gracefully. KWin Wayland's focus tracking is more sensitive to input flooding.
Compatibility & Testing Request
Confirmed working:
Needs testing:
Please test if you have an Intel-based Surface device! We need to verify:
Patch Details
The patch adds 3 files totaling 99 lines per kernel version:
drivers/hid/hid-surface.c(new, 90 lines)drivers/hid/Kconfig(modified, +8 lines)drivers/hid/Makefile(modified, +1 line)Patches included for:
patches/6.16/0016-hid-surface-fn-key.patchpatches/6.17/0016-hid-surface-fn-key.patchFixes: #1851