mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-26 00:06:02 +00:00
shadPS4: build the ARM64 PS4 emulator as an AppImage
Cross-builds the ARM64 shadPS4 core (FEXCore guest CPU) in Debian trixie with a patch so it runs stand-alone in the runtime: SDL controllers and SDL audio when there is no Android control socket.
This commit is contained in:
1 parent
c950d31960
commit
9a1aee75d5
4 files changed
+246
No files matched your search
@@ -0,0 +1,47 @@
|
|||||||
|
name: Build shadPS4 (ARM64)
|
||||||
|
|
||||||
|
# The PS4 emulator package: the ARM64 shadPS4 core (FEXCore runs the PS4's x86-64 code) from
|
||||||
|
# tools/shadps4/source.env, with tools/shadps4/patches so it runs stand-alone in the runtime (SDL
|
||||||
|
# controllers, PulseAudio), packed as shadps4.AppImage. Published as a release asset the hosted
|
||||||
|
# package catalog points at; the apk does not carry it.
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- 'tools/shadps4/**'
|
||||||
|
- '.github/workflows/build-shadps4.yml'
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
tag:
|
||||||
|
description: 'Release tag to publish as (e.g. shadps4-be6bc2e-p1); empty = artifact only'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-24.04
|
||||||
|
timeout-minutes: 150
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Build in Debian trixie
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
df -h /
|
||||||
|
docker run --rm -v "$PWD:/work" -w /work debian:trixie bash tools/shadps4/build-in-debian.sh
|
||||||
|
sudo chown -R "$(id -u):$(id -g)" .
|
||||||
|
- uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: shadps4-appimage
|
||||||
|
path: |
|
||||||
|
shadps4.AppImage
|
||||||
|
shadps4.AppImage.sha256
|
||||||
|
- name: Publish
|
||||||
|
if: github.event_name == 'workflow_dispatch' && inputs.tag != ''
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
. tools/shadps4/source.env
|
||||||
|
gh release create "${{ inputs.tag }}" --title "${{ inputs.tag }}" --notes "shadPS4 ARM64 (FEXCore guest CPU) from ${SHADPS4_REPO} @ ${SHADPS4_REV} with tools/shadps4/patches; installed by the app to /opt/appimages/shadps4.AppImage. sha256 $(cut -d' ' -f1 shadps4.AppImage.sha256)" shadps4.AppImage shadps4.AppImage.sha256 || gh release upload "${{ inputs.tag }}" shadps4.AppImage shadps4.AppImage.sha256 --clobber
|
||||||
Executable
+82
@@ -0,0 +1,82 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Runs INSIDE a debian:trixie container on an x86-64 runner. Cross-builds the ARM64 shadPS4 core
|
||||||
|
# (tools/shadps4/source.env) with its own scripts - FEXCore first, then shadPS4 linked against it -
|
||||||
|
# after applying ./patches, and packs the binary as shadps4.AppImage for /opt/appimages.
|
||||||
|
# Built against trixie's glibc 2.41; the runtime's Arch rootfs is newer, so its own X11, Vulkan
|
||||||
|
# loader, udev and C++ libraries are used and nothing is bundled.
|
||||||
|
set -euxo pipefail
|
||||||
|
WORK=/work
|
||||||
|
cd "$WORK"
|
||||||
|
. tools/shadps4/source.env
|
||||||
|
|
||||||
|
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).
|
||||||
|
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 \
|
||||||
|
gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu \
|
||||||
|
python3 nodejs \
|
||||||
|
libvulkan-dev libc6-dev \
|
||||||
|
libx11-dev:arm64 libxext-dev:arm64 libudev-dev:arm64 uuid-dev:arm64 \
|
||||||
|
libpulse-dev:arm64 libasound2-dev:arm64 \
|
||||||
|
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 '*'
|
||||||
|
|
||||||
|
SRC=$WORK/build/shadps4-arm64-src
|
||||||
|
rm -rf "$SRC"
|
||||||
|
git init -q "$SRC"
|
||||||
|
git -C "$SRC" remote add origin "$SHADPS4_REPO"
|
||||||
|
git -C "$SRC" fetch -q --depth 1 origin "$SHADPS4_REV"
|
||||||
|
git -C "$SRC" checkout -q --detach FETCH_HEAD
|
||||||
|
test "$(git -C "$SRC" rev-parse HEAD)" = "$SHADPS4_REV"
|
||||||
|
git -C "$SRC" submodule update --init --recursive --depth 1 --jobs 8
|
||||||
|
for p in $(ls tools/shadps4/patches/*.patch | sort); do
|
||||||
|
echo "applying $(basename "$p")"
|
||||||
|
git -C "$SRC" apply --whitespace=nowarn "$WORK/$p"
|
||||||
|
done
|
||||||
|
|
||||||
|
bash "$SRC/runtime/scripts/build-shadps4-arm64.sh"
|
||||||
|
BIN=$SRC/runtime/build/shadps4-arm64-stage/bin/shadps4-arm64
|
||||||
|
test -x "$BIN"
|
||||||
|
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
|
||||||
|
# The patch is in.
|
||||||
|
grep -aq 'BACHATA_MANAGED' "$BIN"
|
||||||
|
|
||||||
|
APPDIR=$WORK/build/shadPS4.AppDir
|
||||||
|
rm -rf "$APPDIR"
|
||||||
|
install -Dm755 "$BIN" "$APPDIR/usr/bin/shadps4"
|
||||||
|
cat > "$APPDIR/AppRun" <<'RUN'
|
||||||
|
#!/bin/sh
|
||||||
|
# shadPS4 is a command-line emulator; opened from a menu with nothing to run, it shows its own
|
||||||
|
# Big Picture game list instead of a usage box.
|
||||||
|
HERE=$(dirname "$(readlink -f "$0")")
|
||||||
|
[ $# -eq 0 ] && set -- --big-picture
|
||||||
|
exec "$HERE/usr/bin/shadps4" "$@"
|
||||||
|
RUN
|
||||||
|
chmod 755 "$APPDIR/AppRun"
|
||||||
|
cat > "$APPDIR/shadps4.desktop" <<'DESK'
|
||||||
|
[Desktop Entry]
|
||||||
|
Type=Application
|
||||||
|
Name=shadPS4
|
||||||
|
Exec=shadps4
|
||||||
|
Icon=shadps4
|
||||||
|
Categories=Game;Emulator;
|
||||||
|
DESK
|
||||||
|
cp "$SRC/src/resources/shadps4.png" "$APPDIR/shadps4.png"
|
||||||
|
ln -sf shadps4.png "$APPDIR/.DirIcon"
|
||||||
|
|
||||||
|
curl -fsSL -o runtime-aarch64 "$APPIMAGE_RUNTIME_URL"
|
||||||
|
file runtime-aarch64 | grep -q 'ARM aarch64'
|
||||||
|
mksquashfs "$APPDIR" shadps4.squashfs -root-owned -noappend -comp zstd -Xcompression-level 19
|
||||||
|
cat runtime-aarch64 shadps4.squashfs > shadps4.AppImage
|
||||||
|
chmod 755 shadps4.AppImage
|
||||||
|
rm -f shadps4.squashfs runtime-aarch64
|
||||||
|
sha256sum shadps4.AppImage | tee shadps4.AppImage.sha256
|
||||||
|
ls -l shadps4.AppImage
|
||||||
@@ -0,0 +1,111 @@
|
|||||||
|
diff --git a/src/core/libraries/audio/audioout.cpp b/src/core/libraries/audio/audioout.cpp
|
||||||
|
index 2e28f7d..91ec84f 100644
|
||||||
|
--- a/src/core/libraries/audio/audioout.cpp
|
||||||
|
+++ b/src/core/libraries/audio/audioout.cpp
|
||||||
|
@@ -1,6 +1,7 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2024-2026 shadPS4 Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
+#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
|
@@ -207,14 +208,15 @@ s32 PS4_SYSV_ABI sceAudioOutInit() {
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef ENABLE_BACHATA_RUNTIME
|
||||||
|
- audio = std::make_unique<BachataAudioOut>();
|
||||||
|
-#else
|
||||||
|
+ if (std::getenv("BACHATA_ALSA_SOCKET") != nullptr) {
|
||||||
|
+ audio = std::make_unique<BachataAudioOut>();
|
||||||
|
+ } else
|
||||||
|
+#endif
|
||||||
|
if (EmulatorSettings.GetAudioBackend() == AudioBackend::OpenAL) {
|
||||||
|
audio = std::make_unique<OpenALAudioOut>();
|
||||||
|
} else {
|
||||||
|
audio = std::make_unique<SDLAudioOut>();
|
||||||
|
}
|
||||||
|
-#endif
|
||||||
|
|
||||||
|
LOG_INFO(Lib_AudioOut, "Audio system initialized");
|
||||||
|
return ORBIS_OK;
|
||||||
|
diff --git a/src/main.cpp b/src/main.cpp
|
||||||
|
index 13733ed..d28319e 100644
|
||||||
|
--- a/src/main.cpp
|
||||||
|
+++ b/src/main.cpp
|
||||||
|
@@ -298,6 +298,8 @@ int main(int argc, char* argv[]) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
runtime_client = std::move(*connected);
|
||||||
|
+ // Stand-alone runs (no socket) keep SDL controllers and SDL audio.
|
||||||
|
+ setenv("BACHATA_MANAGED", "1", 1);
|
||||||
|
if (!runtime_client.SendStarting()) {
|
||||||
|
std::cerr << "Failed to send Bachata Starting event\n";
|
||||||
|
return 1;
|
||||||
|
diff --git a/src/sdl_window.cpp b/src/sdl_window.cpp
|
||||||
|
index ffa42d3..0785fc3 100644
|
||||||
|
--- a/src/sdl_window.cpp
|
||||||
|
+++ b/src/sdl_window.cpp
|
||||||
|
@@ -27,6 +27,8 @@
|
||||||
|
#include "input/input_handler.h"
|
||||||
|
#include "input/input_mouse.h"
|
||||||
|
#include "sdl_window.h"
|
||||||
|
+
|
||||||
|
+#include <cstdlib>
|
||||||
|
#include "video_core/renderdoc.h"
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
@@ -39,6 +41,14 @@ CMRC_DECLARE(res);
|
||||||
|
|
||||||
|
namespace Frontend {
|
||||||
|
|
||||||
|
+#ifdef ENABLE_BACHATA_RUNTIME
|
||||||
|
+// The Android runtime delivers controllers over its socket; a stand-alone run uses SDL like
|
||||||
|
+// the desktop build.
|
||||||
|
+static bool BachataManaged() {
|
||||||
|
+ return std::getenv("BACHATA_MANAGED") != nullptr;
|
||||||
|
+}
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
using namespace Libraries::Pad;
|
||||||
|
|
||||||
|
static OrbisPadButtonDataOffset SDLGamepadToOrbisButton(u8 button) {
|
||||||
|
@@ -153,9 +163,10 @@ WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameControllers* controller
|
||||||
|
SDL_SetWindowFullscreen(window, EmulatorSettings.IsFullScreen());
|
||||||
|
SDL_SyncWindow(window);
|
||||||
|
|
||||||
|
-#ifndef ENABLE_BACHATA_RUNTIME
|
||||||
|
- SDL_InitSubSystem(SDL_INIT_GAMEPAD);
|
||||||
|
+#ifdef ENABLE_BACHATA_RUNTIME
|
||||||
|
+ if (!BachataManaged())
|
||||||
|
#endif
|
||||||
|
+ SDL_InitSubSystem(SDL_INIT_GAMEPAD);
|
||||||
|
|
||||||
|
#if defined(SDL_PLATFORM_WIN32)
|
||||||
|
window_info.type = WindowSystemType::Windows;
|
||||||
|
@@ -183,9 +194,10 @@ WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameControllers* controller
|
||||||
|
// input handler init-s
|
||||||
|
Input::ControllerOutput::LinkJoystickAxes();
|
||||||
|
Input::ParseInputConfig(std::string(Common::ElfInfo::Instance().GameSerial()));
|
||||||
|
-#ifndef ENABLE_BACHATA_RUNTIME
|
||||||
|
- controllers.TryOpenSDLControllers();
|
||||||
|
+#ifdef ENABLE_BACHATA_RUNTIME
|
||||||
|
+ if (!BachataManaged())
|
||||||
|
#endif
|
||||||
|
+ controllers.TryOpenSDLControllers();
|
||||||
|
|
||||||
|
if (EmulatorSettings.IsBackgroundControllerInput()) {
|
||||||
|
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
||||||
|
@@ -266,9 +278,10 @@ void WindowSDL::WaitEvent() {
|
||||||
|
break;
|
||||||
|
case SDL_EVENT_GAMEPAD_ADDED:
|
||||||
|
case SDL_EVENT_GAMEPAD_REMOVED:
|
||||||
|
-#ifndef ENABLE_BACHATA_RUNTIME
|
||||||
|
- controllers.TryOpenSDLControllers();
|
||||||
|
+#ifdef ENABLE_BACHATA_RUNTIME
|
||||||
|
+ if (!BachataManaged())
|
||||||
|
#endif
|
||||||
|
+ controllers.TryOpenSDLControllers();
|
||||||
|
break;
|
||||||
|
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
||||||
|
case SDL_EVENT_GAMEPAD_BUTTON_UP:
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# The ARM64 shadPS4 core: upstream shadPS4 with FEXCore running the PS4's x86-64 code, published
|
||||||
|
# by the Bachata S4 project (GPL-2.0). Pinned; tools/shadps4/patches apply on top.
|
||||||
|
SHADPS4_REPO=https://github.com/zenithblue-oss/shadps4-arm64.git
|
||||||
|
SHADPS4_REV=be6bc2e9c60799e071dd2fafa6216e8d80ec619c
|
||||||
|
# AppImage type2 runtime for aarch64 (squashfs with zstd).
|
||||||
|
APPIMAGE_RUNTIME_URL=https://github.com/AppImage/type2-runtime/releases/download/continuous/runtime-aarch64
|
||||||
Reference in new issue
Block a user