RUN_GAME: added retroarch cores

This commit is contained in:
XargonWan 2024-09-08 13:52:05 +09:00
parent 2818362e30
commit b2a59be611

View file

@ -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,6 +948,12 @@ run_game() {
log d "Run game: selected emulator $emulator"
# 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")
@ -944,4 +963,5 @@ run_game() {
# Form and execute the command
eval "$launch_command $launch_args"
fi
}