mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-22 05:55:38 +00:00
FRAMEWORK: added the possibility to run a game from cli
This commit is contained in:
parent
2f2ffd7f72
commit
bcf0f2b8cd
|
@ -1061,6 +1061,7 @@
|
||||||
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_about/what-is-retrodeck/",
|
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_about/what-is-retrodeck/",
|
||||||
"launch": "Yuzu",
|
"launch": "Yuzu",
|
||||||
"system": "switch",
|
"system": "switch",
|
||||||
|
"launch-args": "-f -g $game",
|
||||||
"ponzu": true,
|
"ponzu": true,
|
||||||
"abxy_button": true
|
"abxy_button": true
|
||||||
},
|
},
|
||||||
|
@ -1069,6 +1070,7 @@
|
||||||
"description": "Dolphin Wii and GameCube Emulator",
|
"description": "Dolphin Wii and GameCube Emulator",
|
||||||
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/dolphin-primehack/dolphin-primehack-guide/",
|
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/dolphin-primehack/dolphin-primehack-guide/",
|
||||||
"launch": "dolphin-emu-wrapper",
|
"launch": "dolphin-emu-wrapper",
|
||||||
|
"launch-args": "-e $game",
|
||||||
"system": [
|
"system": [
|
||||||
"gc",
|
"gc",
|
||||||
"wii"
|
"wii"
|
||||||
|
@ -1088,6 +1090,7 @@
|
||||||
"description": "A fork of Dolphiin to enhance Metroid Prime experience",
|
"description": "A fork of Dolphiin to enhance Metroid Prime experience",
|
||||||
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/dolphin-primehack/dolphin-primehack-guide/",
|
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/dolphin-primehack/dolphin-primehack-guide/",
|
||||||
"launch": "primehack-wrapper",
|
"launch": "primehack-wrapper",
|
||||||
|
"launch-args": "-e $game",
|
||||||
"system": [
|
"system": [
|
||||||
"wii"
|
"wii"
|
||||||
],
|
],
|
||||||
|
@ -1104,6 +1107,7 @@
|
||||||
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/cemu/cemu-guide/",
|
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/cemu/cemu-guide/",
|
||||||
"system": "wiiu",
|
"system": "wiiu",
|
||||||
"launch": "Cemu-wrapper",
|
"launch": "Cemu-wrapper",
|
||||||
|
"launch-args": "-g $game",
|
||||||
"properties": [
|
"properties": [
|
||||||
{
|
{
|
||||||
"abxy_button": true,
|
"abxy_button": true,
|
||||||
|
@ -1116,7 +1120,8 @@
|
||||||
"name": "xemu",
|
"name": "xemu",
|
||||||
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/xemu/xemu-guide/",
|
"url": "https://retrodeck.readthedocs.io/en/latest/wiki_emulator_guides/xemu/xemu-guide/",
|
||||||
"system": "xbox",
|
"system": "xbox",
|
||||||
"launch": "xemu"
|
"launch": "xemu",
|
||||||
|
"launch-args": "-dvd_path $game"
|
||||||
},
|
},
|
||||||
"es-de": {
|
"es-de": {
|
||||||
"description": "ES-DE Emulation Frontend",
|
"description": "ES-DE Emulation Frontend",
|
||||||
|
|
|
@ -891,3 +891,55 @@ start_retrodeck() {
|
||||||
log i "Starting RetroDECK v$version"
|
log i "Starting RetroDECK v$version"
|
||||||
es-de
|
es-de
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_game() {
|
||||||
|
# Arguments: $1 -> game path, $2 -> optional system
|
||||||
|
local game="$1"
|
||||||
|
local system="$2"
|
||||||
|
|
||||||
|
# If no system is provided, extract it from the game path
|
||||||
|
if [[ -z "$system" ]]; then
|
||||||
|
system=$(echo "$game" | grep -oP '(?<=roms/)[^/]+')
|
||||||
|
fi
|
||||||
|
|
||||||
|
log d "Run game: running $(basename "$game") for $system system"
|
||||||
|
|
||||||
|
# Special case for retroarch
|
||||||
|
if [[ "$system" == "retroarch" ]]; then
|
||||||
|
log d "TODO: implement retroarch"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Query the features JSON for emulators that support the system
|
||||||
|
local emulators=$(jq -r --arg system "$system" '
|
||||||
|
.emulator | to_entries[] |
|
||||||
|
select(
|
||||||
|
(.value.system == $system) or
|
||||||
|
(.value.system[]? == $system)
|
||||||
|
) | .key' "$features")
|
||||||
|
|
||||||
|
# Check if multiple emulators are found and prompt the user to select one with zenity
|
||||||
|
if [[ $(echo "$emulators" | wc -l) -gt 1 ]]; then
|
||||||
|
emulator=$(echo "$emulators" | zenity --list --title="Select Emulator" --text="Multiple emulators found for $system. Select one to run." --column="Emulator")
|
||||||
|
else
|
||||||
|
emulator="$emulators"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If no emulator was selected, exit
|
||||||
|
if [[ -z "$emulator" ]]; then
|
||||||
|
log e "No emulator selected. Exiting."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
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")
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ flatpak run [FLATPAK-RUN-OPTION] net.retrodeck-retrodeck [ARGUMENTS]
|
||||||
Arguments:
|
Arguments:
|
||||||
-h, --help Print this help
|
-h, --help Print this help
|
||||||
-v, --version Print RetroDECK version
|
-v, --version Print RetroDECK version
|
||||||
|
--run <path> (system) Run a game from cli, if no system is defined it will deducted from the path. For example --run ~/retrodeck/roms/system/game.ext will be run with the system "system".
|
||||||
--info-msg Print paths and config informations
|
--info-msg Print paths and config informations
|
||||||
--configurator Starts the RetroDECK Configurator
|
--configurator Starts the RetroDECK Configurator
|
||||||
--compress-one <file> Compresses target file to a compatible format
|
--compress-one <file> Compresses target file to a compatible format
|
||||||
|
@ -42,6 +43,10 @@ https://retrodeck.net
|
||||||
echo "RetroDECK v$version"
|
echo "RetroDECK v$version"
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
--run*)
|
||||||
|
run_game "$2" "$3"
|
||||||
|
exit
|
||||||
|
;;
|
||||||
--info-msg*)
|
--info-msg*)
|
||||||
echo "RetroDECK v$version"
|
echo "RetroDECK v$version"
|
||||||
echo "RetroDECK config file is in: $rd_conf"
|
echo "RetroDECK config file is in: $rd_conf"
|
||||||
|
|
Loading…
Reference in a new issue