Skip to content

Windows: RemoteIdd capture, active streams API and session-local input - #6

Merged
mlopezsegura merged 8 commits into
masterfrom
fix/input-rdp-session
Nov 8, 2026
Merged

mlopezsegura merged 8 commits into
masterfrom
fix/input-rdp-session

Conversation

@mlopezsegura

@mlopezsegura mlopezsegura commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Brings the Windows work shipped in OpenStreamMS into master, plus the fix for mouse/keyboard going to the host console.

Session-local mouse and keyboard (OpenStreamMS#39)

With the Virtual HID Driver installed and licensed, libvirtualhid creates a driver-backed HID mouse and keyboard. Windows routes HID input to the console session, so a Sunshine running inside an RDP session moved the host's cursor instead of the session's.

When the process is not in the active console session, mouse and keyboard now go through SendInput (src/platform/windows/session_input.{h,cpp}), which injects into the caller's own session. The logic mirrors libvirtualhid's Win32 fallback: same US-layout scan-code map, same virtual-desktop scaling for absolute moves, and a retry on desktop switches (UAC/lock screen). Gamepads, touch and pen keep using libvirtualhid. In the console session nothing changes.

Also included (already shipped in OpenStreamMS builds)

  • feat(windows): RemoteIdd capture backend
  • feat(windows): send frames as they arrive, capped at the client fps
  • fix(windows): use Sunshine's own session for the user token when SYSTEM
  • feat(webrtc): tell Moonlight and WebRTC TV pairings apart in /api/pin
  • feat(confighttp): report active streams in GET /api/streams

Testing

  • Builds locally (MSYS2 UCRT64, Release).
  • Input inside an RDP session via Moonlight: relative/absolute mouse, buttons, wheel, keyboard, unicode text, UAC prompt.
  • Console session still uses libvirtualhid (log line on first input).
  • Original bug with a licensed Virtual HID Driver (needs the reporter; not reproducible here).

🤖 Generated with Claude Code

mlopezsegura and others added 8 commits October 26, 2026 23:50
New capture method "remoteidd" for OpenStreamMS seats. Instead of Desktop
Duplication or WGC, it reads the frames that the OpenStreamMS RemoteIdd
display driver publishes for the current session: a shared texture (NT handle
+ keyed mutex) announced through a named slot with a seqlock. The texture is
copied into the capture image and released right away, so the driver never
waits for the encoder.

- Only selected with capture = remoteidd; never part of auto-detection.
- Requires a hardware encoder and SDR (IddCx 1.4 swapchains are 8-bit BGRA).
- src/platform/windows/remoteidd/ is a copy of the contract and consumer from
  OpenStreamMS/Native/RemoteIdd; change it there and copy it back.
- Tests: hand-off across devices, texture recreation on resize, publisher
  never blocking on a busy consumer, and the real backend capturing a 240 Hz
  producer (481/480 frames, no reinit).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the display refreshes much faster than the client asks for (an RDP seat
composing at 250 Hz for a 60 fps stream), pacing by display ticks repeats or
drops frames. Capture each frame when it arrives and cap the rate with
frame_rate_limiter_t; hold back a frame that comes too early.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Running as SYSTEM inside an RDP seat (needed for the RemoteIdd backend),
retrieve_users_token took the console session's user. Use the session the
process runs in, and fall back to the console only from session 0.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each pending pairing listed by GET /api/pin now carries a kind:
"moonlight" for a Moonlight client and "webrtc" for a Moonlight WebRTC
TV, so a frontend can say which device is waiting for a PIN.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hosts that manage several Sunshine instances (OpenStreamMS) had no way to
know whether anyone is streaming from an instance. GET /api/streams returns
the Moonlight session count (rtsp_stream) and the Moonlight WebRTC TV
session count (webrtc_stream), plus their total. Authenticated like the
rest of the Web UI API.

Tests cover the response and the authentication requirement.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With the Virtual HID Driver installed and licensed, libvirtualhid creates a
driver-backed HID mouse and keyboard. Windows routes HID input to the console
session, so a Sunshine running inside an RDP session moved the host's cursor
instead of the session's (OpenStreamMS#39).

When the process is not in the active console session, mouse and keyboard
now go through SendInput, which injects into the caller's session. Gamepads,
touch and pen keep using libvirtualhid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mlopezsegura
mlopezsegura merged commit c2437ec into master Nov 8, 2026
3 checks passed
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