From 52341f00796aac7cd99ecbbd8506e646b3c678fe Mon Sep 17 00:00:00 2001 From: dankcushions Date: Sun, 20 Feb 2022 13:44:21 +0000 Subject: [PATCH 1/3] DuckStation standalone PSX emulator --- scriptmodules/emulators/duckstation.sh | 86 ++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 scriptmodules/emulators/duckstation.sh diff --git a/scriptmodules/emulators/duckstation.sh b/scriptmodules/emulators/duckstation.sh new file mode 100644 index 0000000000..4eebc9ea5b --- /dev/null +++ b/scriptmodules/emulators/duckstation.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash + +# This file is part of The RetroPie Project +# +# The RetroPie Project is the legal property of its developers, whose names are +# too numerous to list here. Please refer to the COPYRIGHT.md file distributed with this source. +# +# See the LICENSE.md file at the top-level directory of this distribution and +# at https://raw.githubusercontent.com/RetroPie/RetroPie-Setup/master/LICENSE.md +# + +rp_module_id="duckstation" +rp_module_desc="PlayStation emulator DuckStation" +rp_module_help="ROM Extensions: .pbp .cue .bin .chd .img .ecm .mds .mdf\n\nCopy your PlayStation roms to $romdir/psx\n\nCopy the required BIOS file to $biosdir" +rp_module_licence="GPL3 https://raw.githubusercontent.com/stenzek/duckstation/master/LICENSE" +rp_module_section="exp" +rp_module_flags="" + +function depends_duckstation() { + local depends=(cmake libsdl2-dev libsnappy-dev pkg-config libevdev-dev libgbm-dev libdrm-dev) + getDepends "${depends[@]}" +} + +function sources_duckstation() { + gitPullOrClone "$md_build" https://github.com/stenzek/duckstation.git +} + +function build_duckstation() { + cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_DISCORD_PRESENCE=OFF -DUSE_X11=OFF -DUSE_DRMKMS=ON -DBUILD_NOGUI_FRONTEND=ON -DBUILD_QT_FRONTEND=OFF . + make clean + make + + md_ret_require="$md_build/bin/duckstation-nogui" +} + +function install_duckstation() { + md_ret_files=( + 'LICENSE' + 'README.md' + 'bin' + ) +} + +function configure_duckstation() { + mkRomDir "psx" + + # needed? + chown -R $user:$user "$md_inst/bin" + + local config="$md_conf_root/psx/duckstation.ini" + + addEmulator 0 "$md_id" "psx" "$md_inst/bin/duckstation-nogui -portable -settings $config -- %ROM%" + addSystem "psx" + + [[ "$md_mode" == "remove" ]] && return + + # create config file + touch "$config" + chown -R $user:$user "$config" + + # set config defaults + iniConfig " = " "" "$config" + if ! grep -q "\[Main\]" "$config"; then + echo "[Main]" >> "$config" + fi + # SettingsVersion = 3 stops overwrite of any settings when version number doesn't match + iniSet "SettingsVersion" "3" + iniSet "ControllerBackend" "evdev" + if ! grep -q "\[BIOS\]" "$config"; then + echo "[BIOS]" >> "$config" + fi + iniSet "SearchDirectory" "$biosdir" + if ! grep -q "\[MemoryCards\]" "$config"; then + echo "[MemoryCards]" >> "$config" + fi + iniSet "Directory" "$romdir/psx" + if ! grep -q "\[Display\]" "$config"; then + echo "[Display]" >> "$config" + fi + iniSet "LinearFiltering" "false" + iniSet "Directory" "$romdir/psx" + if ! grep -q "\[Hotkeys\]" "$config"; then + echo "[Hotkeys]" >> "$config" + fi + iniSet "OpenQuickMenu" "Keyboard/Escape" +} From add83f12b33148ff9e68fc7e9956ded8a8739425 Mon Sep 17 00:00:00 2001 From: dankcushions Date: Sun, 20 Feb 2022 14:16:02 +0000 Subject: [PATCH 2/3] Remove EVDEV controller backend setting (defaults to SDL) --- scriptmodules/emulators/duckstation.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scriptmodules/emulators/duckstation.sh b/scriptmodules/emulators/duckstation.sh index 4eebc9ea5b..c8f29cbcee 100644 --- a/scriptmodules/emulators/duckstation.sh +++ b/scriptmodules/emulators/duckstation.sh @@ -65,7 +65,6 @@ function configure_duckstation() { fi # SettingsVersion = 3 stops overwrite of any settings when version number doesn't match iniSet "SettingsVersion" "3" - iniSet "ControllerBackend" "evdev" if ! grep -q "\[BIOS\]" "$config"; then echo "[BIOS]" >> "$config" fi From ae42113e4660401edd9dd148769cfbbe6d6765bf Mon Sep 17 00:00:00 2001 From: dankcushions Date: Sun, 13 Mar 2022 12:39:22 +0000 Subject: [PATCH 3/3] Changes following review --- scriptmodules/emulators/duckstation.sh | 46 +++++++++++++++----------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/scriptmodules/emulators/duckstation.sh b/scriptmodules/emulators/duckstation.sh index c8f29cbcee..33079f26fd 100644 --- a/scriptmodules/emulators/duckstation.sh +++ b/scriptmodules/emulators/duckstation.sh @@ -26,7 +26,18 @@ function sources_duckstation() { } function build_duckstation() { - cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_DISCORD_PRESENCE=OFF -DUSE_X11=OFF -DUSE_DRMKMS=ON -DBUILD_NOGUI_FRONTEND=ON -DBUILD_QT_FRONTEND=OFF . + local params=(-DCMAKE_BUILD_TYPE=Release -DENABLE_DISCORD_PRESENCE=OFF -DBUILD_NOGUI_FRONTEND=ON -DBUILD_QT_FRONTEND=OFF) + if isPlatform "x11"; then + params+=(-DUSE_X11=ON) + else + params+=(-DUSE_X11=OFF) + fi + if isPlatform "kms"; then + params+=(-DUSE_DRMKMS=ON) + else + params+=(-DUSE_DRMKMS=OFF) + fi + cmake "${params[@]}" . make clean make @@ -44,9 +55,6 @@ function install_duckstation() { function configure_duckstation() { mkRomDir "psx" - # needed? - chown -R $user:$user "$md_inst/bin" - local config="$md_conf_root/psx/duckstation.ini" addEmulator 0 "$md_id" "psx" "$md_inst/bin/duckstation-nogui -portable -settings $config -- %ROM%" @@ -54,32 +62,32 @@ function configure_duckstation() { [[ "$md_mode" == "remove" ]] && return - # create config file - touch "$config" - chown -R $user:$user "$config" - # set config defaults - iniConfig " = " "" "$config" - if ! grep -q "\[Main\]" "$config"; then - echo "[Main]" >> "$config" + local tmp_config="$(mktemp)" + iniConfig " = " "" "$tmp_config" + if ! grep -q "\[Main\]" "$tmp_config"; then + echo "[Main]" >> "$tmp_config" fi # SettingsVersion = 3 stops overwrite of any settings when version number doesn't match iniSet "SettingsVersion" "3" - if ! grep -q "\[BIOS\]" "$config"; then - echo "[BIOS]" >> "$config" + if ! grep -q "\[BIOS\]" "$tmp_config"; then + echo "[BIOS]" >> "$tmp_config" fi iniSet "SearchDirectory" "$biosdir" - if ! grep -q "\[MemoryCards\]" "$config"; then - echo "[MemoryCards]" >> "$config" + if ! grep -q "\[MemoryCards\]" "$tmp_config"; then + echo "[MemoryCards]" >> "$tmp_config" fi iniSet "Directory" "$romdir/psx" - if ! grep -q "\[Display\]" "$config"; then - echo "[Display]" >> "$config" + if ! grep -q "\[Display\]" "$tmp_config"; then + echo "[Display]" >> "$tmp_config" fi iniSet "LinearFiltering" "false" iniSet "Directory" "$romdir/psx" - if ! grep -q "\[Hotkeys\]" "$config"; then - echo "[Hotkeys]" >> "$config" + if ! grep -q "\[Hotkeys\]" "$tmp_config"; then + echo "[Hotkeys]" >> "$tmp_config" fi iniSet "OpenQuickMenu" "Keyboard/Escape" + + copyDefaultConfig "$tmp_config" "$config" + rm "$tmp_config" }