fix(macos): provide left/right identity for modifiers#5115
Merged
Conversation
99b91f0 to
058b8f9
Compare
Bundle ReportBundle size has no change ✅ |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #5115 +/- ##
=========================================
Coverage ? 17.84%
=========================================
Files ? 111
Lines ? 24029
Branches ? 10619
=========================================
Hits ? 4288
Misses ? 16556
Partials ? 3185
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
|
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.



Description
Preserve the left/right identity of modifier keys when reflecting keyboard input on macOS.
Moonlight sends distinct virtual keycodes for left and right Shift, etc., but Sunshine previously reflected those as generic modifier state only. That works for many consumers, but it loses information that some macOS apps use to distinguish the physical modifier key. In those cases, modified key combinations arrive as if the modifier was not pressed. For example, Apple's Remote Desktop client or products built with Apple's virtualization kit all ignore modifiers completely when sent the old way.
This PR maps Moonlights left/right modifier keycodes onto the corresponding macOS device-level modifier flags before posting the event. Apps now receive both the generic modifier state and the physical left/right identity.
The switch to
CGSessionEventTapis intentional: the HID-level injection path does not appear to preserve the required left/right identity. This is the main behavior change worth watching for regressions.I checked a few open-source macOS game backends. GLFW, Godot, SDL, and O3DE all read keyboard input through
NSEventon macOS, which is the normal AppKit path for session-posted events. SDL and O3DE also split left/right modifiers usingNX_DEVICEL*/NX_DEVICER*masks, which this PR now provides.This issue was not introduced by #5102, the fix is for a separate case the old code also did not handle.
Sorry for the fourth macOS PR in three days. I think this is the last one for a bit. Famous last words, etc.
Screenshot
Issues Fixed or Closed
Roadmap Issues
Type of Change
Checklist
AI Usage