Skip to content

feat: initial implementation#160

Draft
ReenigneArcher wants to merge 26 commits intomasterfrom
feat/initial-implementation
Draft

feat: initial implementation#160
ReenigneArcher wants to merge 26 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 49.98940% with 2358 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.16%. Comparing base (a6e416a) to head (2c7bd74).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/network/host_pairing.cpp 20.19% 943 Missing and 140 partials ⚠️
src/app/client_state.cpp 62.01% 305 Missing and 199 partials ⚠️
src/ui/shell_view.cpp 57.17% 78 Missing and 125 partials ⚠️
src/app/host_records.cpp 70.89% 47 Missing and 47 partials ⚠️
src/logging/logger.cpp 60.81% 68 Missing and 19 partials ⚠️
src/app/settings_storage.cpp 57.84% 52 Missing and 34 partials ⚠️
src/startup/saved_files.cpp 57.54% 20 Missing and 25 partials ⚠️
src/startup/client_identity_storage.cpp 51.16% 25 Missing and 17 partials ⚠️
src/logging/log_file.cpp 49.35% 26 Missing and 13 partials ⚠️
src/platform/filesystem_utils.cpp 60.86% 12 Missing and 15 partials ⚠️
... and 17 more

❗ There is a different number of reports uploaded between BASE (a6e416a) and HEAD (2c7bd74). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (a6e416a) HEAD (2c7bd74)
Windows 1 0
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #160       +/-   ##
===========================================
- Coverage   61.40%   50.16%   -11.24%     
===========================================
  Files           2       30       +28     
  Lines          57     4764     +4707     
  Branches       13     2123     +2110     
===========================================
+ Hits           35     2390     +2355     
- Misses         15     1686     +1671     
- Partials        7      688      +681     
Flag Coverage Δ
Linux 49.98% <49.80%> (-11.42%) ⬇️
Windows ?
macOS 40.73% <40.40%> (-20.67%) ⬇️

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

Files with missing lines Coverage Δ
src/splash/splash_layout.cpp 92.85% <100.00%> (ø)
src/startup/saved_files.h 100.00% <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%> (ø)
src/network/runtime_network.h 0.00% <0.00%> (ø)
src/platform/error_utils.h 75.00% <75.00%> (ø)
src/ui/menu_model.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 a6e416a...2c7bd74. 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
@ReenigneArcher ReenigneArcher force-pushed the feat/initial-implementation branch 2 times, most recently from 2cdaed4 to e727743 Compare April 14, 2026 01:53
Introduce client-side UI and state management plus extensive build and platform adjustments for Xbox/nxdk.

