Repository navigation
Conversation
hotkey_F1_F12() decides whether to translate a top-row key from the
current Fn and Fn-lock state alone. If a top-row key goes down as a
media key and Fn is pressed before it is released (with Fn-lock off),
the release takes the "Fn held, pass through" early return:
- the host gets the F-key break code instead of the media break code,
so the media key is never released on the host side, and
- the key's bit stays set in fn_key_table_media.
With Fn-lock on, plain F-keys are only passed through while
fn_key_table_media is empty, so the leftover bit makes every top-row
key send its media function and Fn-lock appears to do nothing.
fn_key_table_media is not cleared on shutdown or startup, so this
survives reboots until the EC itself resets.
Only take the early returns for presses, or for releases while no key
is translated. Any other release goes through the switch, where
fn_table_media_set() clears and translates a key that went down as a
media key and leaves the rest untouched. Presses follow Fn / Fn-lock
only, so a key held as a media key no longer makes the other keys
ignore Fn-lock. Typematic repeats are unaffected: keyboard_8042 resends
the already translated make code without calling the callback.
Repro on a Laptop 13 Pro (sakura), BIOS 3.04:
1. With Fn-lock off: press F2, press Fn, release F2, release Fn.
2. Press Fn+Esc to turn Fn-lock on.
3. Press F1: it sends Mute instead of F1.
Checked with a host-side model of the old and new logic; not yet built
or flashed. Affects every board using keyboard_customization_13.c
(marigold, sakura).
Member
|
Thanks, I can reproduce the issue. |
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.
On my Laptop 13 Pro (Core Ultra Series 3, BIOS 3.04), Fn Lock stopped working: after Fn+Esc, plain F1 still sent Mute. Fn itself worked (Fn+Space, Fn+F1), and rebooting didn't help. This PR fixes the cause in
hotkey_F1_F12().What the controller does today
Each top-row key has two meanings, for example F1 or Mute, and F2 or Volume Down. The controller picks one when the key goes down, and must send the matching release when it comes up.
To keep presses and releases matched, it keeps a list of keys currently held as media keys (
fn_key_table_media). A key goes on the list when it's pressed as a media key, and should come off it when it's released.What goes wrong
On a release, the controller checks Fn before looking at the list. With Fn Lock off and Fn held, it assumes the F-key meaning and skips the list entirely. So if you:
the controller sends "F2 released" instead of "Volume Down released", and Volume Down never comes off the list. That causes three problems:
A smaller version of the same problem: with Fn Lock on, holding any media key turns the other top-row keys into media keys too.
How this change fixes it
Key presses work exactly as before: the controller picks F-key or media from Fn and Fn Lock.
The difference is in releases while any key is on the list. They no longer take the Fn shortcut and go through the existing switch instead:
fn_table_media_set()leaves keys that aren't on the list alone. Non-top-row keys pass straight through.Every release now matches its press, so a key can't get stuck on the list and Fn Lock keeps working. Key repeats are unaffected, because
keyboard_8042resends the already-translated make code without calling the callback.Reproduce
To recover on current firmware: with Fn Lock on, tap each top-row key once without Fn.
Testing
I checked this with a host-side model of the old and new
hotkey_F1_F12()logic, covering the reproduction above, Fn+F-key with Fn Lock on and off, holding a media key while pressing other keys, and releasing keys in different orders. The old logic fails the reproduction; the new logic passes all cases.I haven't built or flashed this firmware. A build and test on hardware by someone with the toolchain would be appreciated.
The change is in the shared
keyboard_customization_13.c, so it affects every board that uses it (marigold and sakura). #87 (Fn-lock indicator on the Caps Lock LED) changes the same file on the same base branch. The two don't overlap, but may need a rebase.