instant_play save/load

Signed-off-by: Michel-FK <michel.stempin@funkey-project.com>
This commit is contained in:
Michel-FK 2021-05-09 23:09:52 +02:00
parent 0d19c7a7f1
commit ee49693543
12 changed files with 69 additions and 47 deletions

View File

@ -23,6 +23,7 @@ export HOME=/mnt/FunKey
mkdir -p "${HOME}" mkdir -p "${HOME}"
export MEDNAFEN_HOME=$HOME/.mednafen export MEDNAFEN_HOME=$HOME/.mednafen
mkdir -p "${MEDNAFEN_HOME}" mkdir -p "${MEDNAFEN_HOME}"
cp -n "/usr/games/lynxboot.img" "/usr/games/mednafen-09x.cfg" "${MEDNAFEN_HOME}/"
export GMENU2X_HOME="$HOME/.gmenu2x" export GMENU2X_HOME="$HOME/.gmenu2x"
mkdir -p "${GMENU2X_HOME}" mkdir -p "${GMENU2X_HOME}"
@ -55,6 +56,9 @@ brightness set $(brightness get) >/dev/null 2>&1
# Start Assembly tests (blocking process) # Start Assembly tests (blocking process)
assembly_tests >/dev/null 2>&1 assembly_tests >/dev/null 2>&1
# Restart saved application/game if any
instant_play load
# Start launcher # Start launcher
echo "Start launcher" echo "Start launcher"
start_launcher >/dev/null 2>&1 & start_launcher >/dev/null 2>&1 &

View File

