Skip to content

Commit

Permalink
shadPS4 init
Browse files Browse the repository at this point in the history
  • Loading branch information
dragoonDorise committed Dec 25, 2024
1 parent cb0fc2c commit cbb7ca2
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ 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 = ""
installDirs = "/run/media/mmcblk0p1/Emulation/storage/shadps4/games"
addonInstallDir = "/run/media/mmcblk0p1/Emulation/storage/shadps4/dlc"
pkgDirs = []
elfDirs = []
recentFiles = []
Expand Down
File renamed without changes.
94 changes: 10 additions & 84 deletions functions/EmuScripts/emuDeckShadPS4.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash

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

Expand All @@ -19,10 +18,7 @@ ShadPS4_emuName="ShadPS4"
ShadPS4_emuType="$emuDeckEmuTypeAppImage"
ShadPS4_emuPath="$HOME/Applications"
ShadPS4_configFile="$HOME/.config/shadps4/config.toml"
ShadPS4_userDir="$HOME/.config/shadps4/user"
ShadPS4_sysDir="$HOME/.config/shadps4/system"
ShadPS4_inputConfigDir="$HOME/.config/shadps4/inputConfig"
ShadPS4_controllerFile="${ShadPS4_inputConfigDir}/default.ini"
ShadPS4_dir="$HOME/.config/shadps4/user"


# Language keys using [ISO 639-1: Language codes] & [ISO 3166-1 alpha-2: Country codes]
Expand Down Expand Up @@ -115,123 +111,53 @@ ShadPS4_install(){

if installEmuAI "$ShadPS4_emuName" "" "$(getReleaseURLGH "shadps4-emu/shadPS4" "zip" "linux-qt")" "" "zip" "emulator" "$showProgress"; then # Cemu.AppImage
unzip -o "$HOME/Applications/ShadPS4.zip" -d "$ShadPS4_emuPath" && rm -rf "$HOME/Applications/ShadPS4.zip"
chmod +x "$ShadPS4_emuPath/publish/Shadps4.AppImage"
chmod +x "$ShadPS4_emuPath/publish/Shadps4-qt.AppImage"
else
return 1
fi
}


ShadPS4_init(){
configEmuAI "$ShadPS4_emuName" "config" "$HOME/.config/shadps4" "$EMUDECKGIT/configs/shadps4" "true"
configEmuAI "$ShadPS4_emuName" "config" "$HOME/.local/share/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
ShadPS4_init
}

# 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 "${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 "${ShadPS4_userDir}/log/"

mkdir -p "${ShadPS4_inputConfigDir}"

sed -i "s|/run/media/mmcblk0p1/Emulation|${emulationPath}|g" "$ShadPS4_configFile"
echo "ShadPS4 Path Config Completed"
}

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

changeLine "emulatorLanguage = " "emulatorLanguage = ${emulatorLanguage}" $ShadPS4_configFile
echo "ShadPS4 language '${emulatorLanguage}' configuration completed."
}

# Setup Saves
ShadPS4_setupSaves(){
echo "Begin ShadPS4 save link"

# Create symbolic links
linkToSaveFolder ShadPS4 saves "${ShadPS4_userDir}/savedata"
linkToSaveFolder ShadPS4 saveMeta "${ShadPS4_userDir}/saveMeta"
linkToSaveFolder ShadPS4 system "${ShadPS4_sysDir}"
linkToSaveFolder ShadPS4 system_saves "${ShadPS4_sysDir}/save"

linkToSaveFolder shadps4 saves "${ShadPS4_dir}/savedata"
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"
mkdir - "$storagePath/shadps4/games"
mkdir - "$storagePath/shadps4/dlc"
}

#WipeSettings
Expand All @@ -243,7 +169,7 @@ ShadPS4_wipe(){
#Uninstall
ShadPS4_uninstall(){
echo "Begin ShadPS4 uninstall"
uninstallGeneric $ShadPS4_emuName $ShadPS4_emuPath "" "emulator"
uninstallEmuAI $ShadPS4_emuName "Shadps4-qt" "AppImage" "emulator"
}

#WideScreenOn
Expand Down
4 changes: 2 additions & 2 deletions functions/uninstallEmuAI.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

uninstallEmuAI() {
function uninstallEmuAI() {
name=$1
filename=$2
format=$3
Expand All @@ -27,7 +27,7 @@ uninstallEmuAI() {
echo "3, Application File Format: $format"
echo "4, Application Type: $type"

echo "Uninstalling $name. Deleting "$HOME/Applications/$filename.$format". Deleting "$HOME/.local/share/applications/$name.desktop""
echo "Uninstalling $name. Deleting "$HOME/Applications/$filename.$format". Deleting "$HOME/.local/share/applications/$name.desktop""

rm -rf "$HOME/Applications/$filename.$format"
rm -rf "$HOME/.local/share/applications/$name.desktop"
Expand Down
2 changes: 1 addition & 1 deletion tools/launchers/shadps4.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
source $HOME/.config/EmuDeck/backend/functions/all.sh
emulatorInit "shadps4"
emuName="ShadPS4" #parameterize me
emuName="Shadps4-qt" #parameterize me
emufolder="$HOME/Applications" # has to be applications for ES-DE to find it

#initialize execute array
Expand Down

0 comments on commit cbb7ca2

Please sign in to comment.