Skip to content

Fix osm unlock not sending mod release - #26347

Open
NapOli1084 wants to merge 2 commits into
qmk:developfrom
NapOli1084:dev-fix-osm-unlock-no-kb-record
Open

Fix osm unlock not sending mod release#26347
NapOli1084 wants to merge 2 commits into
qmk:developfrom
NapOli1084:dev-fix-osm-unlock-no-kb-record

Conversation

@NapOli1084

Copy link
Copy Markdown
Contributor

Description

After locking a one-shot mod (OSM) by tapping it ONESHOT_TAP_TOGGLE times (when defined to a value >1), tapping it again afterwards to unlock it did not send the release of the mod. The next pressed key would correctly be sent without the mod, but in the meantime the mod was still seen as pressed by the computer. That's a problem if the next thing you do isn't pressing a key on the keyboard, e.g. when clicking with a mouse, because the mod is still applied.

The problem was due to the sequence when unlocking in process_action():

                                unregister_mods(mods);
                                del_oneshot_mods(mods);
                                del_oneshot_locked_mods(mods);

unregister_mods() calls send_keyboard_report(), which will do so only if there's a change. However, at that point the one-shot mod is still locked, so the mod is still added to the report. No change is detected and no report is sent.

To fix it, del_oneshot_mods() and del_oneshot_locked_mods() must be called before unregister_mods().

I added unit tests to validate this change. The test fails without the change in process_action().

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

Didn't find an existing issue.

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@github-actions github-actions Bot added the core label Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant