mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-25 15:35:38 +00:00
RUN_GAME: emulator and system can now be passed as optional arguments
This commit is contained in:
parent
b100cb3667
commit
302feef631
|
@ -893,22 +893,45 @@ start_retrodeck() {
|
||||||
}
|
}
|
||||||
|
|
||||||
run_game() {
|
run_game() {
|
||||||
# Arguments: $1 -> game path, $2 -> optional system
|
|
||||||
local game="$1"
|
# Initialize variables
|
||||||
local system="$2"
|
emulator=""
|
||||||
|
system=""
|
||||||
|
|
||||||
|
# Parse options
|
||||||
|
while getopts ":e:s:" opt; do
|
||||||
|
case ${opt} in
|
||||||
|
e )
|
||||||
|
emulator=$OPTARG
|
||||||
|
;;
|
||||||
|
s )
|
||||||
|
system=$OPTARG
|
||||||
|
;;
|
||||||
|
\? )
|
||||||
|
echo "Usage: $0 --run [-e emulator] [-s system] game"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
shift $((OPTIND -1))
|
||||||
|
|
||||||
|
# Check for game argument
|
||||||
|
if [[ -z "$1" ]]; then
|
||||||
|
echo "Error: Game file is required."
|
||||||
|
echo "Usage: $0 --run [-e emulator] [-s system] game"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
game=$1
|
||||||
|
|
||||||
# If no system is provided, extract it from the game path
|
# If no system is provided, extract it from the game path
|
||||||
if [[ -z "$system" ]]; then
|
if [[ -z "$system" ]]; then
|
||||||
system=$(echo "$game" | grep -oP '(?<=roms/)[^/]+')
|
system=$(echo "$game" | grep -oP '(?<=roms/)[^/]+')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
log d "Run game: running $(basename "$game") for $system system"
|
log d "Emulator: $emulator"
|
||||||
|
log d "System: $system"
|
||||||
# Special case for retroarch
|
log d "Game: $game"
|
||||||
if [[ "$system" == "retroarch" ]]; then
|
|
||||||
log d "TODO: implement retroarch"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Query the features JSON for emulators that support the system
|
# Query the features JSON for emulators that support the system
|
||||||
local emulators=$(jq -r --arg system "$system" '
|
local emulators=$(jq -r --arg system "$system" '
|
||||||
|
@ -926,6 +949,15 @@ run_game() {
|
||||||
(.value.system[]? == $system)
|
(.value.system[]? == $system)
|
||||||
) | .key' "$features")
|
) | .key' "$features")
|
||||||
|
|
||||||
|
# if the emulator is given and it's a retroarch core just execute it
|
||||||
|
if [[ "$emulator" == *"_libretro" ]]; then
|
||||||
|
local core_path="/var/config/retroarch/cores/$emulator.so"
|
||||||
|
log d "Running RetroArch core: $core_path"
|
||||||
|
log d "Command: retroarch -L $core_path \"$game\""
|
||||||
|
eval "retroarch -L $core_path \"$game\""
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# If the system is handled by RetroArch cores, add them to the list of emulators
|
# If the system is handled by RetroArch cores, add them to the list of emulators
|
||||||
if [[ -n "$retroarch_cores" ]]; then
|
if [[ -n "$retroarch_cores" ]]; then
|
||||||
emulators=$(echo -e "$emulators\n$retroarch_cores")
|
emulators=$(echo -e "$emulators\n$retroarch_cores")
|
||||||
|
|
24
retrodeck.sh
24
retrodeck.sh
|
@ -18,20 +18,21 @@ for i in "$@"; do
|
||||||
case $i in
|
case $i in
|
||||||
-h*|--help*)
|
-h*|--help*)
|
||||||
echo "RetroDECK v""$version"
|
echo "RetroDECK v""$version"
|
||||||
echo "
|
echo -e "
|
||||||
Usage:
|
Usage:
|
||||||
flatpak run [FLATPAK-RUN-OPTION] net.retrodeck-retrodeck [ARGUMENTS]
|
flatpak run [FLATPAK-RUN-OPTION] net.retrodeck-retrodeck [ARGUMENTS]
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
-h, --help Print this help
|
-h, --help \t Print this help
|
||||||
-v, --version Print RetroDECK version
|
-v, --version \t 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 \t Print paths and config informations
|
||||||
--info-msg Print paths and config informations
|
--configurator \t Starts the RetroDECK Configurator
|
||||||
--configurator Starts the RetroDECK Configurator
|
--compress-one <file> \t Compresses target file to a compatible format
|
||||||
--compress-one <file> Compresses target file to a compatible format
|
--compress-all <format> \t Compresses all supported games into a compatible format.\n\t\t\t\t\t\t Available formats are \"chd\", \"zip\", \"rvz\" and \"all\".
|
||||||
--compress-all <format> Compresses all supported games into a compatible format. Available formats are \"chd\", \"zip\", \"rvz\" and \"all\".
|
--reset-component <component> \t Reset one or more component or emulator configs to the default values
|
||||||
--reset-component <component> Reset one or more component or emulator configs to the default values
|
--reset-retrodeck \t Starts the initial RetroDECK installer (backup your data first!)
|
||||||
--reset-retrodeck Starts the initial RetroDECK installer (backup your data first!)
|
|
||||||
|
--run [-s <path>] [-e <path>] <path>\t Run a game from cli, if no system is defined it will deducted from the path.\n\t\t\t\t\t\t For example --run ~/retrodeck/roms/system/game.ext will be run with the system "system".\n\t\t\t\t\t\t Optionally -e (emulator) and -s (system) can be passed as arguments.
|
||||||
|
|
||||||
For flatpak run specific options please run: flatpak run -h
|
For flatpak run specific options please run: flatpak run -h
|
||||||
|
|
||||||
|
@ -44,7 +45,8 @@ https://retrodeck.net
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
--run*)
|
--run*)
|
||||||
run_game "$2" "$3"
|
shift # Remove --run
|
||||||
|
run_game "$@"
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
--info-msg*)
|
--info-msg*)
|
||||||
|
|
Loading…
Reference in a new issue