Skip to content

Launcher fixes #1392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 88 additions & 12 deletions functions/helperFunctions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1042,11 +1042,30 @@ addProtonLaunch(){
function emulatorInit(){
local emuName=$1
local emuCode=$2
local params=$3
local emuFolder=$3
shift 3
# extract list of executables, usually 1 but can be more (see yuzu)
# this list must be terminated by "--" argument because we need to separate it from command line arguments
local emuExecutables=()
if [[ -z "$1" ]]; then
shift
fi
while [[ -n "$1" && "$1" != "--" ]]; do
emuExecutables+=("$1")
shift
done
if [[ "$1" == "--" ]]; then
shift
fi
#if [[ ${#emuExecutables[@]} -eq 0 ]]; then
# emuExecutables=("$emuCode")
#fi
local params=("$@")

#isLatestVersionGH "$emuName"
#NetPlay
cloud_sync_stopService
if [ "$emuName" = 'retroarch' ]; then
if [ "$emuName" == "retroarch" ]; then
if [ "$netPlay" == "true" ]; then
#Looks for devices listening
setSetting netplayCMD "-H"
Expand All @@ -1059,7 +1078,7 @@ function emulatorInit(){
source $emudeckBackend/functions/all.sh
fi

if [ "$emuName" != 'retroarch' ]; then
if [ "$emuName" != "retroarch" ]; then
cloud_sync_downloadEmu "$emuName" && cloud_sync_startService
fi

Expand Down Expand Up @@ -1092,47 +1111,105 @@ function emulatorInit(){

fi



fi

#We launch the emulator
if [[-z "$emuCode"]]; then
if [[ ! -z "$emuCode" ]]; then

#We launch the emulator
exe=()

#find full path to emu executable
exe_path=$(find "$emusfolder" -iname "${emuCode}" | sort -n | cut -d' ' -f 2- | tail -n 1 2>/dev/null)
#exe_path=$(find "$emusFolder" -iname "$emuCode" | sort -n | cut -d' ' -f 2- | tail -n 1 2>/dev/null)
# search list of emuExecutables in searchPath, one by one
local searchPath="${emuFolder:-$emusFolder}"
local exe_path=""
for emuExecutable in "${emuExecutables[@]}"; do
echo "Searching for '$emuExecutable' in '$searchPath'"
found_exe=$(find "$searchPath" -iname "$emuExecutable" | cut -d' ' -f 2- | tail -n 1 2>/dev/null)
echo "Found '$found_exe'"
if [[ -n "$found_exe" ]]; then
exe_path="$found_exe"
break
fi
done

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

fileExtension="${@##*.}"
# moved to launcher, it can be handled from there
#if [[ "$emuName" == "Vita3k" ]]; then
# export LC_ALL="C"
#fi

if [[ $fileExtension == "psvita" ]]; then
# we need to handle psvita viles for Vita3k and desktop files for RPCS3 and ShadPS4
fileExtension="${@##*.}"
if [[ $fileExtension == "psvita" && $emuName == "Vita3k" ]]; then
vita3kFile=$(<"${*}")
echo "GAME ID: $vita3kFile"
echo "Launching: ${exe[*]} -Fr $vita3kFile"
"${exe[@]}" -Fr "$vita3kFile"
elif [[ $fileExtension == "desktop" && ( $emuName == "rpcs3" || $emuName == "shadps4" ) ]]; then
# trying to figure this out... :)
# In desktop file the Exec line is like this:
# Exec="/home/deck/Applications/rpcs3.AppImage" --no-gui "%%RPCS3_GAMEID%%:BLES01732"
# Exec=/tmp/.mount_ShadpsT3Dso0/usr/bin/shadps4 "/run/media/mmcblk0p1/Emulation/storage/shadps4/games/CUSA01369/eboot.bin"
# shadPS4 should probably fix the executable here?
# they both seem to have incorrect executabe for flatpak versions (/app/run/rpcs3|shadps4)

# take desktop file and extract Exec= line
desktopFileExec=$(grep -E "^Exec=" "${*}" | sed 's/^Exec=//' | sed 's/%%/%/g')
echo $desktopFileExec

# this removes everything in Exec= line before first " or ' (quotes), keeps everything after that (including the quotes)
# we also need to skip the executable if it is quoted, Exec= starts with "
# given examples above, results should be:
# "/run/media/mmcblk0p1/Emulation/storage/shadps4/games/CUSA01369/eboot.bin"
# "%%RPCS3_GAMEID%%:BLES01732"
#launchParam=$(echo "Exec=$desktopFileExec" | sed "s|^\(Exec=\)[^\"\']*\([\"\']\)|\2|")
launchParam=$(echo "Exec=$desktopFileExec" | awk -F'"' '{for (i=NF; i>0; i--) if ($i ~ /./) {print "\"" $i "\""; exit}}')

launch_args=()
if [[ $emuName == "rpcs3" ]]; then
launch_args+=("--no-gui")
elif [[ $emuName == "shadps4 " ]]; then
launch_args+=("-g")
fi
# construct launch args and run
launch_args+=("$launchParam")
echo "Launching: ${exe[*]} ${launch_args[*]}"
"${exe[@]}" "${launch_args[@]}"
else
#run the executable with the params.
launch_args=()
for rom in "${params}"; do
for rom in "${params[@]}"; 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

# check if we need netplayCMD argument, if it is blank it messes up the run command
if [[ -n "${netplayCMD-}" && ! "$netplayCMD" =~ ^[[:space:]]*$ ]]; then
echo "Adding '${netplayCMD}' to launch arguments"
launch_args=("$netplayCMD" "${launch_args[@]}")
fi

# for yuzu and co, this was in the original launcher
if [[ "$emuName" == "yuzu" || "$emuName" == "suyu" || "$emuName" == "citron" || "$emuName" == "torzu" ]]; then
echo "Appending 'prlimit --nofile=8192' before executable"
exe=("prlimit" "--nofile=8192" "${exe[@]}")
fi

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

if [[ -z "${*}" ]]; then
Expand All @@ -1147,7 +1224,6 @@ function emulatorInit(){

fi


}


Expand Down
3 changes: 1 addition & 2 deletions tools/launchers/ares-emu.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
cd $biosPath
emulatorInit "ares"
/usr/bin/flatpak run dev.ares.ares "${@}"
emulatorInit "ares" "dev.ares.ares" "" "" "--" "${@}"
rm -rf "$savesPath/.gaming"
2 changes: 1 addition & 1 deletion tools/launchers/bigpemu.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "BigPEmu" "bigPEmu" "${@}"
emulatorInit "BigPEmu" "com.richwhitehouse.BigPEmu" "$emusFolder/BigPEmu" "bigpemu" "--" "${@}"
rm -rf "$savesPath/.gaming"
15 changes: 13 additions & 2 deletions tools/launchers/cemu-native.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "Cemu" "Cemu" "${@}"
rm -rf "$savesPath/.gaming"
emulatorInit "cemu"
# shellcheck disable=SC1091
. "$emudeckFolder/settings.sh"

# shellcheck disable=SC2154
LAUNCH="${toolsPath}/emu-launch.sh"

# Set emulator name
EMU="Cemu"

# Launch emu-launch.sh
"${LAUNCH}" -e "${EMU}" -- "${@}"
rm -rf "$savesPath/.gaming"
4 changes: 2 additions & 2 deletions tools/launchers/cemu.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "Cemu" "Cemu" "${@}"
rm -rf "$savesPath/.gaming"
emulatorInit "Cemu" "info.cemu.Cemu" "" "Cemu*.AppImage" "--" "${@}"
rm -rf "$savesPath/.gaming"
4 changes: 2 additions & 2 deletions tools/launchers/citra.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "citra" "citra-qt" "${@}"
rm -rf "$savesPath/.gaming"
emulatorInit "citra" "org.citra_emu.citra" "" "citra-qt*.AppImage" "--" "${@}"
rm -rf "$savesPath/.gaming"
4 changes: 2 additions & 2 deletions tools/launchers/citron.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "citron" "citron" "${@}"
rm -rf "$savesPath/.gaming"
emulatorInit "citron" "citron" "" "citron*.AppImage" "--" "${@}"
rm -rf "$savesPath/.gaming"
2 changes: 1 addition & 1 deletion tools/launchers/dolphin-emu.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "dolphin" "dolphin-emu" "${@}"
emulatorInit "dolphin" "org.DolphinEmu.dolphin-emu" "" "" "--" "${@}"
rm -rf "$savesPath/.gaming"
4 changes: 2 additions & 2 deletions tools/launchers/duckstation.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "duckstation" "duckstation" "${@}"
rm -rf "$savesPath/.gaming"
emulatorInit "duckstation" "org.duckstation.DuckStation" "" "" "--" "${@}"
rm -rf "$savesPath/.gaming"
4 changes: 2 additions & 2 deletions tools/launchers/flycast.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "flycast" "flycast" "${@}"
/usr/bin/flatpak run org.flycast.Flycast "${@}"
emulatorInit "flycast" "org.flycast.Flycast" "" "" "--" "${@}"
rm -rf "$savesPath/.gaming"
4 changes: 2 additions & 2 deletions tools/launchers/lime3ds.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "lime3ds" "lime3ds-gui" "${@}"
rm -rf "$savesPath/.gaming"
emulatorInit "lime3ds" "io.github.lime3ds.Lime3DS" "" "lime3ds-gui*.AppImage" "--" "${@}"
rm -rf "$savesPath/.gaming"
4 changes: 2 additions & 2 deletions tools/launchers/mame.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "mame" "MAME" "${@}"
rm -rf "$savesPath/.gaming"
emulatorInit "mame" "org.mamedev.MAME" "" "" "--" "${@}"
rm -rf "$savesPath/.gaming"
4 changes: 2 additions & 2 deletions tools/launchers/melonds.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "melonds" "melonDS" "${@}"
rm -rf "$savesPath/.gaming"
emulatorInit "melonds" "net.kuribo64.melonDS" "" "" "--" "${@}"
rm -rf "$savesPath/.gaming"
2 changes: 1 addition & 1 deletion tools/launchers/mgba.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "mgba" "mGBA" ${@}
emulatorInit "mgba" "io.mgba.mGBA" "" "mGBA*.AppImage" "--" "${@}"
rm -rf "$savesPath/.gaming"
5 changes: 3 additions & 2 deletions tools/launchers/model-2-emulator.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "model2"

# $ULWGL_toolPath is assigned in emuDeckModel2.sh
GAMELAUNCHER=$ULWGL_toolPath/ulwgl-run

Expand All @@ -10,7 +11,7 @@ Model2Launcher="${toolsPath}/launchers/model-2-emulator.sh"

Model2ConfigFile="$romsPath/model2/EMULATOR.INI"

#In case the user deletes it, will allow loading bar to pop up again.
# In case the user deletes it, will allow loading bar to pop up again.
mkdir -p "$romsPath/model2/pfx"

while [ ! -d "$romsPath/model2/pfx/drive_c" ]; do
Expand Down Expand Up @@ -39,4 +40,4 @@ else
WINEPREFIX=$romsPath/model2/pfx/ GAMEID=ulwgl-model2 PROTONPATH="$HOME/.steam/steam/compatibilitytools.d/ULWGL-Proton-$Model2_ProtonGEVersion" $GAMELAUNCHER $EXE "${@}"
fi

rm -rf "$savesPath/.gaming"
rm -rf "$savesPath/.gaming"
2 changes: 1 addition & 1 deletion tools/launchers/pcsx2-qt.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "pcsx2" "pcsx2-Qt" ${@}
emulatorInit "pcsx2" "net.pcsx2.PCSX2" "" "pcsx2-Qt*.AppImage" "--" "${@}"
rm -rf "$savesPath/.gaming"
4 changes: 2 additions & 2 deletions tools/launchers/ppsspp.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "ppsspp" "ppsspp" "${@}"
rm -rf "$savesPath/.gaming"
emulatorInit "ppsspp" "org.ppsspp.PPSSPP" "" "" "--" "${@}"
rm -rf "$savesPath/.gaming"
4 changes: 2 additions & 2 deletions tools/launchers/primehack.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "primehack" "primehack" "${@}"
rm -rf "$savesPath/.gaming"
emulatorInit "primehack" "io.github.shiiion.primehack" "" "" "--" "${@}"
rm -rf "$savesPath/.gaming"
4 changes: 2 additions & 2 deletions tools/launchers/retroarch.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "retroarch" "RetroArch" "${@}"
rm -rf "$savesPath/.gaming"
emulatorInit "retroarch" "org.libretro.RetroArch" "" "" "--" "${@}"
rm -rf "$savesPath/.gaming"
4 changes: 2 additions & 2 deletions tools/launchers/rosaliesmupengui.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "RMG" "RMG" "${@}"
rm -rf "$savesPath/.gaming"
emulatorInit "RMG" "com.github.Rosalie241.RMG" "" "" "--" "${@}"
rm -rf "$savesPath/.gaming"
2 changes: 1 addition & 1 deletion tools/launchers/rpcs3.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "rpcs3""rpcs3" "${@}"
emulatorInit "rpcs3" "net.rpcs3.RPCS3" "" "rpcs3*.AppImage" "--" "${@}"
rm -rf "$savesPath/.gaming"
2 changes: 1 addition & 1 deletion tools/launchers/ryujinx.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "ryujinx" "Ryujinx" "${@}"
emulatorInit "ryujinx" "org.ryujinx.Ryujinx" "$emusFolder/publish" "Ryujinx.sh" "--" "${@}"
rm -rf "$savesPath/.gaming"
4 changes: 2 additions & 2 deletions tools/launchers/scummvm.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "scummvm" "scummvm" "${@}"
rm -rf "$savesPath/.gaming"
emulatorInit "scummvm" "org.scummvm.ScummVM" "" "" "--" "${@}"
rm -rf "$savesPath/.gaming"
2 changes: 1 addition & 1 deletion tools/launchers/shadps4.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "shadps4" "shadps4" "${@}"
emulatorInit "shadps4" "net.shadps4.shadPS4" "" "Shadps4-qt*.AppImage" "--" "${@}"
rm -rf "$savesPath/.gaming"
6 changes: 2 additions & 4 deletions tools/launchers/supermodel.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/sh
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
param="${@}"
param=$(echo "$param" | sed "s|'||g")
emulatorInit "supermodel" "supermodel3" "${param}"
rm -rf "$savesPath/.gaming"
emulatorInit "supermodel" "com.supermodel3.Supermodel" "" "" "--" "${@}"
rm -rf "$savesPath/.gaming"
6 changes: 2 additions & 4 deletions tools/launchers/suyu.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
param="${@}"
param=$(echo $param | sed -e 's/^/"/' -e 's/$/"/')
emulatorInit "suyu" "suyu" "$param"
rm -rf "$savesPath/.gaming"
emulatorInit "suyu" "suyu" "" "suyu*.AppImage" "--" "${@}"
rm -rf "$savesPath/.gaming"
3 changes: 2 additions & 1 deletion tools/launchers/vita3k.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "Vita3k" "Vita3k" "${@}"
export LC_ALL="C" # this was originally in the launcher, so i kept it
emulatorInit "Vita3k" "Vita3k" "$emusFolder/Vita3K" "Vita3k" "--" "${@}"
rm -rf "$savesPath/.gaming"
4 changes: 2 additions & 2 deletions tools/launchers/xemu-emu.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
. "$HOME/.config/EmuDeck/backend/functions/all.sh"
emulatorInit "xemu" "xemu" "${@}"
rm -rf "$savesPath/.gaming"
emulatorInit "xemu" "app.xemu.xemu" "" "" "--" "${@}"
rm -rf "$savesPath/.gaming"
Loading