feat(macos): add opt-in physical-only key events - #198
Draft
LuisJann wants to merge 1 commit into
Draft
Conversation
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
Recent macOS versions can abort a process when TIS/TSM input-source operations
run from an inappropriate queue. An rdev
listen()callback can encounter thiswhile resolving layout-dependent key names.
This change adds the opt-in
macos_physical_key_eventsfeature. When enabled,macOS key events are mapped exclusively from their physical keycodes and
Event::nameis left unset. The default behavior remains unchanged.Motivation
Consumers such as keyboard-sound applications do not need Unicode or current
keyboard-layout resolution; they need stable physical key identities. For those
applications, dispatching TIS work to the main queue adds latency and potential
re-entrancy/deadlock risk, while moving the complete event tap to the
application's main run loop changes callback scheduling.
An explicit physical-only mode avoids TIS entirely without changing callback
threading or affecting existing consumers. This complements the main-thread
initialization work in #147 and is
motivated by the crash class reported in
#146.
Changes
macos_physical_key_eventsCargo feature;key_from_codewhen enabled;Event::name;Behavioral impact
With
macos_physical_key_eventsenabled:Event::nameisNonefor macOS key events;unavailable.
Without the feature, behavior and API output are unchanged.
Validation
cargo fmt --all --check: passed;cargo test --lib: 4 passed with the default configuration;cargo test --lib --features macos_physical_key_events: 4 passed;rdev 0.5.3path was validated in MechvibesDX onApple Silicon/macOS with global keyboard and mouse input, both audio paths,
more than five minutes of stability, and close/reopen;
SIGTRAP,dispatch_assert_queue, orTSMGetInputSourcePropertycrash recurred in that consumer validation.Compatibility
The feature is opt-in and does not alter the default configuration. A consumer
can enable it while retaining other features such as
unstable_grab.