From 8ebe501f341f845d70705f67468b1b3b396795b3 Mon Sep 17 00:00:00 2001 From: The412Banner Date: Sat, 26 Sep 2026 15:03:42 -0400 Subject: [PATCH] shadPS4: build SDL's Wayland video driver The ARM64 core's build script turns SDL's Wayland driver off, so on the desktop shadPS4 could only reach labwc through Xwayland ("wayland not available"). Patch it back on (libdecor off, loaded at run time like X11), install the arm64 Wayland/EGL/xkbcommon headers and the host wayland-scanner, and check both drivers made it into SDL's config. AppRun picks the driver: X11 inside gamescope (GAMESCOPE_WAYLAND_DISPLAY), Wayland when a compositor is there (the desktop), and leaves an explicit SDL_VIDEODRIVER alone, so game sessions keep today's path. --- tools/shadps4/build-in-debian.sh | 16 +++++++++++- .../0002-sdl-wayland-video-driver.patch | 26 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 tools/shadps4/patches/0002-sdl-wayland-video-driver.patch diff --git a/tools/shadps4/build-in-debian.sh b/tools/shadps4/build-in-debian.sh index d324c9764b..5388bbeebf 100755 --- a/tools/shadps4/build-in-debian.sh +++ b/tools/shadps4/build-in-debian.sh @@ -13,7 +13,8 @@ export DEBIAN_FRONTEND=noninteractive dpkg --add-architecture arm64 apt-get update # The Bachata runtime's cross set, plus PulseAudio and ALSA headers so SDL3 builds its audio -# drivers (it loads them at run time; the runtime plays through PulseAudio). +# drivers (it loads them at run time; the runtime plays through PulseAudio), and the Wayland, EGL +# and xkbcommon headers with the host's wayland-scanner so it builds its Wayland video driver. apt-get install -y --no-install-recommends \ ca-certificates git curl xz-utils zstd file pkg-config dpkg-dev squashfs-tools \ cmake ninja-build clang llvm lld gcc g++ make \ @@ -22,6 +23,7 @@ apt-get install -y --no-install-recommends \ libvulkan-dev libc6-dev \ libx11-dev:arm64 libxext-dev:arm64 libudev-dev:arm64 uuid-dev:arm64 \ libpulse-dev:arm64 libasound2-dev:arm64 \ + libwayland-dev:arm64 libegl-dev:arm64 libxkbcommon-dev:arm64 libwayland-bin \ libc6:arm64 libgcc-s1:arm64 libstdc++6:arm64 libvulkan1:arm64 libudev1:arm64 libuuid1:arm64 \ libx11-6:arm64 libxext6:arm64 git config --global --add safe.directory '*' @@ -50,6 +52,9 @@ cat "$SRC/runtime/build/shadps4-arm64-stage/needed.txt" # SDL3 found the audio drivers the runtime needs. grep -E 'SDL_AUDIO_DRIVER_(PULSEAUDIO|ALSA)' "$SRC"/runtime/build/shadps4-arm64/externals/sdl3/include-config-release/build_config/SDL_build_config.h grep -q '#define SDL_AUDIO_DRIVER_PULSEAUDIO 1' "$SRC"/runtime/build/shadps4-arm64/externals/sdl3/include-config-release/build_config/SDL_build_config.h +# ... and both video drivers: X11 under gamescope, Wayland on the desktop. +grep -q '#define SDL_VIDEO_DRIVER_WAYLAND 1' "$SRC"/runtime/build/shadps4-arm64/externals/sdl3/include-config-release/build_config/SDL_build_config.h +grep -q '#define SDL_VIDEO_DRIVER_X11 1' "$SRC"/runtime/build/shadps4-arm64/externals/sdl3/include-config-release/build_config/SDL_build_config.h # The patch is in. grep -aq 'BACHATA_MANAGED' "$BIN" @@ -62,7 +67,16 @@ cat > "$APPDIR/AppRun" <<'RUN' # Big Picture game list instead of a usage box. # The first time, the ROMs folder's ps4 folder (any case) is added to its game folders so the # list is not empty; a folder the player removes later stays removed. +# Under gamescope (a game session) it stays on gamescope's X server; on the desktop it draws +# through the compositor's Wayland directly. An SDL_VIDEODRIVER already set wins. HERE=$(dirname "$(readlink -f "$0")") +if [ -z "$SDL_VIDEODRIVER" ]; then + if [ -n "$GAMESCOPE_WAYLAND_DISPLAY" ]; then + export SDL_VIDEODRIVER=x11 + elif [ -n "$WAYLAND_DISPLAY" ]; then + export SDL_VIDEODRIVER=wayland + fi +fi if [ $# -eq 0 ]; then MARK="${XDG_DATA_HOME:-$HOME/.local/share}/shadPS4/.droiddeck-games-folder" if [ ! -e "$MARK" ]; then diff --git a/tools/shadps4/patches/0002-sdl-wayland-video-driver.patch b/tools/shadps4/patches/0002-sdl-wayland-video-driver.patch new file mode 100644 index 0000000000..25671ebed9 --- /dev/null +++ b/tools/shadps4/patches/0002-sdl-wayland-video-driver.patch @@ -0,0 +1,26 @@ +diff --git a/runtime/scripts/build-shadps4-arm64.sh b/runtime/scripts/build-shadps4-arm64.sh +index 8739b7a..49c35fa 100644 +--- a/runtime/scripts/build-shadps4-arm64.sh ++++ b/runtime/scripts/build-shadps4-arm64.sh +@@ -98,7 +98,8 @@ cmake -S "$project_root" -B "$build_dir" -G Ninja \ + -DSDL_X11_XSHAPE=OFF \ + -DSDL_X11_XSYNC=OFF \ + -DSDL_X11_XTEST=OFF \ +- -DSDL_WAYLAND=OFF ++ -DSDL_WAYLAND=ON \ ++ -DSDL_WAYLAND_LIBDECOR=OFF + + sdl_config="$build_dir/externals/sdl3/include-config-release/build_config/SDL_build_config.h" + if ! grep -Fq '#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "libXext.so.6"' "$sdl_config"; then +@@ -106,6 +107,11 @@ if ! grep -Fq '#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "libXext.so.6"' "$sdl_c + exit 1 + fi + ++if ! grep -Fq '#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC "libwayland-client.so.0"' "$sdl_config"; then ++ echo "ARM64 SDL3 requires dynamic Wayland support; install libwayland-dev:arm64, libegl-dev:arm64 and libxkbcommon-dev:arm64" >&2 ++ exit 1 ++fi ++ + cmake --build "$build_dir" --target shadps4 + + test -f "$binary"