mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-22 05:55:38 +00:00
RUN_GAME: added retroarch cores
This commit is contained in:
parent
2818362e30
commit
b2a59be611
|
@ -918,6 +918,19 @@ run_game() {
|
|||
(.value.system[]? == $system)
|
||||
) | .key' "$features")
|
||||
|
||||
# Check if the system is handled by RetroArch cores
|
||||
local retroarch_cores=$(jq -r --arg system "$system" '
|
||||
.emulator.retroarch.cores | to_entries[] |
|
||||
select(
|
||||
.value.system == $system or
|
||||
(.value.system[]? == $system)
|
||||
) | .key' "$features")
|
||||
|
||||
# If the system is handled by RetroArch cores, add them to the list of emulators
|
||||
if [[ -n "$retroarch_cores" ]]; then
|
||||
emulators=$(echo -e "$emulators\n$retroarch_cores")
|
||||
fi
|
||||
|
||||
local pretty_system=$(jq -r --arg system "$system" '.system[$system].name' "$features")
|
||||
|
||||
# Check if multiple emulators are found and prompt the user to select one with zenity
|
||||
|
@ -935,13 +948,20 @@ run_game() {
|
|||
|
||||
log d "Run game: selected emulator $emulator"
|
||||
|
||||
# Parse emulator launch command and arguments from the JSON file
|
||||
local launch_command=$(jq -r ".emulator.$emulator.launch" "$features")
|
||||
local launch_args=$(jq -r ".emulator.$emulator.\"launch-args\"" "$features")
|
||||
# Handle RetroArch core separately
|
||||
if [[ "$emulator" == *"_libretro" ]]; then
|
||||
local core_path="/var/config/retroarch/cores/$emulator.so"
|
||||
log d "Running RetroArch core: $core_path"
|
||||
eval "retroarch -L $core_path \"$game\""
|
||||
else
|
||||
# Parse emulator launch command and arguments from the JSON file
|
||||
local launch_command=$(jq -r ".emulator.$emulator.launch" "$features")
|
||||
local launch_args=$(jq -r ".emulator.$emulator.\"launch-args\"" "$features")
|
||||
|
||||
# Replace $game in launch_args with the actual game path, quoting it to handle spaces
|
||||
launch_args=${launch_args//\$game/\"$game\"}
|
||||
# Replace $game in launch_args with the actual game path, quoting it to handle spaces
|
||||
launch_args=${launch_args//\$game/\"$game\"}
|
||||
|
||||
# Form and execute the command
|
||||
eval "$launch_command $launch_args"
|
||||
}
|
||||
# Form and execute the command
|
||||
eval "$launch_command $launch_args"
|
||||
fi
|
||||
}
|
Loading…
Reference in a new issue