Skip to content

feat: initial implementation#160

Merged
ReenigneArcher merged 35 commits intomasterfrom
feat/initial-implementation
Apr 18, 2026
Merged

feat: initial implementation#160
ReenigneArcher merged 35 commits intomasterfrom
feat/initial-implementation

Conversation

@ReenigneArcher
Copy link
Copy Markdown
Member

@ReenigneArcher ReenigneArcher commented Apr 6, 2026

Description

Phase 1 of implementation

  • UI beyond splash screen
  • Automatically detect aspect ratio and configure/scale UI accordingly
  • Manual host pairing
  • Automatic host refreshing
  • Applist and caching
  • Log viewer

TODO:

  • Fix known issues
    • slow gamepad navigation in some cases
    • use cached applist from previous sessions on clean boot
  • Add auto discovery
  • improve startup debugPrint output
  • improve test coverage
  • eliminate sonar warnings
  • use nicer SVG assets
  • persistent settings, json? (decided on toml format for now)
  • docs
    • remove AI generated md files in docs
    • add screenshots and/or gif
    • update readme with updated build instructions, dependencies

Screenshot

image image image image image image image image image image

Issues Fixed or Closed

Roadmap Issues

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Unit tests have been added or updated for any new or modified functionality

AI Usage

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 6, 2026

Codecov Report

❌ Patch coverage is 69.15749% with 1036 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.82%. Comparing base (cb3c38c) to head (e25ea15).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/app/client_state.cpp 67.82% 221 Missing and 206 partials ⚠️
src/ui/shell_view.cpp 60.12% 66 Missing and 123 partials ⚠️
src/app/host_records.cpp 75.54% 29 Missing and 50 partials ⚠️
src/app/settings_storage.cpp 67.15% 33 Missing and 34 partials ⚠️
src/logging/logger.cpp 77.02% 23 Missing and 28 partials ⚠️
src/startup/saved_files.cpp 66.03% 8 Missing and 28 partials ⚠️
src/logging/log_file.cpp 54.54% 15 Missing and 20 partials ⚠️
src/startup/client_identity_storage.cpp 59.30% 13 Missing and 22 partials ⚠️
src/startup/cover_art_cache.cpp 69.01% 5 Missing and 17 partials ⚠️
src/startup/host_storage.cpp 57.14% 4 Missing and 14 partials ⚠️
... and 14 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #160      +/-   ##
==========================================
+ Coverage   61.40%   61.82%   +0.42%     
==========================================
  Files           2       30      +28     
  Lines          57     4794    +4737     
  Branches       13     2140    +2127     
