From 7a30e57ad20777cb9c49de3e0c96a82cde6ddf42 Mon Sep 17 00:00:00 2001 From: Ryan Omasta Date: Mon, 14 Oct 2024 13:39:18 -0600 Subject: [PATCH] shadps4: init at 0.3.0-unstable-2024-10-13 --- .../0001-Disable-update-checking.patch | 30 ++++ pkgs/by-name/sh/shadps4/bloodborne.patch | 19 +++ pkgs/by-name/sh/shadps4/laptop-controls.patch | 24 +++ pkgs/by-name/sh/shadps4/package.nix | 140 ++++++++++++++++++ 4 files changed, 213 insertions(+) create mode 100644 pkgs/by-name/sh/shadps4/0001-Disable-update-checking.patch create mode 100644 pkgs/by-name/sh/shadps4/bloodborne.patch create mode 100644 pkgs/by-name/sh/shadps4/laptop-controls.patch create mode 100644 pkgs/by-name/sh/shadps4/package.nix diff --git a/pkgs/by-name/sh/shadps4/0001-Disable-update-checking.patch b/pkgs/by-name/sh/shadps4/0001-Disable-update-checking.patch new file mode 100644 index 000000000000..874f20ef493a --- /dev/null +++ b/pkgs/by-name/sh/shadps4/0001-Disable-update-checking.patch @@ -0,0 +1,30 @@ +From 266a090882133e30df20899bbf8a5b66b28e02cd Mon Sep 17 00:00:00 2001 +From: OPNA2608 +Date: Mon, 14 Oct 2024 00:31:01 +0200 +Subject: [PATCH] Disable update checking + +Downloading an AppImage and trying to run it just won't work. +--- + src/qt_gui/check_update.cpp | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/src/qt_gui/check_update.cpp b/src/qt_gui/check_update.cpp +index ca6009ca..e3b14d5d 100644 +--- a/src/qt_gui/check_update.cpp ++++ b/src/qt_gui/check_update.cpp +@@ -201,6 +201,12 @@ void CheckUpdate::setupUI(const QString& downloadUrl, const QString& latestDate, + noButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred); + bottomLayout->addWidget(autoUpdateCheckBox); + ++ yesButton->setVisible(false); ++ yesButton->setEnabled(false); ++ QString updateDisabledText = QStringLiteral("[Nix] Auto-updating has been disabled in this package."); ++ QLabel* updateDisabledLabel = new QLabel(updateDisabledText, this); ++ layout->addWidget(updateDisabledLabel); ++ + QSpacerItem* spacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum); + bottomLayout->addItem(spacer); + +-- +2.44.1 + diff --git a/pkgs/by-name/sh/shadps4/bloodborne.patch b/pkgs/by-name/sh/shadps4/bloodborne.patch new file mode 100644 index 000000000000..63eb722eb494 --- /dev/null +++ b/pkgs/by-name/sh/shadps4/bloodborne.patch @@ -0,0 +1,19 @@ +--- a/src/core/libraries/kernel/thread_management.cpp ++++ b/src/core/libraries/kernel/thread_management.cpp +@@ -1065,7 +1065,16 @@ ScePthread PThreadPool::Create() { + } + } + ++#ifdef _WIN64 + auto* ret = new PthreadInternal{}; ++#else ++ // TODO: Linux specific hack ++ static u8* hint_address = reinterpret_cast(0x7FFFFC000ULL); ++ auto* ret = reinterpret_cast( ++ mmap(hint_address, sizeof(PthreadInternal), PROT_READ | PROT_WRITE, ++ MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0)); ++ hint_address += Common::AlignUp(sizeof(PthreadInternal), 4_KB); ++#endif + ret->is_free = false; + ret->is_detached = false; + ret->is_almost_done = false; diff --git a/pkgs/by-name/sh/shadps4/laptop-controls.patch b/pkgs/by-name/sh/shadps4/laptop-controls.patch new file mode 100644 index 000000000000..e221cc71dd40 --- /dev/null +++ b/pkgs/by-name/sh/shadps4/laptop-controls.patch @@ -0,0 +1,24 @@ +diff --git a/src/sdl_window.cpp b/src/sdl_window.cpp +index bd2cc39d..13438149 100644 +--- a/src/sdl_window.cpp ++++ b/src/sdl_window.cpp +@@ -127,19 +127,12 @@ void WindowSDL::onResize() { + void WindowSDL::onKeyPress(const SDL_Event* event) { + using Libraries::Pad::OrbisPadButtonDataOffset; + +-#ifdef __APPLE__ + // Use keys that are more friendly for keyboards without a keypad. + // Once there are key binding options this won't be necessary. + constexpr SDL_Keycode CrossKey = SDLK_N; + constexpr SDL_Keycode CircleKey = SDLK_B; + constexpr SDL_Keycode SquareKey = SDLK_V; + constexpr SDL_Keycode TriangleKey = SDLK_C; +-#else +- constexpr SDL_Keycode CrossKey = SDLK_KP_2; +- constexpr SDL_Keycode CircleKey = SDLK_KP_6; +- constexpr SDL_Keycode SquareKey = SDLK_KP_4; +- constexpr SDL_Keycode TriangleKey = SDLK_KP_8; +-#endif + + u32 button = 0; + Input::Axis axis = Input::Axis::AxisMax; diff --git a/pkgs/by-name/sh/shadps4/package.nix b/pkgs/by-name/sh/shadps4/package.nix new file mode 100644 index 000000000000..56a0b85b4256 --- /dev/null +++ b/pkgs/by-name/sh/shadps4/package.nix @@ -0,0 +1,140 @@ +{ + lib, + stdenv, + fetchFromGitHub, + fetchpatch, + alsa-lib, + boost184, + cmake, + cryptopp, + glslang, + ffmpeg, + fmt, + jack2, + libdecor, + libpulseaudio, + libunwind, + libusb1, + magic-enum, + mesa, + pkg-config, + pugixml, + qt6, + rapidjson, + renderdoc, + sndio, + toml11, + vulkan-headers, + vulkan-loader, + vulkan-memory-allocator, + xorg, + xxHash, + zlib-ng, + unstableGitUpdater, +}: + +stdenv.mkDerivation { + pname = "shadps4"; + version = "0.3.0-unstable-2024-10-13"; + + src = fetchFromGitHub { + owner = "shadps4-emu"; + repo = "shadPS4"; + rev = "bd9f82df94847b4a5f3d2676ae938f064505c992"; + hash = "sha256-Z4+hHq2VI4wA1D72dBI7Lt++Rm3q0svjF6AialXxM0k="; + fetchSubmodules = true; + }; + + patches = [ + # https://github.com/shadps4-emu/shadPS4/issues/758 + ./bloodborne.patch + # Fix controls without a numpad + ./laptop-controls.patch + + # Disable auto-updating, as + # downloading an AppImage and trying to run it just won't work. + # https://github.com/shadps4-emu/shadPS4/issues/1368 + ./0001-Disable-update-checking.patch + ]; + + buildInputs = [ + alsa-lib + boost184 + cryptopp + glslang + ffmpeg + fmt + jack2 + libdecor + libpulseaudio + libunwind + libusb1 + xorg.libX11 + xorg.libXext + magic-enum + mesa + pugixml + qt6.qtbase + qt6.qtdeclarative + qt6.qtmultimedia + qt6.qttools + qt6.qtwayland + rapidjson + renderdoc + sndio + toml11 + vulkan-headers + vulkan-loader + vulkan-memory-allocator + xxHash + zlib-ng + ]; + + nativeBuildInputs = [ + cmake + pkg-config + qt6.wrapQtAppsHook + ]; + + cmakeFlags = [ + (lib.cmakeBool "ENABLE_QT_GUI" true) + ]; + + # Still in development, help with debugging + cmakeBuildType = "RelWithDebugInfo"; + dontStrip = true; + + installPhase = '' + runHook preInstall + + install -D -t $out/bin shadps4 + install -Dm644 -t $out/share/icons/hicolor/512x512/apps $src/.github/shadps4.png + install -Dm644 -t $out/share/applications $src/.github/shadps4.desktop + + runHook postInstall + ''; + + fixupPhase = '' + patchelf --add-rpath ${ + lib.makeLibraryPath [ + vulkan-loader + xorg.libXi + ] + } \ + $out/bin/shadps4 + ''; + + passthru.updateScript = unstableGitUpdater { + tagFormat = "v.*"; + tagPrefix = "v."; + }; + + meta = { + description = "Early in development PS4 emulator"; + homepage = "https://github.com/shadps4-emu/shadPS4"; + license = lib.licenses.gpl2Plus; + maintainers = with lib.maintainers; [ ryand56 ]; + mainProgram = "shadps4"; + platforms = lib.intersectLists lib.platforms.linux lib.platforms.x86_64; + }; +}