Skip to content

shadps4: init at 0.3.0-unstable-2024-10-13 #340215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions pkgs/by-name/sh/shadps4/0001-Disable-update-checking.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
From 266a090882133e30df20899bbf8a5b66b28e02cd Mon Sep 17 00:00:00 2001
From: OPNA2608 <[email protected]>
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

19 changes: 19 additions & 0 deletions pkgs/by-name/sh/shadps4/bloodborne.patch
Original file line number Diff line number Diff line change
@@ -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<u8*>(0x7FFFFC000ULL);
+ auto* ret = reinterpret_cast<PthreadInternal*>(
+ 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;
24 changes: 24 additions & 0 deletions pkgs/by-name/sh/shadps4/laptop-controls.patch
Original file line number Diff line number Diff line change
@@ -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;
140 changes: 140 additions & 0 deletions pkgs/by-name/sh/shadps4/package.nix
Original file line number Diff line number Diff line change
@@ -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;
};
}