==========================================
+ Hits           35     2964    +2929     
- Misses         17      910     +893     
- Partials        5      920     +915     
Flag Coverage Δ
Linux 62.01% <69.80%> (+0.60%) ⬆️
Windows ?
macOS 49.48% <56.33%> (-11.92%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/input/navigation_input.cpp 100.00% <100.00%> (ø)
src/network/host_pairing.cpp 43.86% <ø> (ø)
src/network/runtime_network.cpp 100.00% <100.00%> (ø)
src/platform/error_utils.h 100.00% <100.00%> (ø)
src/splash/splash_layout.cpp 92.85% <100.00%> (ø)
src/streaming/stats_overlay.cpp 100.00% <100.00%> (ø)
src/app/client_state.h 97.50% <97.50%> (ø)
src/app/host_records.h 90.90% <90.90%> (ø)
src/logging/logger.h 80.00% <80.00%> (ø)
src/network/host_pairing.h 0.00% <0.00%> (ø)
... and 20 more

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cb3c38c...e25ea15. Read the comment docs.

@ReenigneArcher ReenigneArcher force-pushed the feat/initial-implementation branch 14 times, most recently from 3d105cb to afa99a2 Compare April 7, 2026 17:19
Comment thread src/platform/filesystem_utils.cpp Fixed
@ReenigneArcher ReenigneArcher force-pushed the feat/initial-implementation branch 14 times, most recently from 2edc2b0 to cf77c81 Compare April 9, 2026 00:53
Refactor add-host keypad handling and improve controller navigation/UI behavior.

- Replace ad-hoc keypad button list with fixed character arrays and AddHostKeypadLayout; add helper to get selected keypad character and robust wrapping navigation across rows.
- Add GamepadAxisDirection enum and mapping for axis directions to UI commands; support left-stick navigation with hysteresis and held-repeat timing.
- Rework SDL event loop to use a short wait timeout, process events, and poll controller navigation when idle; add per-direction hold state and repeat/seeding logic; avoid jitter and require neutral stick when non-navigation commands occur.
- Introduce KeypadModalLayoutCache to cache modal text measurements and reduce redraws; optimize modal rendering and drawing conditions for keypad modal.
- Update shell view text and modal footer actions to reflect new controls and improve help messaging.
- Simplify host_pairing: remove legacy JSON parsing helpers and SHA-1 legacy support, force SHA-256 pairing digest, and adjust digest/key derivation APIs; return an explicit error when applist is not XML.
- Minor input and UI tweaks (constants, thresholds, repeat timings) and corresponding unit test updates.

These changes improve controller UX (left-stick support, repeat behavior), simplify keypad logic, and remove legacy pairing code paths.
Add an IDE run configuration (.run/docs.run.xml) to open the generated docs HTML. Replace the old loading.png with three new screenshots under docs/images/screenshots and update README to show the new images and clarify that streaming does not work yet and 1080i does not work in Xemu. Also tidy the TODO checklist by marking docs via doxygen done and removing the duplicate entry.
Add test-output/ to .gitignore and delete generated test logs under test-output/logging (long-lines.log, moonlight.log, reset.log). These are ephemeral test artifacts and should not be tracked in the repository.
Stop tracking the binary vegur-regular.ttf and instead copy it from the nxdk samples during the CMake xbox asset sync. Remove the committed font file from the repo. Update CI and docs: drop mingw-w64-x86_64-make from the workflow and remove the failing OpenSSL debug-logs step, and adjust README to use mingw-w64-x86_64-cmake (plus minor formatting).
Introduce a lightweight activeHost snapshot and hostsLoaded flag to allow unloading the hosts page while preserving host-specific screens. Add utilities to remember/restore selected host, unload per-screen state, and route lookups via find_loaded_host_by_endpoint. Implement a thread-safe HostProbeResultQueue and refactor host probing to spawn per-host worker threads that publish results into the queue; the main loop now drains and reap workers, updating host reachability and persisting metadata changes. Extend host-record serialization to include cached host metadata and app-list entries (with percent-encoding/decoding and parsing helpers) so app lists, artwork cache keys, and related flags are persisted. Update persistence and shell logic to merge activeHost into saved hosts when saving, lazily load hosts for the hosts screen, release page resources on screen changes, and adjust related client_state/shell behavior. Tests updated to reflect the new unload/load semantics and probe behavior.
Introduce persistent TOML-backed app settings and expand logging features.

- Add third-party tomlplusplus submodule and include it in the Xbox build.
- Implement settings storage (src/app/settings_storage.*) to load/save moonlight.toml (logging and UI keys), with parsing, validation, warnings and cleanup hints.
- Add AppSettings types and load/save APIs (settings_storage.h).
- Add storage_paths helper for default storage locations and platform error utilities.
- Enhance logging subsystem:
  - Add global logger proxy (global_logger.*) and startup debug support.
  - Add source-location support and richer formatting in logger; include optional file/line in entries.
  - Add runtime file sink type and ability to set file sink, per-sink minimum levels, debugger-console minimum level, and startup debug flag.
  - Change default in-memory/file logging levels handling and improve sink dispatching.
- Update client_state to use new settings, add detailed UI menu item descriptions, track settingsDirty/settingsChanged, expose xemu console logging level, and restructure create_initial_state to explicit member initialization.
- Update run-xemu.sh to add environment flags controlling xemu serial stdio and to include serial device args conditionally.
- Update CMake includes for tomlplusplus and adjust logging/log_file storage path resolution to use new storage helpers.
- Add startup debug logger files and tests for settings/logging components; add third-party/tomlplusplus submodule.

These changes add user-configurable TOML settings, improve observability during startup and runtime, and enable mirrored logging to xemu's serial console.
Remove separate global_logger and startup_debug modules and move their functionality into logger.{h,cpp}. Introduces process-wide logger management and convenience logging APIs (set_global_logger, log/trace/debug/info/warn/error, set_minimum_level, set_file_sink, set_file_minimum_level, set_debugger_console_minimum_level, set_startup_debug_enabled, snapshot, format_startup_console_line, startup console enable/print helpers). Replace uses of logging::logger proxy and StartupConsoleStyle with the new logging::* free functions and LogLevel-based startup console functions across main, splash, startup, ui and tests. Add internal g_globalLogger and startup-console state, and NXDK-aware startup console printing. Update includes to use logger.h and tidy up related tests.
Break up large command and app-list functions into focused helper routines. Extracted modal helpers (close_modal_and_mark_closed, per-modal handlers, handle_modal_activation) and host/app action helpers (request_host_pairing, delete_selected_host, collect_deleted_host_cover_art_keys). Reworked apply_app_list_result into smaller pieces (find_app_list_result_host, merge_host_app_records, apply_unpaired_app_list_failure, apply_cached_app_list_failure, restore_selected_app_after_refresh) and tightened null/update checks. Also modularized UI command handling (overlay, add-host keypad, settings, hosts, apps) to improve readability and maintainability with no intended behavioral changes.
Group related ClientState fields into nested substructures (hosts, apps, shell, settings, persistence, navigation, requests) and update all usages accordingly. Moves host list into hosts.items and renames numerous fields (e.g. activeHost -> hosts.active, activeScreen -> shell.activeScreen, statusMessage -> shell.statusMessage, hostsDirty -> hosts.dirty, logViewer* and savedFiles into settings.*, pairingResetEndpoints into hosts.pairingResetEndpoints). Also adapts AppUpdate fields to new namespaces (navigation/requests/persistence) and updates related logic and tests to match the new layout.
Integrate nanosvg to rasterize SVG assets to requested pixel bounds and make asset texture caching size-aware. Adds helpers: build_asset_texture_cache_key, calculate_fitted_dimensions and load_svg_surface_from_asset; load_texture_from_asset now optionally rasterizes SVGs when max dimensions are provided. The asset cache keys include raster dimensions and failed-key tracking was updated accordingly; load_cached_asset_texture and render_asset_icon were updated to pass requested bounds. Removed the dedicated titleLogoTexture field and its load/destroy calls in favor of rendering the logo via the asset cache. Also updates several SVG icon assets with revised vector art.
Add Doxygen-style @file and @brief header comments to numerous source, header and test files across the codebase to improve documentation and readability. These are non-functional changes intended to aid tooling (e.g. Doxygen) and developer comprehension; no logic or API behavior was modified.
@ReenigneArcher ReenigneArcher force-pushed the feat/initial-implementation branch from 2c7bd74 to aebf7e4 Compare April 17, 2026 23:26
Make the pairing flow expose generated PINs immediately by setting PairingStage to pin_ready and updating status text. Remove the pre-check that aborted background pairing when reachability wasn't confirmed and use app::effective_host_port for pairing attempts. Update shell UI messaging accordingly. Adjust and extend unit tests to match the new behavior and add coverage for input mappings, host pairing parsing/validation, address resolution, and runtime network status handling.
Introduce a HostPairingHttpTestHandler and associated request/response structs to allow tests to script and intercept host-pairing HTTP/TLS exchanges. Add global test handler (g_host_pairing_http_test_handler) and set/clear functions, and wire the handler into host_pairing's transport path to short-circuit real network calls when present. Refinement: improve pairing failure message construction to preserve meaningful details. Add comprehensive unit tests and test helpers (scripted exchanges, crypto helpers, scoped handler) to validate pairing, server-info, app-list and asset flows. Also include necessary <functional> and OpenSSL utilities for the new tests.
Delete two documentation files that are no longer needed: docs/sunshine-pairing-research.md and docs/working-client-plan.md. These removals clean up outdated design notes and planning artifacts from the repository.
Add and expand unit tests across the codebase to improve coverage and validate edge cases. Highlights:

- Add many new tests in tests/unit/app/* to cover connection test handling, pairing validation and flow, host/app context actions, settings placeholder activation, confirmation modal behavior, saved files and status clearing; also adjust path literals to raw string form for Windows paths.
- Add tests in tests/unit/host_records_test.cpp to validate display name restrictions, percent-encoding of cached app fields, matching endpoints against resolved http/https ports, port parsing, and stable enum string names.
- Extend settings storage tests to cover missing files, mixed-case logging values, cleanup of unknown/legacy keys, and parse/type error warnings.
- Add logging tests for reading unterminated log files, runtime file sink path accessor, formatting helpers, additional sink minimum-level behavior, zero-capacity fallback, and startup console helpers; also introduce write_raw_text_file helper.
- Add a new tests/unit/platform/filesystem_utils_test.cpp covering path joining, parent/file name helpers, directory creation, file size checks, and prefix comparisons (platform-specific behavior).
- Extend startup tests (client identity, cover art cache, saved files) to trim trailing newlines, warn on missing cert/key, save/load nested cover art, build cache keys, list nested cover-art files, and validate delete behavior for empty paths.
- Update UI shell view tests for rendering saved file sizes, app badges, port keypad display, pair-host reachability messages, and overlay fallback text; adjust expectations where extra body lines are present.

Also add small test helpers (write_text_file / write_raw_text_file) and minor test adjustments to reflect expected UI/content changes. These changes are focused on tests only and do not modify production logic.
Replace the global test handler with a function-scoped static (host_pairing_http_test_handler) and update callers to use it, avoiding the previous global g_host_pairing_http_test_handler. Convert test utilities and data paths to use std::byte-based buffers and helper converters for OpenSSL interop (openssl_bytes), update hex encoding/decoding to use std::from_chars, and add helpers (filled_bytes, sequential_bytes). Consolidate repeated scripted pairing request logic into handle_short_challenge_pairing_request and handle_successful_pairing_request handlers and add make_host_pairing_http_test_handler to simplify test setup. Also change a couple of test helpers to accept std::string_view for content and adjust scripts/run-xemu.sh to assign then export APPDATA/LOCALAPPDATA in separate steps.
Replace unsafe reinterpret_cast helpers with explicit conversion functions between std::byte and unsigned char for OpenSSL calls, and update functions (sha256_digest, aes_128_ecb_encrypt, sign_sha256_hex) to use those conversions. Simplify hex encoding/decoding to avoid C-style arrays and from_chars pointer issues. Introduce SuccessfulPairingScriptContext to bundle pairing test parameters and update handle_successful_pairing_request and its test usage accordingly. Also use an if-init statement for the HostPairingHttpTestHandler lookup in host_pairing.cpp for clearer scoping. These changes improve safety, clarity, and correctness of the tests and OpenSSL interactions.
Improve GetOpenSSL.cmake by normalizing variable names and adding shell helper functions: _moonlight_shell_quote and _moonlight_join_shell_command to safely quote and join arguments for shell/MSYS2 use. _moonlight_to_msys_path was adjusted to use the new normalized variable names. Rename the common-dependencies macro to MOONLIGHT_PREPARE_COMMON_DEPENDENCIES (and update its invocation in xbox-build.cmake) to standardize naming and clarify intent.
@ReenigneArcher ReenigneArcher marked this pull request as ready for review April 18, 2026 14:48
Split and reorganize MSYS2 detection logic in cmake/msys2.cmake into smaller helper functions. Centralized caching of MOONLIGHT_MSYS2_ROOT via _moonlight_set_detected_msys2_root and added helpers to build candidate lists (_moonlight_get_configured_msys2_root_candidates, _moonlight_get_default_msys2_root_candidates), to try candidate roots (_moonlight_try_msys2_root_candidates), to probe from given tool paths (_moonlight_try_msys2_root_from_tools), to probe PATH for common tools (_moonlight_try_msys2_root_from_path_tools), and to check hinted installation roots (_moonlight_try_hinted_msys2_root). The main moonlight_detect_windows_msys2_root was rewritten to orchestrate these helpers and keep behavior while cleaning up responsibility and removing duplicated cache writes. Also minor formatting change in tests/CMakeLists.txt to wrap the fatal error message across lines for readability.
@ReenigneArcher ReenigneArcher force-pushed the feat/initial-implementation branch from cc39917 to e25ea15 Compare April 18, 2026 15:01
@sonarqubecloud
Copy link
Copy Markdown

@ReenigneArcher ReenigneArcher merged commit 828e766 into master Apr 18, 2026
17 checks passed
@ReenigneArcher ReenigneArcher deleted the feat/initial-implementation branch April 18, 2026 15:20
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.

2 participants