From c183a33a681095c085537886879a4572431abfce Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Tue, 20 Feb 2024 15:48:19 +0100 Subject: [PATCH] Bump version to v1.6 --- .github/workflows/ci.yml | 6 +- Dockerfile | 266 ++---------------------------- README.md | 66 ++++++-- dist/wiiu/apps/moonlight/meta.xml | 12 +- libgamestream/client.c | 2 +- libgamestream/http.c | 2 +- moonlight.conf | 3 + src/config.c | 1 + src/wiiu/wiiu.h | 2 +- 9 files changed, 76 insertions(+), 284 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de5d5135..51fa55b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,15 +4,15 @@ on: [push, pull_request] jobs: build-binary: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: recursive - name: build binary run: | docker run --rm -v ${PWD}:/project garyodernichts/moonlightbuilder make dist - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: moonlight-wiiu path: dist/* diff --git a/Dockerfile b/Dockerfile index c98ab1c6..823622b0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,261 +1,15 @@ -# build wut -FROM devkitpro/devkitppc:20220531 AS wutbuild - -ENV PATH=$DEVKITPPC/bin:$PATH - -WORKDIR / -RUN git clone https://github.com/devkitPro/wut +FROM devkitpro/devkitppc:20240220 + +# build latest wut from source +RUN \ +mkdir wut && \ +cd wut && \ +git init . && \ +git remote add origin https://github.com/devkitPro/wut.git && \ +git fetch --depth 1 origin c1115e51bb16979a04463e2bf2ebc4369a013e67 && \ +git checkout FETCH_HEAD WORKDIR /wut -RUN git checkout f1b5da996f4c4a58beb3d3ab93aa8e8b9f66e775 RUN make -j$(nproc) RUN make install -WORKDIR / - -# set up builder image -FROM devkitpro/devkitppc:20220531 AS builder - -RUN apt-get update && apt-get -y install --no-install-recommends wget tar autoconf automake libtool && rm -rf /var/lib/apt/lists/* -COPY --from=wutbuild /opt/devkitpro/wut /opt/devkitpro/wut - -# build SDL2 -FROM builder AS sdlbuild -ENV WUT_ROOT=$DEVKITPRO/wut - -RUN git clone -b wiiu-2.0.9 --single-branch https://github.com/yawut/SDL -WORKDIR /SDL -RUN mkdir build -WORKDIR /SDL/build - -# Need to set CFLAGS manually for now until issues with SDL and wiiu-cmake get resolved -ENV CFLAGS="-mcpu=750 -meabi -mhard-float -ffunction-sections -fdata-sections -DESPRESSO -D__WIIU__ -D__WUT__ -O3" - -RUN /opt/devkitpro/portlibs/wiiu/bin/powerpc-eabi-cmake .. -DCMAKE_INSTALL_PREFIX=$DEVKITPRO/portlibs/wiiu -DCMAKE_BUILD_TYPE=Release -RUN make -j$(nproc) && make install -WORKDIR / - -# build openssl -FROM builder AS opensslbuild -ARG openssl_ver=1.1.1q - -RUN wget https://www.openssl.org/source/openssl-$openssl_ver.tar.gz && mkdir /openssl && tar xf openssl-$openssl_ver.tar.gz -C /openssl --strip-components=1 -WORKDIR /openssl - -RUN echo 'diff --git a/Configurations/10-main.conf b/Configurations/10-main.conf\n\ -index 61c6689..efe686a 100644\n\ ---- a/Configurations/10-main.conf\n\ -+++ b/Configurations/10-main.conf\n\ -@@ -627,6 +627,27 @@ my %targets = (\n\ - shared_extension => ".so",\n\ - },\n\ - \n\ -+### Wii U target\n\ -+ "wiiu" => {\n\ -+ inherit_from => [ "BASE_unix" ],\n\ -+ CC => "$ENV{DEVKITPPC}/bin/powerpc-eabi-gcc",\n\ -+ CXX => "$ENV{DEVKITPPC}/bin/powerpc-eabi-g++",\n\ -+ AR => "$ENV{DEVKITPPC}/bin/powerpc-eabi-ar",\n\ -+ CFLAGS => picker(default => "-Wall",\n\ -+ debug => "-O0 -g",\n\ -+ release => "-O3"),\n\ -+ CXXFLAGS => picker(default => "-Wall",\n\ -+ debug => "-O0 -g",\n\ -+ release => "-O3"),\n\ -+ LDFLAGS => "-L$ENV{DEVKITPRO}/wut/lib",\n\ -+ cflags => add("-mcpu=750 -meabi -mhard-float -ffunction-sections -fdata-sections"),\n\ -+ cxxflags => add("-std=c++11"),\n\ -+ lib_cppflags => "-DOPENSSL_USE_NODELETE -DB_ENDIAN -DNO_SYS_UN_H -DNO_SYSLOG -D__WIIU__ -D__WUT__ -I$ENV{DEVKITPRO}/wut/include",\n\ -+ ex_libs => add("-lwut -lm"),\n\ -+ bn_ops => "BN_LLONG RC4_CHAR",\n\ -+ asm_arch => '"'"'ppc32'"'"',\n\ -+ },\n\ -+\n ####\n #### Variety of LINUX:-)\n ####\n\ -diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c\n\ -index 0f45251..d303e8e 100644\n\ ---- a/crypto/rand/rand_unix.c\n\ -+++ b/crypto/rand/rand_unix.c\n\ -@@ -202,6 +202,41 @@ void rand_pool_keep_random_devices_open(int keep)\n\ - {\n\ - }\n\ - \n\ -+# elif defined(__WIIU__)\n\ -+\n\ -+#include \n\ -+\n\ -+size_t rand_pool_acquire_entropy(RAND_POOL *pool)\n\ -+{\n\ -+ int i;\n\ -+ size_t bytes_needed;\n\ -+ unsigned char v;\n\ -+\n\ -+ bytes_needed = rand_pool_bytes_needed(pool, 4 /*entropy_factor*/);\n\ -+\n\ -+ for (i = 0; i < bytes_needed; i++) {\n\ -+ srand(OSGetSystemTick());\n\ -+ v = rand() & 0xff;\n\ -+\n\ -+ rand_pool_add(pool, &v, sizeof(v), 2);\n\ -+ }\n\ -+\n\ -+ return rand_pool_entropy_available(pool);\n\ -+}\n\ -+\n\ -+int rand_pool_init(void)\n\ -+{\n\ -+ return 1;\n\ -+}\n\ -+\n\ -+void rand_pool_cleanup(void)\n\ -+{\n\ -+}\n\ -+\n\ -+void rand_pool_keep_random_devices_open(int keep)\n\ -+{\n\ -+}\n\ -+\n # else\n\ - \n # if defined(OPENSSL_RAND_SEED_EGD) && \\\n\ -diff --git a/crypto/uid.c b/crypto/uid.c\n\ -index a9eae36..4a81d98 100644\n\ ---- a/crypto/uid.c\n\ -+++ b/crypto/uid.c\n\ -@@ -10,7 +10,7 @@\n #include \n #include \n\ - \n\ --#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI)\n\ -+#if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_VXWORKS) || defined(OPENSSL_SYS_UEFI) || defined(__WIIU__)\n\ - \n\ - int OPENSSL_issetugid(void)\n\ - {\ -' >> wiiu.patch && git apply wiiu.patch - -RUN ./Configure wiiu \ - no-threads no-shared no-asm no-ui-console no-unit-test no-tests no-buildtest-c++ no-external-tests no-autoload-config \ - --with-rand-seed=os -static - -RUN make build_generated -RUN make libssl.a libcrypto.a -j$(nproc) -WORKDIR / - -# build curl -FROM builder as curlbuild -ARG curl_ver=7.84.0 - -# copy in openssl -COPY --from=opensslbuild /openssl/libcrypto.a /openssl/libssl.a /opt/devkitpro/portlibs/wiiu/lib/ -COPY --from=opensslbuild /openssl/include/openssl /opt/devkitpro/portlibs/wiiu/include/openssl/ -COPY --from=opensslbuild /openssl/include/crypto /opt/devkitpro/portlibs/wiiu/include/crypto/ - -RUN wget https://curl.se/download/curl-$curl_ver.tar.gz && mkdir /curl && tar xf curl-$curl_ver.tar.gz -C /curl --strip-components=1 -WORKDIR /curl - -ENV CFLAGS "-mcpu=750 -meabi -mhard-float -O3 -ffunction-sections -fdata-sections" -ENV CXXFLAGS "${CFLAGS}" -ENV CPPFLAGS "-D__WIIU__ -D__WUT__ -I${DEVKITPRO}/wut/include" -ENV LDFLAGS "-L${DEVKITPRO}/wut/lib" -ENV LIBS "-lwut -lm" - -RUN autoreconf -fi -RUN ./configure \ ---prefix=$DEVKITPRO/portlibs/wiiu/ \ ---host=powerpc-eabi \ ---enable-static \ ---disable-threaded-resolver \ ---disable-pthreads \ ---with-ssl=$DEVKITPRO/portlibs/wiiu/ \ ---disable-ipv6 \ ---disable-unix-sockets \ ---disable-socketpair \ ---disable-ntlm-wb \ -CC=$DEVKITPPC/bin/powerpc-eabi-gcc \ -AR=$DEVKITPPC/bin/powerpc-eabi-ar \ -RANLIB=$DEVKITPPC/bin/powerpc-eabi-ranlib \ -PKG_CONFIG=$DEVKITPRO/portlibs/wiiu/bin/powerpc-eabi-pkg-config - -WORKDIR /curl/lib -RUN make -j$(nproc) install -WORKDIR /curl/include -RUN make -j$(nproc) install -WORKDIR / - -FROM builder as expatbuild -ARG expat_tag=2_4_8 -ARG expat_ver=2.4.8 - -RUN wget https://github.com/libexpat/libexpat/releases/download/R_$expat_tag/expat-$expat_ver.tar.gz && mkdir /expat && tar xf expat-$expat_ver.tar.gz -C /expat --strip-components=1 -WORKDIR /expat - -ENV CFLAGS "-mcpu=750 -meabi -mhard-float -O3 -ffunction-sections -fdata-sections" -ENV CXXFLAGS "${CFLAGS}" -ENV CPPFLAGS "-D__WIIU__ -D__WUT__ -I${DEVKITPRO}/wut/include" -ENV LDFLAGS "-L${DEVKITPRO}/wut/lib" -ENV LIBS "-lwut -lm" - -RUN autoreconf -fi -RUN ./configure \ ---prefix=$DEVKITPRO/portlibs/wiiu/ \ ---host=powerpc-eabi \ ---enable-static \ ---without-examples \ ---without-tests \ ---without-docbook \ -CC=$DEVKITPPC/bin/powerpc-eabi-gcc \ -AR=$DEVKITPPC/bin/powerpc-eabi-ar \ -RANLIB=$DEVKITPPC/bin/powerpc-eabi-ranlib \ -PKG_CONFIG=$DEVKITPRO/portlibs/wiiu/bin/powerpc-eabi-pkg-config - -RUN make -j$(nproc) && make install -WORKDIR / - -FROM builder as opusbuild -ARG opus_ver=1.1.2 - -RUN wget https://github.com/xiph/opus/releases/download/v$opus_ver/opus-$opus_ver.tar.gz && mkdir /opus && tar xf opus-$opus_ver.tar.gz -C /opus --strip-components=1 -WORKDIR /opus - -ENV CFLAGS "-mcpu=750 -meabi -mhard-float -O3 -ffunction-sections -fdata-sections" -ENV CXXFLAGS "${CFLAGS}" -ENV CPPFLAGS "-D__WIIU__ -D__WUT__ -I${DEVKITPRO}/wut/include" -ENV LDFLAGS "-L${DEVKITPRO}/wut/lib" -ENV LIBS "-lwut -lm" - -RUN ./configure \ ---prefix=$DEVKITPRO/portlibs/wiiu/ \ ---host=powerpc-eabi \ ---enable-static \ ---disable-doc \ ---disable-extra-programs \ -CC=$DEVKITPPC/bin/powerpc-eabi-gcc \ -AR=$DEVKITPPC/bin/powerpc-eabi-ar \ -RANLIB=$DEVKITPPC/bin/powerpc-eabi-ranlib \ -PKG_CONFIG=$DEVKITPRO/portlibs/wiiu/bin/powerpc-eabi-pkg-config \ -CFLAGS="$CFLAGS -Wno-expansion-to-defined" -RUN make -j$(nproc) && make install - -# build final container -FROM devkitpro/devkitppc:20220531 AS final - -# copy in wut -COPY --from=wutbuild /opt/devkitpro/wut /opt/devkitpro/wut - -# copy in SDL2 -COPY --from=sdlbuild /opt/devkitpro/portlibs/wiiu/lib/libSDL2.a /opt/devkitpro/portlibs/wiiu/lib/ -COPY --from=sdlbuild /opt/devkitpro/portlibs/wiiu/include/SDL2 /opt/devkitpro/portlibs/wiiu/include/SDL2/ - -# copy in openssl -COPY --from=opensslbuild /openssl/libcrypto.a /openssl/libssl.a /opt/devkitpro/portlibs/wiiu/lib/ -COPY --from=opensslbuild /openssl/include/openssl /opt/devkitpro/portlibs/wiiu/include/openssl/ -COPY --from=opensslbuild /openssl/include/crypto /opt/devkitpro/portlibs/wiiu/include/crypto/ - -# copy in curl -COPY --from=curlbuild /opt/devkitpro/portlibs/wiiu/lib/libcurl.a /opt/devkitpro/portlibs/wiiu/lib/ -COPY --from=curlbuild /opt/devkitpro/portlibs/wiiu/include/curl /opt/devkitpro/portlibs/wiiu/include/curl/ - -# copy in expat -COPY --from=expatbuild /opt/devkitpro/portlibs/wiiu/lib/libexpat.a /opt/devkitpro/portlibs/wiiu/lib/ -COPY --from=expatbuild /opt/devkitpro/portlibs/wiiu/include/expat.h /opt/devkitpro/portlibs/wiiu/include/expat.h -COPY --from=expatbuild /opt/devkitpro/portlibs/wiiu/include/expat_config.h /opt/devkitpro/portlibs/wiiu/include/expat_config.h -COPY --from=expatbuild /opt/devkitpro/portlibs/wiiu/include/expat_external.h /opt/devkitpro/portlibs/wiiu/include/expat_external.h - -# copy in opus -COPY --from=opusbuild /opt/devkitpro/portlibs/wiiu/lib/libopus.a /opt/devkitpro/portlibs/wiiu/lib/ -COPY --from=opusbuild /opt/devkitpro/portlibs/wiiu/include/opus /opt/devkitpro/portlibs/wiiu/include/opus/ WORKDIR /project diff --git a/README.md b/README.md index 05563560..d30a9f2d 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,55 @@ # Moonlight Wii U -Moonlight Wii U is a port of [Moonlight Embedded](https://github.com/moonlight-stream/moonlight-embedded), which is an open source client for [Sunshine](https://github.com/LizardByte/Sunshine) and NVIDIA GameStream. - -Moonlight Wii U allows you to stream your full collection of games from your powerful Windows desktop to your Wii U. +Moonlight Wii U is a port of [Moonlight Embedded](https://github.com/moonlight-stream/moonlight-embedded), which is an open source client for [Sunshine](https://github.com/LizardByte/Sunshine) and NVIDIA GameStream. Moonlight allows you to stream your full collection of games and applications from your PC to other devices to play them remotely. ## Quick Start -* A Wii U LAN Adapter is recommended -* Grab the latest version from the [releases page](https://github.com/GaryOderNichts/moonlight-wiiu/releases) and extract it to the root of your SD Card -* Enter the IP of your GFE server in the `moonlight.conf` file located at `sd:/wiiu/apps/moonlight` -* Ensure your GFE server and Wii U are on the same network -* Turn on Shield Streaming in the GFE settings -* Pair Moonlight Wii U with the GFE server -* Accept the pairing confirmation on your PC -* Connect to the GFE Server with Moonlight Wii U +> :information_source: A Wii U LAN Adapter is recommended! + +* Grab the latest version from the [releases page](https://github.com/GaryOderNichts/moonlight-wiiu/releases) and extract it to the root of your SD Card. +* Enter the IP of your Sunshine/GFE server in the `moonlight.conf` file located at `sd:/wiiu/apps/moonlight`. +* Ensure your Sunshine/GFE server and Wii U are on the same network. +* If using GFE, turn on Shield Streaming in the GFE settings. +* Pair Moonlight Wii U with the server. +* Accept the pairing confirmation on your PC. +* Connect to the server with Moonlight Wii U. * Play games! ## Configuration -You can configure all of the documented settings in the `moonlight.conf` file located at `sd:/wiiu/apps/moonlight`. +You can configure all of the documented settings in the `moonlight.conf` file located at `sd:/wiiu/apps/moonlight`. +Note that a lot of option are commented out by default, to edit them you need to remove the `#` in front of them. ## Supported controllers -* Gamepad (can be disabled with the `disable_gamepad` option) -* Up to 4 Wii U Pro Controllers and Wii Classic Controllers (Pro) - Gamepad needs to be disabled to use the 4th controller +* Gamepad (can be disabled with the `disable_gamepad` option). +* Up to 4 Wii U Pro Controllers and Wii Classic Controllers (Pro). + The Gamepad needs to be disabled to use the 4th controller. + +## Troubleshooting +### Input doesn't work when using Sunshine +Verify that you've installed [Nefarius Virtual Gamepad](https://github.com/nefarius/ViGEmBus/releases/latest) and restarted your PC after the installation. + +### The stream disconnects frequently/immediately +Depending on your network connection you need to adjust the configuration to find a stable bitrate and resolution. +Try something like this to get started: +``` +width = 854 +height = 480 +fps = 30 +``` +``` +bitrate = 1500 +``` +Then slowly increate the bitrate until the stream is no longer stable. + +### Can't find app Steam +Moonlight Wii U tries to start the app "Steam" by default, but sunshine does not have a default Application called "Steam". +You can either rename the app in the `moonlight.conf` to +``` +app = Steam Big Picture +``` +which is a default option in sunshine or add a new application called "Steam" in the sunshine configuration. ## See also @@ -37,7 +62,16 @@ You can configure all of the documented settings in the `moonlight.conf` file lo 3. Send Pull Requests ## Building from source +Install the required dependencies: `(dkp-)pacman -S --needed wiiu-dev wiiu-sdl2 wiiu-curl wiiu-mbedtls ppc-freetype ppc-libopus ppc-libexpat`. +Run `make` to build moonlight. -You can simply build this using the provided Dockerfile. +### Using docker +You can also build moonlight-wiiu using the provided Dockerfile. Use `docker build -t moonlightbuilder .` to build the container. Then use `docker run -it --rm -v ${PWD}:/project moonlightbuilder make` to build moonlight. + +## TODO +- double tap to drag +- gyro support +- rumble +- test with gfe for fun diff --git a/dist/wiiu/apps/moonlight/meta.xml b/dist/wiiu/apps/moonlight/meta.xml index b8a3fa1f..09b2555a 100644 --- a/dist/wiiu/apps/moonlight/meta.xml +++ b/dist/wiiu/apps/moonlight/meta.xml @@ -1,12 +1,12 @@ - Moonlight WiiU + Moonlight Wii U GaryOderNichts - v1.5 - 20221012120000 - A Moonlight port for the Nintendo WiiU - Moonlight Wii U is a port of Moonlight Embedded, which is an open source implementation of NVIDIA's GameStream, as used by the NVIDIA Shield. -Moonlight Wii U allows you to stream your full collection of games from your powerful Windows desktop to your Wii U. + v1.6 + 20240220120000 + A Moonlight port for the Nintendo Wii U + Moonlight Wii U is a port of Moonlight Embedded, which is an open source client for Sunshine and NVIDIA GameStream. +Moonlight allows you to stream your full collection of games and applications from your PC to other devices to play them remotely. Homebrew https://github.com/GaryOderNichts/moonlight-wiiu diff --git a/libgamestream/client.c b/libgamestream/client.c index 69372344..a62c2d9e 100644 --- a/libgamestream/client.c +++ b/libgamestream/client.c @@ -321,7 +321,7 @@ int gs_pair(GS_CLIENT hnd, PSERVER_DATA server, const char *pin) { if (server->currentGame != 0) { ret = GS_WRONG_STATE; - gs_set_error(GS_WRONG_STATE, "The computer is currently in a game. You must close the game before pairing"); + gs_set_error(GS_WRONG_STATE, "The computer is currently in a game.\nYou must close the game before pairing."); goto cleanup; } diff --git a/libgamestream/http.c b/libgamestream/http.c index 50d9846e..3520b4fa 100644 --- a/libgamestream/http.c +++ b/libgamestream/http.c @@ -103,7 +103,7 @@ int http_request(HTTP *http, char *url, HTTP_DATA *data) { goto finish; } assert (data->memory != NULL); - int http_code = 0; + long http_code = 0; curl_easy_getinfo(curl, CURLINFO_HTTP_CODE, &http_code); ret = GS_OK; diff --git a/moonlight.conf b/moonlight.conf index c48706ae..5229670f 100644 --- a/moonlight.conf +++ b/moonlight.conf @@ -1,3 +1,6 @@ +## Moonlight Wii U Configuration +## Lines starting with '#' are comments, to edit an option uncomment it by removing the '#' + ## Hostname or IP-address of host to connect to #address = 1.2.3.4 diff --git a/src/config.c b/src/config.c index 8e4f029a..9b4afb11 100644 --- a/src/config.c +++ b/src/config.c @@ -413,6 +413,7 @@ void config_parse(int argc, char* argv[], PCONFIGURATION config) { #endif #ifdef __WIIU__ + // TODO test how slow audio encryption is config->stream.encryptionFlags = ENCFLG_NONE; config->stream.fps = 30; #endif diff --git a/src/wiiu/wiiu.h b/src/wiiu/wiiu.h index 045ab148..b68c599c 100644 --- a/src/wiiu/wiiu.h +++ b/src/wiiu/wiiu.h @@ -4,7 +4,7 @@ #define _GNU_SOURCE #endif -#define VERSION_STRING "v1.5" +#define VERSION_STRING "v1.6" enum { STATE_INVALID,