Repository navigation
Gamepads: hide Moonlight controllers from the host until they're assigned to their session - #94
Merged
Merged
Conversation
… assigned Sunshine creates Moonlight controllers in ViGEmBus, and the owning session is only known once it shows up in Sunshine's log, so the controller was hidden after it appeared. By then the host (Steam, a game's XInput) had already opened it, and the Xbox 360 node itself (the one XInput uses) was never restarted because it has children: the remote player's controller also reached the PC. While streams are running, the next free ViGEmBus serials (Xbox 360 and DS4) are now kept in HidHide's jail with a session that doesn't exist, so a new controller is hidden from everyone from the start. Once assigned it's made visible only in its session and restarted as a whole so that session picks it up. Seat claims keep precedence, an unassigned controller goes back to visible everywhere as before, and reservations are removed when the service stops. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
The remote player's controller could also reach the host PC. Sunshine creates Moonlight controllers in ViGEmBus, and OpenStreamMS only learns which session owns one from Sunshine's log, so it hid the controller after it appeared. In that moment the host (Steam, a game's XInput) had already opened it, and HidHide doesn't revoke open handles. The HID child was restarted to close them, but the Xbox 360 node itself — the one XInput reads — never was, because it has children. Controllers that OpenStreamMS plugs in for seats were already hidden before appearing (
ClaimNextViGEmPad); Moonlight ones weren't.What changes
USB\VID_045E&PID_028E\NN) and DS4 (USB\VID_054C&PID_05C4\NN), with a session that doesn't exist. A new controller is hidden from every session from the moment it appears.Testing
dotnet test: 171/171.🤖 Generated with Claude Code