Skip to content

Extend core API to enable mouse keymap community modules#26232

Open
schuay wants to merge 2 commits into
qmk:developfrom
schuay:feat/mouse-bridge-core
Open

Extend core API to enable mouse keymap community modules#26232
schuay wants to merge 2 commits into
qmk:developfrom
schuay:feat/mouse-bridge-core

Conversation

@schuay

@schuay schuay commented May 26, 2026

Copy link
Copy Markdown

Description

Two small core additions that enable an out-of-tree community module to bridge host-side mouse activity into the QMK action pipeline.

host_last_mouse_buttons() - shadow getter mirroring host_last_system_usage / host_last_consumer_usage. Tracks the latest buttons mask written by host_mouse_send(). Consumers that synthesize out-of-band mouse activity need this to stamp the current HID button state onto motion/wheel reports generated from non-button signals - otherwise a click-and-drag whose press and motion arrive on separate code paths sees buttons=0 on motion and the drag drops mid-stream.

update/read_source_layers_cache_default - extract the existing bodies into default siblings and make the originals weak wrappers that delegate. Same shape as get_chordal_hold_default(). Lets modules adding new KEYLOC_* keypos sentinels add cache buffers for those sentinels and delegate the matrix/encoder cases back. Pure refactor; no behavior change for code that does not override.

See https://github.com/schuay/qmk_modules/tree/feat/strict-core/native_mouse for the community module that uses these hooks.

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

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).

schuay added 2 commits May 26, 2026 18:18
Track the most recent buttons mask passed to host_mouse_send() and
expose it via host_last_mouse_buttons(). Mirrors host_last_system_usage()
and host_last_consumer_usage() in shape and motivation.

Consumers that synthesize out-of-band mouse activity (Raw HID adapters,
pointing-device button handlers) need the current HID-level button
state to stamp onto reports they generate from non-button signals
(motion, wheel). Without this, a click-and-drag whose press and motion
arrive on separate code paths sees buttons=0 on the motion report and
the drag drops mid-stream.
Move the bodies of update_source_layers_cache and read_source_layers_cache
into update_source_layers_cache_default and read_source_layers_cache_default,
and make the original symbols weak wrappers that delegate to the
defaults.

This lets out-of-tree code (e.g. community modules adding new KEYLOC_*
sentinels for additional keypos types) strong-override the wrappers to
add their own cache buffers for those sentinels, then delegate the
existing matrix and encoder cases back to the *_default sibling.

Same shape as get_chordal_hold_default() in action_tapping.c. Pure
refactor: no behavior change for code that doesn't override the
wrappers.
@github-actions github-actions Bot added the core label May 26, 2026
@schuay schuay marked this pull request as ready for review May 26, 2026 16:36
@schuay

schuay commented Jun 14, 2026

Copy link
Copy Markdown
Author

Hey @tzarc @drashna could you please take a look? This enables mouse integration via community modules.

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