Skip to content

Commit 828e766

Browse files
feat: initial implementation (#160)
1 parent cb3c38c commit 828e766

128 files changed

Lines changed: 22635 additions & 260 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/copilot-instructions.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@ You need to prefix commands with `C:\msys64\msys2_shell.cmd -defterm -here -no-s
33

44
Prefix build directories with `cmake-build-`.
55

6+
The xbox build uses Unix Makefiles.
7+
8+
The host native tests will use MinGW Makefiles on Windows, but Unix Makefiles on other platforms.
9+
610
The project uses gtest as a test framework.
711

12+
Always add or update doxygen documentation.
13+
14+
The project requires that everything be documented in doxygen or the build will fail.
15+
16+
Primary doxygen comments should be done like so:
17+
18+
```cpp
19+
/**
20+
* @brief Describe the function, structure, etc.
21+
*
22+
* @param my_param Describe the parameter.
23+
* @return Describe the return.
24+
*/
25+
```
26+
27+
Inline doxygen comments should use `///< ...` instead of `/**< ... */`.
28+
829
Always follow the style guidelines defined in .clang-format for c/c++ code.

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,15 @@ jobs:
103103
update: true
104104
install: >-
105105
bison
106-
cmake
107106
flex
108107
git
109108
make
109+
mingw-w64-x86_64-cmake
110110
mingw-w64-x86_64-clang
111111
mingw-w64-x86_64-gcc
112112
mingw-w64-x86_64-lld
113113
mingw-w64-x86_64-llvm
114+
mingw-w64-x86_64-make
114115
115116
- name: Setup python
116117
id: setup-python

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,8 @@ cmake-*/
4343
.local/
4444
docs/doxyconfig*
4545

46+
# test output
47+
test-output/
48+
4649
# Temporary files
4750
*.cmd~

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@
1616
[submodule "third-party/openssl"]
1717
path = third-party/openssl
1818
url = https://github.com/openssl/openssl.git
19+
branch = OpenSSL_1_1_1-stable
20+
[submodule "third-party/tomlplusplus"]
21+
path = third-party/tomlplusplus
22+
url = https://github.com/marzer/tomlplusplus.git
1923
branch = master

.run/docs.run.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="docs" type="CMakeRunConfiguration" factoryName="Application" PROGRAM_PARAMS="&quot;file:\\$CMakeCurrentBuildDir$\build\html\index.html&quot;" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="Moonlight" TARGET_NAME="docs" CONFIG_NAME="nxdk-release (mingw64)" RUN_PATH="$PROJECT_DIR$/../../../../../Windows/explorer.exe">
3+
<method v="2">
4+
<option name="com.jetbrains.cidr.execution.CidrBuildBeforeRunTaskProvider$BuildBeforeRunTask" enabled="true" />
5+
</method>
6+
</configuration>
7+
</component>

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ cmake_minimum_required(VERSION 3.18)
55

66
# Allow third-party subdirectories that use cmake_minimum_required < 3.5 (removed in CMake 4.x)
77
set(CMAKE_POLICY_VERSION_MINIMUM 3.5 CACHE STRING "")
8+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Export compile commands for IDE tooling" FORCE)
89

910
set(MOONLIGHT_BUILD_KIND "HOST" CACHE STRING "Internal Moonlight build mode")
1011
set_property(CACHE MOONLIGHT_BUILD_KIND PROPERTY STRINGS HOST XBOX)
@@ -51,12 +52,14 @@ option(BUILD_XBOX "Build the Xbox target through an internal child configure" ON
5152
option(MOONLIGHT_FORCE_NXDK_DISTCLEAN "Force a fresh nxdk distclean during configure" OFF)
5253

5354
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/sources.cmake")
55+
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/moonlight-dependencies.cmake")
5456

5557
if(BUILD_DOCS)
5658
add_subdirectory(third-party/doxyconfig docs)
5759
endif()
5860

5961
if(BUILD_TESTS)
62+
moonlight_prepare_common_dependencies()
6063
enable_testing()
6164
add_subdirectory(tests)
6265
endif()

CMakePresets.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,40 @@
3434
"cacheVariables": {
3535
"CMAKE_BUILD_TYPE": "Debug"
3636
}
37+
},
38+
{
39+
"name": "xbox-release (mingw64)",
40+
"displayName": "Xbox Release (mingw64)",
41+
"description": "Direct nxdk Xbox configure for IDE/code-model support on Xbox-only sources",
42+
"generator": "Unix Makefiles",
43+
"toolchainFile": "${sourceDir}/third-party/nxdk/share/toolchain-nxdk.cmake",
44+
"binaryDir": "${sourceDir}/cmake-build-xbox-release",
45+
"environment": {
46+
"CHERE_INVOKING": "1",
47+
"MSYSTEM": "MINGW64",
48+
"NXDK_DIR": "${sourceDir}/third-party/nxdk"
49+
},
50+
"cacheVariables": {
51+
"BUILD_DOCS": "OFF",
52+
"CMAKE_BUILD_TYPE": "Release",
53+
"CMAKE_DEPENDS_USE_COMPILER": "FALSE",
54+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
55+
"CMAKE_MAKE_PROGRAM": "C:/msys64/usr/bin/make.exe",
56+
"CMAKE_TRY_COMPILE_TARGET_TYPE": "STATIC_LIBRARY",
57+
"MOONLIGHT_BUILD_KIND": "XBOX",
58+
"MOONLIGHT_SKIP_NXDK_PREP": "ON",
59+
"NXDK_DIR": "${sourceDir}/third-party/nxdk"
60+
}
61+
},
62+
{
63+
"name": "xbox-debug (mingw64)",
64+
"displayName": "Xbox Debug (mingw64)",
65+
"description": "Direct nxdk Xbox configure for IDE/code-model support on Xbox-only sources",
66+
"inherits": "xbox-release (mingw64)",
67+
"binaryDir": "${sourceDir}/cmake-build-xbox-debug",
68+
"cacheVariables": {
69+
"CMAKE_BUILD_TYPE": "Debug"
70+
}
3771
}
3872
],
3973
"buildPresets": [
@@ -44,6 +78,14 @@
4478
{
4579
"name": "nxdk-debug (mingw64)",
4680
"configurePreset": "nxdk-debug (mingw64)"
81+
},
82+
{
83+
"name": "xbox-release (mingw64)",
84+
"configurePreset": "xbox-release (mingw64)"
85+
},
86+
{
87+
"name": "xbox-debug (mingw64)",
88+
"configurePreset": "xbox-debug (mingw64)"
4789
}
4890
]
4991
}

