Skip to content

Commit

Permalink
shadps4 launcher
Browse files Browse the repository at this point in the history
  • Loading branch information
dragoonDorise committed Dec 23, 2024
1 parent 49e097a commit 245502a
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 21 deletions.
43 changes: 22 additions & 21 deletions functions/EmuScripts/emuDeckShadPS4.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

# Credits: https://github.com/Aeonitis
# Script to install, initialize and configure ShadPS4 on EmuDeck
# Note: No Bios/Keys symlinks necessary

Expand All @@ -18,10 +19,10 @@ 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"
ShadPS4_userDir="$HOME/.config/shadps4/user"
ShadPS4_sysDir="$HOME/.config/shadps4/system"
ShadPS4_inputConfigDir="$HOME/.config/shadps4/inputConfig"
ShadPS4_controllerFile="${ShadPS4_inputConfigDir}/default.ini"

migrationFlag="$HOME/.config/EmuDeck/.${ShadPS4_emuName}MigrationCompleted"

Expand Down Expand Up @@ -172,22 +173,22 @@ ShadPS4_setEmulationFolder(){
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/"
mkdir -p "${ShadPS4_userDir}/screenshots/"
mkdir -p "${ShadPS4_userDir}/shader/"
mkdir -p "${ShadPS4_userDir}/savedata/"
mkdir -p "${ShadPS4_userDir}/data/"
mkdir -p "${ShadPS4_userDir}/temp/"
mkdir -p "${ShadPS4_userDir}/sys_modules/"
mkdir -p "${ShadPS4_userDir}/download/"
mkdir -p "${ShadPS4_userDir}/captures/"
mkdir -p "${ShadPS4_userDir}/cheats/"
mkdir -p "${ShadPS4_userDir}/patches/"
mkdir -p "${ShadPS4_userDir}/game_data/"

# https://github.com/shadps4-emu/shadPS4/blob/main/documents/Debugging/Debugging.md#quick-analysis
mkdir -p "${userDir}/log/"
mkdir -p "${ShadPS4_userDir}/log/"

mkdir -p "${inputConfigDir}"
mkdir -p "${ShadPS4_inputConfigDir}"

echo "ShadPS4 Path Config Completed"
}
Expand Down Expand Up @@ -241,10 +242,10 @@ 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"
linkToSaveFolder ShadPS4 saves "${ShadPS4_userDir}/savedata"
linkToSaveFolder ShadPS4 saveMeta "${ShadPS4_userDir}/saveMeta"
linkToSaveFolder ShadPS4 system "${ShadPS4_sysDir}"
linkToSaveFolder ShadPS4 system_saves "${ShadPS4_sysDir}/save"

echo "ShadPS4 save link completed"
}
Expand Down
44 changes: 44 additions & 0 deletions tools/launchers/shadps4.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
source $HOME/.config/EmuDeck/backend/functions/all.sh
emulatorInit "shadps4"
emuName="ShadPS4" #parameterize me
emufolder="$HOME/Applications/publish" # has to be here for ES-DE to find it

#initialize execute array
exe=()

#find full path to emu executable
exe_path=$(find "$emufolder" -iname "${emuName}.sh" | sort -n | cut -d' ' -f 2- | tail -n 1 2>/dev/null)

#if appimage doesn't exist fall back to flatpak.
if [[ -z "$exe_path" ]]; then
#flatpak
flatpakApp=$(flatpak list --app --columns=application | grep "$emuName")
#fill execute array
exe=("flatpak" "run" "$flatpakApp")
else
#make sure that file is executable
chmod +x "$exe_path"
#fill execute array
exe=("$exe_path")
fi

#run the executable with the params.
launch_args=()
for rom in "${@}"; do
# Parsers previously had single quotes ("'/path/to/rom'" ), this allows those shortcuts to continue working.
removedLegacySingleQuotes=$(echo "$rom" | sed "s/^'//; s/'$//")
launch_args+=("$removedLegacySingleQuotes")
done

echo "Launching: ${exe[*]} ${launch_args[*]}"

if [[ -z "${*}" ]]; then
echo "ROM not found. Launching $emuName directly"
"${exe[@]}"
else
echo "ROM found, launching game"
"${exe[@]}" "${launch_args[@]}"
fi

rm -rf "$savesPath/.gaming"

0 comments on commit 245502a

Please sign in to comment.