@ -3,35 +3,71 @@
# Uncomment the following line to get debug info # Uncomment the following line to get debug info
#set -x #set -x
# Check args SELF="$(basename ${0})"
if [ ${#} -eq 0 ]; then INSTANT_PLAY_FILE="/mnt/instant_play"
echo "Usage: $(basename ${0}) args..." RESUME_PLAY_FILE="/mnt/resume_play"
usage() {
>&2 echo "Usage: ${SELF} load"
>&2 echo " ${SELF} save application args..."
exit 1 exit 1
}
# Check number of arguments
if [ ${#} -lt 1 ]; then
usage
fi fi
INSTANT_PLAY_FILE="/mnt/instant_play" case ${1} in
load)
if [ ${#} -ne 1 ]; then
usage
fi
# Write quick load file args # Launch Previous Game if any
echo -n "" > "${INSTANT_PLAY_FILE}" if [ -f "${INSTANT_PLAY_FILE}" ]; then
for arg in "$@"; do keymap resume
if $(echo "${arg}" | egrep -q '[[:space:]]'); then echo -n "Found Instant Play file, restarting previous game with command: "
echo $(head -n 1 "${INSTANT_PLAY_FILE}")
rm -f "${RESUME_PLAY_FILE}"
mv "${INSTANT_PLAY_FILE}" "${RESUME_PLAY_FILE}"
source "${RESUME_PLAY_FILE}"
rm -f "${RESUME_PLAY_FILE}"
keymap default
termfix_all
fi
;;
# Add quotes around arguments containing spaces save)
echo -n "\"${arg}\" " >> "${INSTANT_PLAY_FILE}" if [ ${#} -lt 2 ]; then
else usage
echo -n "${arg} " >> "${INSTANT_PLAY_FILE}" fi
fi shift
done
# Add the magic sauce to launch the process in background, record the # Write quick load file args
# PID into a file, wait for the process to terminate and erase the echo -n "" > "${INSTANT_PLAY_FILE}"
# recorded PID for arg in "$@"; do
cat << EOF >> "${INSTANT_PLAY_FILE}"
# Add quotes around all arguments
echo -n "'${arg}' " >> "${INSTANT_PLAY_FILE}"
done
# Add the magic sauce to launch the process in background,
# record the PID into a file, wait for the process to
# terminate and erase the recorded PID
cat << EOF >> "${INSTANT_PLAY_FILE}"
& &
record_pid \$! record_pid \$!
wait \$! wait \$!
erase_pid erase_pid
EOF EOF
# Now terminate gracefully # Now terminate gracefully
exec shutdown_funkey exec shutdown_funkey
;;
*)
usage
;;
esac
exit 0

View File

@ -4,8 +4,6 @@
#set -x #set -x
LOCK_FILE="/var/lock/launcher.lock" LOCK_FILE="/var/lock/launcher.lock"
INSTANT_PLAY_FILE="/mnt/instant_play"
RESUME_PLAY_FILE="/mnt/resume_play"
PREVENT_LAUNCHER_FILE="/mnt/prevent_launcher" PREVENT_LAUNCHER_FILE="/mnt/prevent_launcher"
REBOOTING_FILE="/run/rebooting" REBOOTING_FILE="/run/rebooting"
@ -16,22 +14,6 @@ if [ -f "${LOCK_FILE}" ]; then
fi fi
touch "${LOCK_FILE}" touch "${LOCK_FILE}"
# Sanity cmd: in case these files do not exist
mkdir -p "${MEDNAFEN_HOME}"
cp "/usr/games/lynxboot.img" "/usr/games/mednafen-09x.cfg" "${MEDNAFEN_HOME}/"
# Launch Previous Game if any
if [ -f "${INSTANT_PLAY_FILE}" ]; then
keymap resume
echo "Found Instant Play file, restarting previous game with command: "$(head -n 1 "${INSTANT_PLAY_FILE}")
rm -f "${RESUME_PLAY_FILE}"
mv "${INSTANT_PLAY_FILE}" "${RESUME_PLAY_FILE}"
source "${RESUME_PLAY_FILE}"
rm -f "${RESUME_PLAY_FILE}"
keymap default
termfix_all
fi
# Then loop to launch the launcher indefinitely # Then loop to launch the launcher indefinitely
while true; do while true; do

View File

@ -4,7 +4,7 @@
# #
################################################################################ ################################################################################
FCEUX_VERSION = 959126d FCEUX_VERSION = f089cec
FCEUX_SITE_METHOD = git FCEUX_SITE_METHOD = git
FCEUX_SITE = https://github.com/FunKey-Project/fceux.git FCEUX_SITE = https://github.com/FunKey-Project/fceux.git
FCEUX_LICENSE = GPL-2.0 FCEUX_LICENSE = GPL-2.0

View File

@ -4,7 +4,7 @@
# #
################################################################################ ################################################################################
PCSX_REARMED_VERSION = ce405c0 PCSX_REARMED_VERSION = a2f9326
PCSX_REARMED_SITE_METHOD = git PCSX_REARMED_SITE_METHOD = git
PCSX_REARMED_SITE = https://github.com/FunKey-Project/pcsx_rearmed.git PCSX_REARMED_SITE = https://github.com/FunKey-Project/pcsx_rearmed.git
PCSX_REARMED_LICENSE = GPL-2.0 PCSX_REARMED_LICENSE = GPL-2.0

View File

@ -4,7 +4,7 @@
# #
################################################################################ ################################################################################
POCKETSNES_VERSION = 033eb1c POCKETSNES_VERSION = 5eb2635
POCKETSNES_SITE_METHOD = git POCKETSNES_SITE_METHOD = git
POCKETSNES_SITE = https://github.com/FunKey-Project/PocketSNES.git POCKETSNES_SITE = https://github.com/FunKey-Project/PocketSNES.git
POCKETSNES_LICENSE = GPL-2.0 POCKETSNES_LICENSE = GPL-2.0

View File

@ -3,7 +3,7 @@
# gmenu2x # gmenu2x
# #
############################################################# #############################################################
GMENU2X_VERSION = 3e23dd2 GMENU2X_VERSION = 837e097
GMENU2X_SITE_METHOD = git GMENU2X_SITE_METHOD = git
GMENU2X_SITE = https://github.com/FunKey-Project/gmenu2x.git GMENU2X_SITE = https://github.com/FunKey-Project/gmenu2x.git
GMENU2X_LICENSE = GPL-2.0 GMENU2X_LICENSE = GPL-2.0

View File

@ -4,7 +4,7 @@
# #
################################################################################ ################################################################################
GNUBOY_VERSION = f23d3e3 GNUBOY_VERSION = a0d8d26
GNUBOY_SITE_METHOD = git GNUBOY_SITE_METHOD = git
GNUBOY_SITE = https://github.com/FunKey-Project/gnuboy.git GNUBOY_SITE = https://github.com/FunKey-Project/gnuboy.git
GNUBOY_LICENSE = GPL-2.0 GNUBOY_LICENSE = GPL-2.0

View File

@ -4,7 +4,7 @@
# #
################################################################################ ################################################################################
GPSP_VERSION = 3e776a9 GPSP_VERSION = b573bc6
GPSP_SITE_METHOD = git GPSP_SITE_METHOD = git
GPSP_SITE = https://github.com/FunKey-Project/gpsp.git GPSP_SITE = https://github.com/FunKey-Project/gpsp.git
GPSP_LICENSE = GPL-2.0 GPSP_LICENSE = GPL-2.0

View File

@ -4,7 +4,7 @@
# #
################################################################################ ################################################################################
MEDNAFEN_VERSION = f81201c MEDNAFEN_VERSION = d535dff
MEDNAFEN_SITE_METHOD = git MEDNAFEN_SITE_METHOD = git
MEDNAFEN_SITE = https://github.com/FunKey-Project/mednafen-git.git MEDNAFEN_SITE = https://github.com/FunKey-Project/mednafen-git.git
MEDNAFEN_LICENSE = GPL-2.0+ MEDNAFEN_LICENSE = GPL-2.0+

View File

@ -4,7 +4,7 @@
# #
################################################################################ ################################################################################
PICODRIVE_VERSION = 0582aba PICODRIVE_VERSION = 59b9892
PICODRIVE_SITE_METHOD = git PICODRIVE_SITE_METHOD = git
PICODRIVE_SITE = https://github.com/FunKey-Project/picodrive.git PICODRIVE_SITE = https://github.com/FunKey-Project/picodrive.git
PICODRIVE_LICENSE = MAME PICODRIVE_LICENSE = MAME

View File

@ -4,7 +4,7 @@
# #
################################################################################ ################################################################################
RETROFE_VERSION = 7fc674e RETROFE_VERSION = 77ccbc2
RETROFE_SITE_METHOD = git RETROFE_SITE_METHOD = git
RETROFE_SITE = https://github.com/FunKey-Project/RetroFE.git RETROFE_SITE = https://github.com/FunKey-Project/RetroFE.git
RETROFE_DEPENDENCIES = gstreamer1 gst1-plugins-base sdl sdl_image sdl_mixer sdl_sound sdl_ttf libglib2 sqlite zlib RETROFE_DEPENDENCIES = gstreamer1 gst1-plugins-base sdl sdl_image sdl_mixer sdl_sound sdl_ttf libglib2 sqlite zlib