README.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77

88
Port of Moonlight for the Original Xbox. Unlikely to ever actually work. Do NOT use!
99

10-
Nothing works, except the splash screen.
10+
> [!WARNING]
11+
> Streaming does not work yet.
1112
12-
![Splash Screen](./docs/images/loading.png)
13+
![Splash Screen](./docs/images/screenshots/01-splash.png)
14+
![Hosts Screen](./docs/images/screenshots/02-hosts.png)
15+
![Apps Screen](./docs/images/screenshots/03-apps.png)
1316

1417

1518
## Build
@@ -33,14 +36,15 @@ Nothing works, except the splash screen.
3336
pacman -Syu
3437
nxdk_dependencies=(
3538
"bison"
36-
"cmake"
3739
"flex"
3840
"git"
3941
"make"
42+
"mingw-w64-x86_64-cmake"
4043
"mingw-w64-x86_64-clang"
4144
"mingw-w64-x86_64-gcc"
4245
"mingw-w64-x86_64-lld"
4346
"mingw-w64-x86_64-llvm"
47+
"mingw-w64-x86_64-make"
4448
)
4549
moonlight_dependencies=(
4650
"mingw-w64-x86_64-doxygen"
@@ -188,6 +192,10 @@ If you only want the emulator without the ROM/HDD support bundle, run:
188192
scripts\setup-xemu.cmd --skip-support-files
189193
```
190194

195+
> [!NOTE]
196+
> You can set Xemu to use widescreen mode by using https://github.com/Ernegien/XboxEepromEditor
197+
> but 1080i does not work in Xemu.
198+
191199
## Todo
192200

193201
- Build
@@ -204,18 +212,19 @@ scripts\setup-xemu.cmd --skip-support-files
204212
- [x] Enable sonarcloud
205213
- [x] Build moonlight-common-c
206214
- [x] Build custom enet
215+
- [x] Docs via doxygen
207216
- Menus / Screens
208217
- [x] Loading/splash screen
209218
- [x] Initial loading screen, see https://github.com/XboxDev/nxdk/blob/master/samples/sdl_image/main.c
210219
- [x] Set video mode based on the best available mode
211220
- [x] dynamic splash screen (size based on current resolution)
212221
- [x] simplify (draw background color and overlay logo) to reduce total size
213-
- [ ] Main/Home
214-
- [ ] Settings
215-
- [ ] Add Host
216-
- [ ] Game/App Selection
217-
- [ ] Host Details
218-
- [ ] App Details
222+
- [x] Main/Home
223+
- [x] Settings
224+
- [x] Add Host
225+
- [x] Game/App Selection
226+
- [x] Host Details
227+
- [x] App Details
219228
- [ ] Pause/Hotkey overlay
220229
- Streaming
221230
- [ ] Video - https://www.xbmc4xbox.org.uk/wiki/XBMC_Features_and_Supported_Formats#Xbox_supported_video_formats_and_resolutions
@@ -230,10 +239,9 @@ scripts\setup-xemu.cmd --skip-support-files
230239
- [ ] Mouse Input
231240
- [ ] Mouse Emulation via Gamepad
232241
- Misc.
233-
- [ ] Save config and pairing states, probably use nlohmann/json
234-
- [ ] Host pairing
242+
- [x] Save config and pairing states
243+
- [x] Host pairing
235244
- [ ] Possibly, GPU overclocking, see https://github.com/GXTX/XboxOverclock
236-
- [x] Docs via doxygen
237245

238246
<details style="display: none;">
239247
<summary></summary>

build.sh

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,32 @@ if [[ "${CLEAN_BUILD}" -eq 1 ]]; then
6363
rm -rf "${BUILD_DIR_PATH}"
6464
fi
6565

66-
cmake \
67-
-S . \
68-
-B "${BUILD_DIR_PATH}" \
69-
-DBUILD_DOCS=OFF \
70-
-DBUILD_TESTS=ON \
71-
-DBUILD_XBOX=ON \
72-
-DCMAKE_DEPENDS_USE_COMPILER=FALSE \
66+
cmake_configure_args=(
67+
-S .
68+
-B "${BUILD_DIR_PATH}"
69+
-DBUILD_DOCS=OFF
70+
-DBUILD_TESTS=ON
71+
-DBUILD_XBOX=ON
72+
-DCMAKE_DEPENDS_USE_COMPILER=FALSE
7373
-DCMAKE_BUILD_TYPE=Release
74+
)
75+
76+
case "$(uname -s)" in
77+
MINGW*|MSYS*|CYGWIN*)
78+
if ! cmake --help 2>/dev/null | grep -q "MinGW Makefiles"; then
79+
echo "Windows builds require a CMake that supports MinGW Makefiles. Install the MSYS2 package 'mingw-w64-x86_64-cmake'."
80+
exit 1
81+
fi
82+
83+
cmake_configure_args+=(
84+
-G "MinGW Makefiles"
85+
-DCMAKE_TOOLCHAIN_FILE="${PROJECT_ROOT}/cmake/host-mingw64-clang.cmake"
86+
)
87+
;;
88+
*)
89+
;;
90+
esac
91+
92+
cmake "${cmake_configure_args[@]}"
7493

7594
cmake --build "${BUILD_DIR_PATH}"

cmake/modules/FindNXDK.cmake

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,6 @@ if(NOT TARGET NXDK::NXDK)
6262
IMPORTED_LOCATION "${NXDK_DIR}/lib/winmm.lib"
6363
)
6464

65-
add_library(ws2_32 STATIC IMPORTED)
66-
set_target_properties(
67-
ws2_32
68-
PROPERTIES
69-
IMPORTED_LOCATION "${NXDK_DIR}/lib/ws2_32.lib"
70-
)
71-
7265
add_library(xboxrt STATIC IMPORTED)
7366
set_target_properties(
7467
xboxrt
@@ -130,17 +123,3 @@ if (NOT TARGET NXDK::Net)
130123
"${NXDK_DIR}/lib/net/nvnetdrv"
131124
)
132125
endif ()
133-
134-
if (NOT TARGET NXDK::ws2_32)
135-
add_library(NXDK::ws2_32 INTERFACE IMPORTED)
136-
target_link_libraries(
137-
NXDK::ws2_32
138-
INTERFACE
139-
ws2_32
140-
)
141-
target_include_directories(
142-
NXDK::ws2_32
143-
SYSTEM INTERFACE
144-
"${NXDK_DIR}/lib/winapi/ws2_32"
145-
)
146-
endif ()

0 commit comments

Comments
 (0)