diff --git a/functions/EmuScripts/emuDeckShadPS4.sh b/functions/EmuScripts/emuDeckShadPS4.sh index 18986dc49..e447e4d6f 100644 --- a/functions/EmuScripts/emuDeckShadPS4.sh +++ b/functions/EmuScripts/emuDeckShadPS4.sh @@ -16,15 +16,14 @@ # Variables ShadPS4_emuName="ShadPS4" -ShadPS4_emuType="$emuDeckEmuTypeBinary" -ShadPS4_emuPath="$HOME/Applications/publish" +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" -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 @@ -111,32 +110,18 @@ 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" + echo "Begin ShadPS4 Install" + local showProgress=$1 + + 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" + else + return 1 + fi } + ShadPS4_init(){ configEmuAI "$ShadPS4_emuName" "config" "$HOME/.config/shadps4" "$EMUDECKGIT/configs/shadps4" "true" ShadPS4_setupStorage @@ -193,19 +178,6 @@ ShadPS4_setEmulationFolder(){ 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) @@ -274,46 +246,6 @@ 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" @@ -340,7 +272,7 @@ ShadPS4_finalize(){ } ShadPS4_IsInstalled(){ - if [ -e "$ShadPS4_emuPath/shadps4" ]; then + if [ -e "$ShadPS4_emuPath/Shadps4-qt.AppImage" ]; then echo "true" else echo "false" @@ -352,20 +284,7 @@ ShadPS4_resetConfig(){ } 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" - + echo "NYI" } ShadPS4_flushEmulatorLauncher(){ diff --git a/functions/generateGameLists.sh b/functions/generateGameLists.sh index 06f9cef3c..7104f5d64 100644 --- a/functions/generateGameLists.sh +++ b/functions/generateGameLists.sh @@ -2,19 +2,9 @@ MSG="$HOME/.config/EmuDeck/msg.log" -generateGameLists_pythonEnv() { - if [ ! -d "$HOME/.config/EmuDeck/python_virtual_env" ]; then - python3 -m venv "$HOME/.config/EmuDeck/python_virtual_env" - source "$HOME/.config/EmuDeck/python_virtual_env/bin/activate" - pip install requests - else - source "$HOME/.config/EmuDeck/python_virtual_env/bin/activate" - fi -} - generateGameLists() { - generateGameLists_pythonEnv &> /dev/null + generate_pythonEnv &> /dev/null local accountfolder=$(ls -td $HOME/.steam/steam/userdata/* | head -n 1) local dest_folder="$accountfolder/config/grid/retrolibrary/artwork/" @@ -38,7 +28,7 @@ generateGameLists() { } generateGameListsJson() { - generateGameLists_pythonEnv &> /dev/null + generate_pythonEnv &> /dev/null echo "Adding Games" > "$MSG" #python $HOME/.config/EmuDeck/backend/tools/retro-library/generate_game_lists.py "$romsPath" echo "Games Added" > "$MSG" @@ -48,12 +38,12 @@ generateGameListsJson() { } generateGameLists_importESDE() { - generateGameLists_pythonEnv &> /dev/null + generate_pythonEnv &> /dev/null python $HOME/.config/EmuDeck/backend/tools/retro-library/import_media.py "$romsPath" "$dest_folder" } generateGameLists_artwork() { - generateGameLists_pythonEnv &> /dev/null + generate_pythonEnv &> /dev/null echo "Searching for missing artwork" > "$MSG" python $HOME/.config/EmuDeck/backend/tools/retro-library/missing_artwork_platforms.py "$romsPath" "$storagePath/retrolibrary/artwork" && python $HOME/.config/EmuDeck/backend/tools/retro-library/download_art_platforms.py "$storagePath/retrolibrary/artwork" @@ -97,7 +87,7 @@ function addGameListsArtwork() { } generateGameLists_getPercentage() { - generateGameLists_pythonEnv &> /dev/null + generate_pythonEnv &> /dev/null local accountfolder=$(ls -td $HOME/.steam/steam/userdata/* | head -n 1) local dest_folder="$storagePath/retrolibrary/artwork/" @@ -143,7 +133,7 @@ generateGameLists_extraArtwork() { } generateGameLists_retroAchievements(){ - generateGameLists_pythonEnv &> /dev/null + generate_pythonEnv &> /dev/null local hash=$1 local system=$2 local localDataPath="$storagePath/retrolibrary/achievements/$system.json" diff --git a/functions/helperFunctions.sh b/functions/helperFunctions.sh index 32cd4fd84..7cbed7e35 100644 --- a/functions/helperFunctions.sh +++ b/functions/helperFunctions.sh @@ -1117,10 +1117,25 @@ function startCompressor(){ konsole -e "/bin/bash $HOME/.config/EmuDeck/backend/tools/chdconv/chddeck.sh" } -function installPIP(){ - python -m pip --version &> /dev/null || python -m ensurepip --upgrade - python -m pip install --upgrade pip - grep -qxF 'PATH="$HOME/.local/bin:$PATH"' ~/.bashrc || echo 'PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc - grep -qxF 'alias pip="pip3"' ~/.bashrc || echo 'alias pip="pip3"' >> ~/.bashrc - PATH="$HOME/.local/bin:$PATH" +function generate_pythonEnv() { + if [ ! -d "$HOME/.config/EmuDeck/python_virtual_env" ]; then + python3 -m venv "$HOME/.config/EmuDeck/python_virtual_env" + source "$HOME/.config/EmuDeck/python_virtual_env/bin/activate" + pip install requests + else + source "$HOME/.config/EmuDeck/python_virtual_env/bin/activate" + fi +} + +# Reusable Function to read value from the config.toml file +function 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" } \ No newline at end of file diff --git a/tools/launchers/shadps4.sh b/tools/launchers/shadps4.sh index ead2d7c3c..3a331f1ec 100644 --- a/tools/launchers/shadps4.sh +++ b/tools/launchers/shadps4.sh @@ -2,18 +2,18 @@ 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 +emufolder="$HOME/Applications" # has to be applications 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) +exe_path=$(find "$emufolder" -iname "${emuName}*.AppImage" | 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") + flatpakApp=$(flatpak list --app --columns=application | grep "$RPCS3_emuPathFlatpak") #fill execute array exe=("flatpak" "run" "$flatpakApp") else @@ -23,22 +23,30 @@ else 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 +fileExtension="${@##*.}" -echo "Launching: ${exe[*]} ${launch_args[*]}" - -if [[ -z "${*}" ]]; then - echo "ROM not found. Launching $emuName directly" - "${exe[@]}" +if [[ $fileExtension == "desktop" ]]; then + rpcs3desktopFile=$(grep -E "^Exec=" "${*}" | sed 's/^Exec=//' | sed 's/%%/%/g') + echo "Exec=$rpcs3desktopFile" + eval $rpcs3desktopFile else - echo "ROM found, launching game" - "${exe[@]}" "${launch_args[@]}" + #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 fi rm -rf "$savesPath/.gaming"