Added ShadPS4 Flatpak (#1357)

* Adding ShadPS4 Flatpak

* Amended Flatpak installation steps for ShadPS4

* Setting input config, optimize settings management and language support

* Additional amendments for consistency
This commit is contained in:
Loading.oO 2024-12-23 22:14:03 +00:00 committed by GitHub
parent d98ed3ad1a
commit 56e01a46a7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 544 additions and 0 deletions

View File

@ -0,0 +1,68 @@
# ShadPS4 Settings/Config file
[General]
isPS4Pro = false
Fullscreen = false
playBGM = false
BGMvolume = 50
enableDiscordRPC = false
logType = "async" # Configures logging synchronization (sync/async)
logFilter = "" # Sets the logging category for various logging classes
userName = "shadPS4"
updateChannel = "Release"
showSplash = false
autoUpdate = false
separateUpdateEnabled = false
[Input]
cursorState = 0 # HideCursorState::Idle
cursorHideTimeout = 5
backButtonBehavior = "left"
useSpecialPad = false
specialPadClass = 1
[GPU]
# Configures the game window width and height e.g. '800' for OLED Steameck (16:10 Aspect Ratio)
screenWidth = 1280
screenHeight = 720
nullGpu = false # Disables rendering
copyGPUBuffers = false
dumpShaders = false # Dump shaders that are loaded by the emulator. Dump path: ../user/shader/dumps
patchShaders = true
vblankDivider = 1
[Vulkan]
gpuId = -1
validation = false
validation_sync = false
validation_gpu = false
rdocEnable = false # Automatically hook RenderDoc when installed. Useful for debugging shaders and game rendering
rdocMarkersEnable = false # Enable automatic RenderDoc event annotation
crashDiagnostic = false
[Debug]
DebugDump = false
CollectShader = false
[GUI]
theme = 0
iconSize = 36
iconSizeGrid = 69
sliderPos = 0
sliderPosGrid = 0
gameTableMode = 0
mw_width = 1280
mw_height = 720 # Need to set to '800' for OLED Deck (16:10 Aspect Ratio)
geometry_x = 400
geometry_y = 400
geometry_w = 1280
geometry_h = 720 # Need to set to '800' for OLED Deck (16:10 Aspect Ratio)
installDirs = []
addonInstallDir = ""
pkgDirs = []
elfDirs = []
recentFiles = []
emulatorLanguage = "en"
[Settings]
consoleLanguage = 1 # english

View File

@ -0,0 +1,67 @@
# Default input configuration file, each game may have per-game files too, e.g.
;~/config/shadps4/
;└── inputConfig/
; ├── default.ini
; └── [game_id].ini
# Keyboard bindings
triangle = f
circle = space
cross = e
square = r
pad_up = w, lalt
pad_up = mousewheelup
pad_down = s, lalt
pad_down = mousewheeldown
pad_left = a, lalt
pad_left = mousewheelleft
pad_right = d, lalt
pad_right = mousewheelright
l1 = rightbutton, lshift
r1 = leftbutton
l2 = rightbutton
r2 = leftbutton, lshift
l3 = x
r3 = q
r3 = middlebutton
options = escape
touchpad = g
key_toggle = i, lalt
mouse_to_joystick = right
mouse_movement_params = 0.5, 1, 0.125
leftjoystick_halfmode = lctrl
axis_left_x_minus = a
axis_left_x_plus = d
axis_left_y_minus = w
axis_left_y_plus = s
# Controller bindings
triangle = triangle
cross = cross
square = square
circle = circle
l1 = l1
l2 = l2
l3 = l3
r1 = r1
r2 = r2
r3 = r3
pad_up = pad_up
pad_down = pad_down
pad_left = pad_left
pad_right = pad_right
options = options
touchpad = back
axis_left_x = axis_left_x
axis_left_y = axis_left_y
axis_right_x = axis_right_x
axis_right_y = axis_right_y

View File

@ -1203,6 +1203,22 @@
"category":"PlayStation 3",
"name":"PlayStation 3"
},
{
"id": "12345678901234567",
"executable": {
"path": "\"/usr/bin/flatpak\" run net.shadps4.shadPS4 --no-gui \"${filePath}\"",
"arguments": ""
},
"romDirectory": "roms/ps4",
"supportedFileTypes": [
"iso",
"ISO",
"pkg",
"PKG"
],
"category": "PlayStation 4",
"name": "PlayStation 4"
},
{
"id":"164785656634747068",
"executable":{

View File

@ -0,0 +1,372 @@
#!/bin/bash
# Script to install, initialize and configure ShadPS4 on EmuDeck
# Note: No Bios/Keys symlinks necessary
# External helper functions (defined outside this script)
#- installEmuBI()
#- getReleaseURLGH()
#- configEmuAI()
#- linkToSaveFolder()
#- uninstallGeneric()
#- migrateAndLinkConfig()
#- flushEmulatorLaunchers()
#- setMSG()
# Variables
ShadPS4_emuName="ShadPS4"
ShadPS4_emuType="$emuDeckEmuTypeBinary"
ShadPS4_emuPath="$HOME/Applications/publish"
ShadPS4_configFile="$HOME/.config/shadps4/config.toml"
userDir="$HOME/.config/shadps4/user"
sysDir="$HOME/.config/shadps4/system"
inputConfigDir="$HOME/.config/shadps4/inputConfig"
controllerFile="${inputConfigDir}/default.ini"
migrationFlag="$HOME/.config/EmuDeck/.${ShadPS4_emuName}MigrationCompleted"
# Language keys using [ISO 639-1: Language codes] & [ISO 3166-1 alpha-2: Country codes]
# NOTE: Keep in sync with https://github.com/shadps4-emu/shadPS4/tree/main/src/qt_gui/translations
# even though project still just uses some two character codes e.g. 'nl' instead of 'nl_NL'
declare -A ShadPS4_languages
ShadPS4_languages=(
["ar"]="Arabic"
["da_DK"]="Danish"
["de"]="German Deutsch"
["el"]="Greek"
["el_GR"]="Greek"
["en"]="English"
["en_US"]="English (US)"
["en_IE"]="English (Irish)"
["es_ES"]="Spanish"
["fa_IR"]="Farsi (Iran)"
["fi"]="Finnish"
["fi_FI"]="Finnish"
["fr"]="French"
["fr_FR"]="French"
["hu_HU"]="Hungarian"
["id"]="Indonesian"
["it"]="Italian"
["ja_JP"]="Japanese"
["ko_KR"]="Korean"
["lt_LT"]="Lithuanian"
["nb"]="Norwegian Bokmål"
["nl"]="Dutch"
["nl_NL"]="Dutch (Netherlands)"
["pl_PL"]="Polish"
["pt_BR"]="Portuguese"
["ro_RO"]="Romanian"
["ru_RU"]="Russian"
["sq"]="Albanian"
["ti_ER"]="Tigrinya"
["tr_TR"]="Turkish"
["uk_UA"]="Ukrainian"
["vi_VN"]="Vietnamese"
["zh_CN"]="Chinese (Simplified)"
["zh_TW"]="Traditional Chinese (Taiwan)"
)
declare -A ShadPS4_regions
ShadPS4_regions=(
["ar"]="Arabic"
["da_DK"]="Denmark"
["de"]="Deutsch"
["el"]="Greece"
["el_GR"]="Greece"
["en"]="Global English"
["en_US"]="United States"
["en_IE"]="Ireland"
["es_ES"]="Spain"
["fa_IR"]="Iran"
["fi"]="Finland"
["fi_FI"]="Finland"
["fr"]="France"
["fr_FR"]="France"
["hu_HU"]="Hungary"
["id"]="Indonesia"
["it"]="Italian"
["ja_JP"]="Japan"
["ko_KR"]="South Korea"
["lt_LT"]="Lithuania"
["nb"]="Norway"
["nl"]="Netherlands"
["nl_NL"]="Netherlands"
["pl_PL"]="Poland"
["pt_BR"]="Brazil"
["ro_RO"]="Romania"
["ru_RU"]="Russia"
["sq"]="Albania"
["ti_ER"]="Eritrea"
["tr_TR"]="Turkey"
["uk_UA"]="Ukraine"
["vi_VN"]="Vietnam"
["zh_CN"]="China"
["zh_TW"]="Taiwan"
)
ShadPS4_cleanup(){
echo "Begin ShadPS4 Cleanup"
}
# TODO: Install Flatpak from https://github.com/shadps4-emu/shadPS4-flatpak
ShadPS4_install(){
echo "Begin ShadPS4 Install"
local showProgress=$1
if installEmuBI "$ShadPS4_emuName" "$(getReleaseURLGH "ShadPS4/shadps4" "-linux_x64.tar.gz")" "" "tar.gz" "$showProgress"; then
mkdir -p "$HOME/Applications/publish"
tar -xvf "$HOME/Applications/shadps4.tar.gz" -C "$HOME/Applications" && rm -rf "$HOME/Applications/shadps4.tar.gz"
chmod +x "$HOME/Applications/publish/shadps4"
else
return 1
fi
# Flatpak install
echo "Installing ShadPS4 via Flatpak..."
flatpak install flathub net.shadps4.shadPS4 -y --user
# Move Flatpak installed files to the desired location
mkdir -p "$HOME/Applications/publish"
rsync -av "$HOME/.local/share/flatpak/app/net.shadps4.shadPS4/x86_64/stable/active/files/bin/" "$HOME/Applications/publish/" && flatpak uninstall flathub net.shadps4.shadPS4 -y --user
# Clean up old games directory if it exists
rm -rf "$HOME/.config/shadps4/games"
# Set executable permission
chmod +x "$HOME/Applications/publish/shadps4"
}
ShadPS4_init(){
configEmuAI "$ShadPS4_emuName" "config" "$HOME/.config/shadps4" "$EMUDECKGIT/configs/shadps4" "true"
ShadPS4_setupStorage
ShadPS4_setEmulationFolder
ShadPS4_setupSaves
ShadPS4_flushEmulatorLauncher
ShadPS4_setLanguage
# SRM_createParsers
# ShadPS4_migrate
}
ShadPS4_update(){
echo "Begin ShadPS4 update"
configEmuAI "$ShadPS4_emuName" "config" "$HOME/.config/shadps4" "$EMUDECKGIT/configs/shadps4"
ShadPS4_setEmulationFolder
ShadPS4_setupStorage
ShadPS4_setupSaves
ShadPS4_finalize
ShadPS4_flushEmulatorLauncher
}
# Configuration Paths
ShadPS4_setEmulationFolder(){
echo "Begin ShadPS4 Path Config"
# Define paths for PS4 ROMs
gameDirOpt='Paths\\gamedirs\\0\\path='
newGameDirOpt='Paths\\gamedirs\\0\\path='"${romsPath}/ps4"
# Update the configuration file
sed -i "/${gameDirOpt}/c\\${newGameDirOpt}" "$ShadPS4_configFile"
# https://github.com/shadps4-emu/shadPS4/blob/3f1061de5613c0c4a74d6394a6493491280bc03f/src/common/path_util.h
mkdir -p "${userDir}/screenshots/"
mkdir -p "${userDir}/shader/"
mkdir -p "${userDir}/savedata/"
mkdir -p "${userDir}/data/"
mkdir -p "${userDir}/temp/"
mkdir -p "${userDir}/sys_modules/"
mkdir -p "${userDir}/download/"
mkdir -p "${userDir}/captures/"
mkdir -p "${userDir}/cheats/"
mkdir -p "${userDir}/patches/"
mkdir -p "${userDir}/game_data/"
# https://github.com/shadps4-emu/shadPS4/blob/main/documents/Debugging/Debugging.md#quick-analysis
mkdir -p "${userDir}/log/"
mkdir -p "${inputConfigDir}"
echo "ShadPS4 Path Config Completed"
}
# Reusable Function to read value from the config.toml file
read_config_toml() {
local key="$1"
local configFile="$2"
echo "Reading arguments - key '$key' from config file: '$configFile'..."
local value
value=$(jq -r "$key" "$configFile")
echo "Extracted value: $value"
echo "$value"
}
ShadPS4_setLanguage(){
setMSG "Setting ShadPS4 Language"
local language=$(locale | grep LANG | cut -d= -f2 | cut -d_ -f1)
echo "Checking if the config file at path: '$ShadPS4_configFile'"
if [[ -f "${ShadPS4_configFile}" ]]; then
echo "Config file found: ${ShadPS4_configFile}"
emulatorLanguage=$(read_config_toml '.GUI.emulatorLanguage' "$ShadPS4_configFile")
echo "Checking if language key exists in current language setting..."
if [[ -n ${ShadPS4_languages[$emulatorLanguage]+_} ]]; then
echo "Language key found in current language settings!"
# Save the updated language settings back to the config file
echo "Updating system language and system region in the config file..."
tmp=$(jq --arg lang "${ShadPS4_languages[$emulatorLanguage]}" --arg region "${ShadPS4_regions[$emulatorLanguage]}" \
'.system_language = $lang | .system_region = $region' \
"${ShadPS4_configFile}")
echo "$tmp" > "${ShadPS4_configFile}"
echo "Config file updated successfully."
else
echo "Language key '${emulatorLanguage}' not found in current language settings. No updates made."
fi
else
echo "Configuration file not found: ${ShadPS4_configFile}"
fi
echo "ShadPS4 language '${emulatorLanguage}' configuration completed."
}
# Setup Saves
ShadPS4_setupSaves(){
echo "Begin ShadPS4 save link"
# Create symbolic links
linkToSaveFolder ShadPS4 saves "${userDir}/savedata"
linkToSaveFolder ShadPS4 saveMeta "${userDir}/saveMeta"
linkToSaveFolder ShadPS4 system "${sysDir}"
linkToSaveFolder ShadPS4 system_saves "${sysDir}/save"
echo "ShadPS4 save link completed"
}
#SetupStorage
ShadPS4_setupStorage(){
echo "Begin ShadPS4 storage config"
local origPath="$HOME/.config/"
# mkdir -p "${storagePath}/shadps4/patchesAndDlc"
rsync -av "${origPath}/shadps4/games/" "${storagePath}/shadps4/games/" && rm -rf "${origPath}ShadPS4/games"
unlink "${origPath}/shadps4/games"
ln -ns "${storagePath}/shadps4/games/" "${origPath}/shadps4/games"
}
#WipeSettings
ShadPS4_wipe(){
echo "Begin ShadPS4 delete config directories"
rm -rf "$HOME/.config/shadps4"
}
#Uninstall
ShadPS4_uninstall(){
echo "Begin ShadPS4 uninstall"
uninstallGeneric $ShadPS4_emuName $ShadPS4_emuPath "" "emulator"
}
# Migrate flatpak to appimage??
ShadPS4_migrate(){
echo "Begin ShadPS4 Migration"
# Migration
if [ "$(ShadPS4_IsMigrated)" != "true" ]; then
#ShadPS4 flatpak to appimage
#From -- > to
migrationTable=()
migrationTable+=("$HOME/.var/app/net.shadps4.ShadPS4/config/shadps4" "$HOME/.config/shadps4")
migrateAndLinkConfig "$ShadPS4_emuName" "$migrationTable"
fi
echo "true"
}
ShadPS4_IsMigrated(){
if [ -f "$migrationFlag" ]; then
echo "true"
else
echo "false"
fi
}
#setABXYstyle
ShadPS4_setABXYstyle(){
sed -i 's/"button_x": "Y",/"button_x": "X",/' $ShadPS4_configFile
sed -i 's/"button_b": "A",/"button_b": "B",/' $ShadPS4_configFile
sed -i 's/"button_y": "X",/"button_y": "Y",/' $ShadPS4_configFile
sed -i 's/"button_a": "B"/"button_a": "A"/' $ShadPS4_configFile
}
ShadPS4_setBAYXstyle(){
sed -i 's/"button_x": "X",/"button_x": "Y",/' $ShadPS4_configFile
sed -i 's/"button_b": "B",/"button_b": "A",/' $ShadPS4_configFile
sed -i 's/"button_y": "Y",/"button_y": "X",/' $ShadPS4_configFile
sed -i 's/"button_a": "A"/"button_a": "B"/' $ShadPS4_configFile
}
#WideScreenOn
ShadPS4_wideScreenOn(){
echo "NYI"
}
#WideScreenOff
ShadPS4_wideScreenOff(){
echo "NYI"
}
#BezelOn
ShadPS4_bezelOn(){
echo "NYI"
}
#BezelOff
ShadPS4_bezelOff(){
echo "NYI"
}
#finalExec - Extra stuff
ShadPS4_finalize(){
echo "Begin ShadPS4 finalize"
}
ShadPS4_IsInstalled(){
if [ -e "$ShadPS4_emuPath/shadps4" ]; then
echo "true"
else
echo "false"
fi
}
ShadPS4_resetConfig(){
ShadPS4_init &>/dev/null && echo "true" || echo "false"
}
ShadPS4_setResolution(){
case $ShadPS4Resolution in
"720P") multiplier=1; docked="false";;
"1080P") multiplier=1; docked="true";;
"1440P") multiplier=2; docked="false";;
"4K") multiplier=2; docked="true";;
*) echo "Error"; return 1;;
esac
jq --arg docked "$docked" --arg multiplier "$multiplier" \
'.docked_mode = $docked | .res_scale = $multiplier' "$ShadPS4_configFile" > tmp.json
mv tmp.json "$ShadPS4_configFile"
}
ShadPS4_flushEmulatorLauncher(){
flushEmulatorLaunchers "ShadPS4"
}

