Skip to content

Gamepads: keep Moonlight controllers hidden from the host after the first reconnection - #95

Merged
mlopezsegura merged 1 commit into
masterfrom
fix/stream-pad-reservation-tracking
Nov 24, 2026
Merged

mlopezsegura merged 1 commit into
masterfrom
fix/stream-pad-reservation-tracking

Conversation

@mlopezsegura

Copy link
Copy Markdown
Collaborator

Why

#94 hides the next ViGEmBus controllers from every session before they appear. On a test PC it worked for the first connection after the service started, but not after a client reconnected: the log showed the old path again, with a 5 s wait between the assignment and "visible only in…", which is Windows refusing to restart a controller that another process already has open.

Cause: when a client disconnected, the periodic scan tried to reserve the freed number before removing the old controller's jail entry. ReserveJails skipped it because the entry still existed, but SyncReservations recorded it as reserved anyway. After the old entry was removed, that number had no reservation, and nothing re-added it.

What changes

  • ReserveJails returns the ids it actually reserved, and only those are recorded. A skipped id is retried on the next scan.
  • The scan syncs reservations after removing controllers that left, so a freed number is reserved in the same pass.
  • Log line when reservations become active ("Próximos mandos de Moonlight ocultos de antemano…") or are removed, to check it in diagnostic bundles.

Testing

  • dotnet test: 171/171.
  • Not yet tested with repeated Moonlight reconnections on the test PC.

🤖 Generated with Claude Code

…oller leaves

The reservation of the next ViGEmBus controllers only protected the first
connection after the service started. When a Moonlight client disconnected,
the periodic scan tried to reserve the freed number before removing the old
controller's jail entry, skipped it because that entry still existed, but
recorded it as reserved anyway. Once the old entry was removed, that number
had no reservation and the next controller appeared visible to the host again
(seen in the log as a 5 s wait while Windows refused to restart it).

Only reservations that were actually added are recorded now, and reservations
are synced after removing the controllers that left. A log line says when
reservations become active or are removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mlopezsegura
mlopezsegura merged commit 840277e into master Nov 24, 2026
2 checks passed
@mlopezsegura
mlopezsegura deleted the fix/stream-pad-reservation-tracking branch November 24, 2026 23:55
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