Skip to content

Add --ignore-injected-events flag to support key remappers (e.g. kanata)#66

Open
MattKotsenas wants to merge 2 commits into
petoncle:mainfrom
MattKotsenas:ignore-injected-events
Open

Add --ignore-injected-events flag to support key remappers (e.g. kanata)#66
MattKotsenas wants to merge 2 commits into
petoncle:mainfrom
MattKotsenas:ignore-injected-events

Conversation

@MattKotsenas

@MattKotsenas MattKotsenas commented Jul 1, 2026

Copy link
Copy Markdown

Summary

Adds the --ignore-injected-events command-line flag (originally prototyped by @petoncle, see #39) on top of current main.

mousemaster ignores injected keyboard events (LLKHF_INJECTED) by default, so key events produced by remapping software such as kanata (which emits via SendInput and is therefore flagged injected) never reach mode/combo processing. That makes it impossible to activate or drive mousemaster from those tools.

This flag lets users opt in to processing injected events:

mousemaster.exe --ignore-injected-events=false
  • Default is true, so behavior is unchanged for anyone who doesn't set it.
  • With =false, injected key events flow through the normal keyboard path.

Testing

Built and verified locally on Windows with Oracle GraalVM JDK 21 + MSVC (VS 2022) with a minimal config that activates on a single key; verified via the ComboWatcher debug log.

I'm also happy to add automated tests here; if you have any preferences, please let me know!

Notes

  • I also bumped the keyboard-hook-installed log line to INFO so that users of keyboard mappers know the hook has been installed without also logging keystrokes.
  • I can't use it with any remapping software e.g.(Kanata) #39 was closed as completed after the reporter switched to the Interception driver, but the flag is still useful for users who can't / don't want to run a kernel driver.

Users of key remappers (e.g. kanata) need to know when mousemaster's low-level keyboard hook is installed so they can order their own hook after it. The message was previously logged at TRACE, which in practice requires DEBUG-or-lower logging that also logs every keystroke. Logging it at INFO exposes the readiness signal without that.
MattKotsenas added a commit to MattKotsenas/dotfiles that referenced this pull request Jul 2, 2026
…tic hook order

kanata maps CAP + backtick to a one-shot F13, and mousemaster activates on
F13. mousemaster only sees kanata's output (emitted via SendInput, so flagged
injected) because its wpm unit now runs --ignore-injected-events=false, a flag
added in the fork build (petoncle/mousemaster#66); the DSC download points at
that fork release until the flag ships upstream. leftalt+i is kept as a
physical activation fallback, and mousemaster's exit is unified on esc (the
q/p exit alias was ambiguous with hint keys).

Both kanata and mousemaster install WH_KEYBOARD_LL hooks, whose call order
(last installed is called first) is nondeterministic and not queryable from
any process. kanata.toml now Requires mousemaster, and mousemaster.toml gates
readiness on a Command healthcheck (wpm/mousemaster-hook-ready.ps1) that waits
for mousemaster to log "Installed keyboard hook successfully". wpm blocks a
dependent until its dependency's healthcheck passes, so kanata always starts
after mousemaster's hook is up: kanata's hook is newest, runs first, and
converts the physical backtick to F13 before mousemaster sees it.

mousemaster runs with --log-level=info (exposes the hook-ready line without
logging every keystroke) and --pause-on-error=false plus ExecStart
RetryLimit=1 (a failed start otherwise hangs on the single-instance lock and
cascades into repeated respawns). It is no longer Autostart; kanata pulls it
in as a dependency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant