Skip to content

About

No description, website, or topics provided.

Resources

Stars

112 stars

Watchers

1 watching

Forks

Repository files navigation

Moonlight for CivSwitch

Stream your PC games to Nintendo Switch 2 through Civilization VII. A Moonlight client running inside Gezine’s CivSwitch, with Sunshine pairing, a game library, controller input, video and stereo audio.

Tested on Switch 2. Requires the Switch 1 edition of Civilization VII on a physical cartridge, version 1.0.0, with CivSwitch already set up. Compatibility with other Switch models has not been established.

Native rendering

Moonlight draws its interface with NanoVG and Vulkan at 1920×1080 and presents H.264/AV1 video directly through the same native display. Boost is not required for 1080p output. The Launcher, Moonlight and streaming share one retained display; app transitions release view leases while keeping its device and swapchain alive. There is no output-renderer setting.

Use the matching CivHomebrew native Launcher (0.4.3-nanovg.12, core 0.4.3-sdk.8, SDK 1.3.5) and restart Civ VII after the upgrade. Earlier builds completed four installed Launcher → Moonlight → stream → Launcher roundtrips on Switch 2, using H.264 and AV1 on one retained native device/swapchain. The user confirmed picture, sound, overlay spacing and centered button labels. These were short 1080p60/20 Mbps requested Desktop streams, rather than a sustained 60 FPS performance qualification. The earlier direct AV1 workload measured 57.2 FPS with Boost off; Boost state was not re-confirmed for this newer test. Stream sources up to 4K are scaled to the shared 1080p output; 4K is capped at 60 FPS. See rendering and app switching and earlier native video evidence.

Shared renderer development

Launcher, Hello CivHomebrew, Moonlight and Doom pin CivHomebrew-SDK 1.3.5. Renderer fixes belong in CivHomebrew-SDK. Each app builds offline from the same verified release. See native rendering for integration and validation, including the restart required when upgrading the resident renderer.

Screenshots

Pairing Game library
Pair a PC with Moonlight Browse the Moonlight game library
Stream settings Streaming controls
Moonlight resolution, frame rate and bitrate settings Moonlight disconnect and terminate controls during a stream
Virtual keyboard Touchscreen mode
Moonlight virtual keyboard during a stream Moonlight touchscreen mode menu

Captured on Switch 2. Click a screenshot to enlarge.

Supported features

  • H.264 hardware decoding
  • Touchscreen: trackpad and direct touch modes (without Boost mode)
  • Virtual keyboard
  • Mouse control from gamepad
  • Gamepad rumble

Installation

Have Sunshine running on your PC and connect the PC and Switch to the same local network. Choose either method below.

1. CivHomebrew — recommended

  1. Set up CivHomebrew with its matching native Launcher on your Switch.
  2. Get a moonlight.civapp package, or build one using the instructions below.
  3. In CivHomebrew, open Y Options → FTP and enable the FTP server.
  4. Connect an FTP client to the Switch (default port 5000) and upload moonlight.civapp into Install civapp.
  5. Select Moonlight in the launcher and press A.

The app stays installed in the game’s save data, ready to launch from CivHomebrew.

In a CivHomebrew version supporting app updates, select Moonlight and open X Menu → Check app updates. The package declares this repository's latest GitHub release and the moonlight.civapp asset. A newer release offers confirmation before installation; its tag and packaged release must use matching SemVer versions. Pairing and settings are kept outside the installation folder.

2. Upload to Gezine’s launcher

Build the project below, then leave Gezine’s original CivSwitch loader waiting for a payload. From the Moonlight repository, run:

python3 tools/send_ui.py SWITCH_IP

Replace SWITCH_IP with your console’s local IP address. The sender uploads the streaming runtime and app automatically. Keep the terminal open while using it; close Moonlight before uploading another payload. The raw loader has no Launcher view to return to; use CivHomebrew for app switching.

First launch