View File

@ -88,6 +88,8 @@ Migration_updatePaths(){
sed -i "s|${origin}|${destination}|g" "$HOME/.var/app/${RPCS3_emuPath}/config/rpcs3/vfs.yml"
#Ryujinx
sed -i "s|${origin}|${destination}|g" "$HOME/.config/Ryujinx/Config.json"
#ShadPS4
sed -i "s|${origin}|${destination}|g" "$HOME/.config/shadps4/config.toml"
#ScummVM
sed -i "s|${origin}|${destination}|g" "$ScummVM_configFile"
#Vita3K

View File

@ -85,6 +85,7 @@ source "$EMUDECKGIT"/functions/EmuScripts/emuDeckDolphin.sh
source "$EMUDECKGIT"/functions/EmuScripts/emuDeckPrimehack.sh
source "$EMUDECKGIT"/functions/EmuScripts/emuDeckRetroArch.sh
source "$EMUDECKGIT"/functions/EmuScripts/emuDeckRyujinx.sh
source "$EMUDECKGIT"/functions/EmuScripts/emuDeckShadPS4.sh
source "$EMUDECKGIT"/functions/EmuScripts/emuDeckPPSSPP.sh
source "$EMUDECKGIT"/functions/EmuScripts/emuDeckDuckStation.sh
source "$EMUDECKGIT"/functions/EmuScripts/emuDeckXemu.sh

View File

@ -281,6 +281,7 @@ function createUpdateSettingsFile(){
defaultSettingsList+=("doSetupCemu=true")
defaultSettingsList+=("doSetupXenia=false")
defaultSettingsList+=("doSetupRyujinx=true")
defaultSettingsList+=("doSetupShadPS4=false")
defaultSettingsList+=("doSetupMAME=true")
defaultSettingsList+=("doSetupPrimehack=true")
defaultSettingsList+=("doSetupPPSSPP=true")

View File

@ -47,6 +47,7 @@ function jsonToBashVars(){
setSetting doSetupCemu "$(jq .overwriteConfigEmus.cemu.status $json)"
setSetting doSetupXenia "$(jq .overwriteConfigEmus.xenia.status $json)"
setSetting doSetupRyujinx "$(jq .overwriteConfigEmus.ryujinx.status $json)"
setSetting doSetupShadPS4 "$(jq .overwriteConfigEmus.shadps4.status $json)"
setSetting doSetupMAME "$(jq .overwriteConfigEmus.mame.status $json)"
setSetting doSetupPrimeHack "$(jq .overwriteConfigEmus.primehack.status $json)"
setSetting doSetupPPSSPP "$(jq .overwriteConfigEmus.ppsspp.status $json)"

View File

@ -14,6 +14,7 @@ doSetupDuck=true
doSetupCemu=true
doSetupXenia=false
doSetupRyujinx=true
doSetupShadPS4=false
doSetupMAME=true
doSetupPrimehack=true
doSetupPPSSPP=true

View File

@ -360,6 +360,10 @@ if [ "$doSetupRyujinx" == "true" ]; then
echo "Ryujinx_init"
Ryujinx_init
fi
if [ "$doSetupShadPS4" == "true" ]; then
echo "ShadPS4_init"
ShadPS4_init
fi
if [ "$doSetupPPSSPP" == "true" ]; then
echo "PPSSPP_init"
PPSSPP_init

View File

@ -515,6 +515,16 @@ fi
rm -rf $HOME/Applications/publish &> /dev/null
rm -rf $HOME/.local/share/applications/Ryujinx.desktop &> /dev/null
fi
if [[ "$doUninstallShadPS4" == true ]]; then
# Flatpak
flatpak uninstall net.shadps4.ShadPS4 -y
rm -rf $HOME/.var/app/net.shadps4.ShadPS4 &> /dev/null
# AppImage
rm -rf "$HOME/.config/shadps4" &> /dev/null
rm -rf "$HOME/.cache/shadps4" &> /dev/null
rm -rf $HOME/.local/share/applications/ShadPS4.desktop &> /dev/null
rm -rf $HOME/Applications/shadps4.AppImage &> /dev/null
fi
if [[ "$doUninstallScummVM" == true ]]; then
flatpak uninstall org.scummvm.ScummVM -y
rm -rf $HOME/.var/app/org.scummvm.ScummVM &> /dev/null

View File

@ -11,6 +11,7 @@
"rpcs3": { "id": "rpcs3", "code": "RPCS3", "version": 0 },
"yuzu": { "id": "yuzu", "code": "Yuzu", "version": 1 },
"ryujinx": { "id": "ryujinx", "code": "Ryujinx", "version": 4 },
"shadps4": { "id": "shadps4", "code": "ShadPS4", "version": 0 },
"xemu": { "id": "xemu", "code": "Xemu", "version": 0 },
"cemu": { "id": "cemu", "code": "Cemu", "version": 0 },
"srm": { "id": "srm", "code": "SRM", "version": 7 },