Key changes:
- Add app UI/state implementation (src/app/*), pairing, host records, networking, startup, logging, input navigation, streaming overlay, and many UI components.
- Add compatibility shims for OpenSSL and moonlight-common-c, plus new FindNXDK_SDL2_TTF CMake module and font/logo assets.
- Add many unit tests covering app, input, logging, network, startup and UI components (tests/unit/*).
- Update CMake build: enable export of compile commands, add xbox mingw64 CMake presets, register SDL2_TTF, include libxboxrt, and pass compat header into moonlight-common-c build.
- Revise GetOpenSSL: pin OpenSSL to 1.1.1w, add platform-aware configure/build logic for HOST vs XBOX, set configure options and env vars, and link host system libs when appropriate.
- Small cmake/source tweaks: exclude shell_screen from host tests, export compile commands for child builds, and link NXDK::Net into ws2_32 target.
- Enhance run-xemu scripts to support network mode and TAP interface, to propagate XEMU-related environment paths, and to include network args when launching xemu.
- Update .gitmodules to track OpenSSL OpenSSL_1_1_1-stable branch and update third-party/openssl submodule reference.

These changes add core UI/state functionality and platform-specific build/tooling to support building and running on Xbox (nxdk) and improve host-side OpenSSL vendoring. Some new files are large and introduce the initial app logic and tests.
Provide NXDK-specific compatibility for OpenSSL and sockets: add src/_nxdk_compat (openssl_compat.h, poll_compat.cpp, stat_compat.cpp), remove legacy openssl compat files, and wire them into CMake (include dirs, build/install commands, and source list changes). Refactor host_pairing to be cross-platform (NXDK vs Winsock): unify socket error handling, non-blocking connect helper, timeouts, TLS connect error reporting, serverinfo path construction with uniqueId, and ensure socket initialization works on NXDK. Minor UI text cleanups and include stat_compat.cpp in the final executable. Also update third-party submodule pins for moonlight-common-c and nxdk.
Introduce the first M0 client shell and supporting infrastructure: structured in-memory logging (logger + log_file), controller/keyboard input mapping, retained menu model, host records and pairing flow scaffolding, saved files and cover art cache, startup memory/video utilities, and UI state management (client_state). Adds grid/modal navigation, add-host keypad, apps view, log viewer, and many unit tests and icon assets. Also includes various refactors and helpers for host/app selection, scrolling, and menu rebuilding to enable further work on pairing, streaming and Xbox runtime integration.
Record and handle data cleanup when hosts are deleted: add pairingResetEndpoints to ClientState and new AppUpdate fields to request host-delete cleanup and carry deleted host metadata (address, port, paired flag, cover art keys). Implement helpers to remember/clear deleted host pairing and to check host_requires_manual_pairing, and clear these records when a host is successfully re-paired.

Add startup APIs to delete persisted client identity and cached cover art (delete_client_identity, delete_cover_art) with basic error reporting. Wire a delete_host_data_if_requested flow that removes cached cover art, clears texture cache, and resets the shared client identity if no paired hosts remain, updating status messages accordingly.

Improve settings/menu synchronization (sync_selected_settings_category_from_menu, rebuild_settings_detail_menu) and adjust UI rendering for the menu/options/detail layout and visuals. Simplify SVG asset handling and texture creation (use SDL scale hint for quality), and swap footer action icons for Exit in the view model.

Update many SVG icon assets to remove text parameters (nanosvg limitation) and tweak visuals, add xbe/assets README, and extend unit tests to cover host deletion/pairing cleanup, client identity deletion, and cover art deletion. Also mark several README features as completed.
Add verbose startup debug logging and encoder diagnostics, and harden video mode selection and UI layout for widescreen/HD scenarios.

- main.cpp: introduce debug_print_* helpers, log XVideoGetEncoderSettings, XVideoSetMode result, SDL initialization/window creation, and startup task lifecycle for easier diagnostics.
- splash: always apply aspect correction when framebuffer vs display aspect differs; add calculate_display_width() to compute logical UI width based on effective display aspect (header and implementation), and adjust logo scaling logic.
- ui/shell_screen: query encoder settings, compute logical screen width via calculate_display_width, apply horizontal SDL renderer scaling to render square-pixel UI, and restore scale after presenting.
- startup/video_mode: prefer 720p progressive over 1080i interlaced when both are available; add helper is_1080i and update selection logic.
- tests: add unit tests for the 4:3 correction on HD modes, calculate_display_width behavior, and preferring 720p over 1080i.
- scripts/README: note widescreen tool in README and update run-xemu.sh to set display.ui aspect_ratio = 'native' in generated config.

These changes improve widescreen support, ensure UI layout uses a logical square-pixel width, prefer progressive HD modes for clarity, and make startup video/debug issues easier to diagnose.
Remove the imported ws2_32 target and all NXDK::ws2_32 link usages from CMake (FindNXDK.cmake, xbox-build.cmake, GetOpenSSL.cmake) and link against NXDK::Net instead. Update OpenSSL target linkage to omit ws2_32 on HOST Windows builds. Add lwIP/socket compatibility helpers to src/_nxdk_compat/openssl_compat.h: include lwip/opt.h, sys/time.h and string.h, declare lwip_select, provide defaults for LWIP_SOCKET_OFFSET and FD_SETSIZE (based on MEMP_NUM_NETCONN), and define fd_set plus FD_* macros and a select macro that maps to lwip_select. These changes remove the dependency on WinSock symbols and provide a minimal fd_set/select shim for lwIP on NXDK.
Introduce platform::filesystem utilities and centralize dependency preparation.

- Add src/platform/filesystem_utils.{h,cpp} to provide cross-platform path operations, directory creation, file size checks and prefix checks.
- Replace duplicated path and directory helper code in logging, startup (client_identity_storage, cover_art_cache, host_storage, saved_files) with platform:: APIs and use platform::join_path for consistent path handling.
- Make saved_files and host_pairing more portable: add POSIX directory enumeration and socket handling fallbacks, unify SOCKET handling and non-blocking configuration.
- Improve OpenSSL vendored build: add msys2 support, shell-quoting helpers and platform-specific configure/build commands in cmake/modules/GetOpenSSL.cmake; expose provider/platform info and link ws2_32 for Windows host builds when needed.
- Add cmake/moonlight-dependencies.cmake to prepare common third-party dependencies (moonlight-common-c, OpenSSL, enet) and use it from top-level CMakeLists and xbox-build.cmake.
- Tests: add tests/support/filesystem_test_utils.h and update tests to use it; require prepared Moonlight dependency targets in tests/CMakeLists and link Moonlight::OpenSSL (add ws2_32 on Windows), and add dependency on moonlight-common-c for test target.

These changes reduce duplicated filesystem/platform code, improve portability across Windows/Unix/NXDK, and centralize dependency configuration for builds and tests.
Make Windows/Mingw builds more reliable and surface better logs. CI: install mingw-w64-x86_64-cmake for MinGW CMake support and expand failure debug step to print OpenSSL configure/build logs for host and Xbox builds. build.sh: collect CMake configure args into an array, require a CMake with MinGW Makefiles on Windows, and set the MinGW generator and toolchain file. cmake/modules/GetOpenSSL.cmake: introduce a deterministic external target name, clear Make-related env vars, pass MAKEFLAGS/MFLAGS/GNUMAKEFLAGS/MAKELEVEL and enforce single-job (-j1) builds for Windows/MSYS to avoid parallel build issues; properly map compiler/AR/RANLIB into MSYS2 shell commands; use the new external target name in ExternalProject_Add and add_dependencies; and emit the OpenSSL external target in status messages. cmake/moonlight-dependencies.cmake: conditionally wire moonlight-common-c to the OpenSSL external target when defined and present. These changes improve reproducibility and Windows build stability.
Add Doxygen-style comments across many public headers to document structs, functions, parameters and return values. Updated .github/copilot-instructions.md to require/mention Doxygen documentation. Files touched include openssl_compat.h, client_state.h, host_records.h, pairing_flow.h, log_file.h, logger.h, host_pairing.h, runtime_network.h, client_identity_storage.h, cover_art_cache.h, host_storage.h, saved_files.h, stats_overlay.h, menu_model.h, shell_view.h and a small SVG asset tweak. These comments improve API clarity and help enforce build-time documentation checks.
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 c4b888b to 2c7bd74 Compare April 15, 2026 04:13
@sonarqubecloud
Copy link
Copy Markdown

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