Choose Pair new host, enter your PC’s IP address, and approve the displayed PIN in Sunshine. Select the paired PC, then choose a game or Desktop to stream.

  • D-pad / A: navigate and select. B: go back; from Hosts, return to Launcher.
  • − and + together: open the left-side menu, titled with the connected host's name. More contains Mouse by Gamepad, Show keyboard and Touchscreen mode. Logout opens Disconnect / Terminate: Disconnect keeps the PC app running; Terminate also closes it. B goes back through the menu and returns to streaming.
  • A running PC app appears first in the library; other cards are dimmed and disabled until it stops. Use Terminate app at the top right to close it.
  • Settings: adjust resolution, frame rate, bitrate, codec and frame pacing. Defaults are 720p, 60 FPS, 20 Mbps.

Pairing and settings are saved between sessions.

Gamepad rumble from the PC is sent to the active Switch controller. It follows the console's vibration setting and stops on disconnect, focus loss, or when opening the stream options. Joy-Con and Pro Controller vibration use both HD rumble frequency bands; trigger rumble is not supported.

Settings → Gamepad rumble turns controller vibration on or off.

Settings → Touchscreen selects either:

  • Trackpad (default): slide one finger to move the mouse. Tap with one finger for left click or two fingers for right click. Swipe with two fingers to scroll vertically or horizontally; the page follows your fingers. Quickly tap again and keep your finger down on the second tap to hold the left button and drag; lifting releases it.
  • Touchpad (direct touch): each finger is sent as a separate touch contact at its position in the streamed picture. Requires a Sunshine host with direct touch support; an unsupported host shows a notice. Host OS and app support determine how those contacts behave.

Place three fingers on the stream to open the full English virtual keyboard in either touchscreen mode. Lift the opening fingers, then hold any combination of keys, including modifiers. Touch outside the keyboard to close it. A keyboard opened by touch leaves the gamepad controlling the stream. −/+ → More → Show keyboard opens the controller mode: D-pad moves, A holds a key or toggles a modifier for combinations, Y sends Backspace, X sends Space, L/R send left/right arrow keys, and B closes. Hold a shortcut to repeat it. Switch-style button hints appear at the bottom in controller mode. Release the opening A before typing.

Touch input pauses while the stream options are open or the app loses focus. More → Touchscreen mode changes the active stream immediately and saves the choice for future streams; touchscreen changes in Settings apply to the next stream. Rumble updates are combined and limited to 30 per second after video/audio processing; zero strength bypasses the rate limit. The performance overlay reports rumble call timing.

−/+ → More → Mouse by Gamepad enables the Moonlight-Switch mouse controls: left stick moves, L/R slows/speeds up, ZR/ZL holds left/right click for clicks and dragging, and the right stick scrolls. − hides/shows hints, X opens the keyboard, Y opens speed/button-swap/scroll-direction options, and B goes back. B from the keyboard returns to mouse mode. B from mouse options saves them. Menu entry, focus loss and disconnect release held input.

Build from source

Install Git, Python 3.10+, Node.js 22+ with npm, CMake, and a C/C++ build toolchain (Xcode Command Line Tools on macOS, or build-essential on Linux). Then run:

git clone https://github.com/XITRIX/Moonlight-CivSwitch.git
cd Moonlight-CivSwitch
npm run bootstrap
npm run build

Bootstrap downloads the pinned dependencies and installs Emscripten 3.1.74 locally; no global SDK setup or npm install is needed. The build produces dist/runtime/moonlight-stream.js. You can now upload with tools/send_ui.py. Run npm run build again after changing native runtime sources.

Optional: create a .civapp package

After building, package from the Moonlight root with the included tool:

npm run package

This creates and validates dist/moonlight.civapp, ready to install using method 1 above. No separate CivHomebrew checkout is needed. payload.json defines the bundled files and their order; rebuild the package after changing the app. The single-file Python packager can also be copied into other repositories; see reuse and CI examples.

The manual Release Moonlight GitHub Actions workflow reads the version from payload.json, builds/tests the app and publishes an update-ready moonlight.civapp release. See release workflow.

Development checks

npm test
npm run test:runtime
npm run test:ui
npm run test:package

Runtime checks require a completed build; package checks also require npm run package. UI and package checks require Chrome; set CHROME_BIN if needed. See the build details, streaming notes and development routine for more.

Credits

Third-party licenses and attribution are included in the bundled notices.

About

No description, website, or topics provided.

Resources

Stars

112 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages