use new Instant Play system

Signed-off-by: Michel-FK <michel.stempin@funkey-project.com>
This commit is contained in:
Michel-FK 2021-01-01 16:02:43 +01:00
parent 504ff1b66a
commit 7cc4acff1a
36 changed files with 254 additions and 100 deletions

View File

@ -53,7 +53,7 @@
7+13, SHELL_COMMAND, quick_action_volume_down, Fn+A, Volume--
7+11, SHELL_COMMAND, quick_action_bright_up, Fn+B, Brightness++
7+14, SHELL_COMMAND, quick_action_bright_down, Fn+X, Brightness--
10, SHELL_COMMAND, sched_shutdown 1 & signal_usr1_to_emulators, N_OE, Quick save and Poweroff because of N_OE
10, SHELL_COMMAND, sched_shutdown 1, N_OE, Instant Play save and Poweroff because of N_OE
7+15+2, SHELL_COMMAND, display_notif_system_stats, Fn+L1+L2, display system cpu and ram usage
#7+12, KEYBOARD, KEY_G, KEY_G, Brightness++

View File

@ -38,7 +38,7 @@ null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr
#::ctrlaltdel:/sbin/reboot
# Stuff to do before rebooting
::shutdown:/etc/init.d/rcK
::shutdown:/sbin/swapoff -a
::shutdown:/bin/umount -r /
::shutdown:/bin/umount -r /mnt
#::shutdown:/etc/init.d/rcK
#::shutdown:/sbin/swapoff -a
#::shutdown:/bin/umount -r /
#::shutdown:/bin/umount -r /mnt

View File

@ -56,4 +56,5 @@ assembly_tests >/dev/null 2>&1
# Start launcher
echo "Start launcher"
start_launcher >/dev/null 2>&1 &
#start_launcher >/dev/null 2>&1 &
start_launcher &

View File

@ -1,8 +1,13 @@
#!/bin/sh
# Security
cp /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/
export HOME=/tmp/funkey
mkdir -p ${HOME}
cd ${HOME}
mednafen -fs 1 -gg.stretch full "$1"
# Launch the process in background, record the PID into a file, wait
# for the process to terminate and erase the recorded PID
mednafen -fs 1 -gg.stretch full "$1"&
record_pid $!
wait $!
erase_pid

View File

@ -3,4 +3,10 @@
export HOME=/tmp/funkey
mkdir -p ${HOME}
cd ${HOME}
sdlgnuboy --syncrtc "$1"
# Launch the process in background, record the PID into a file, wait
# for the process to terminate and erase the recorded PID
sdlgnuboy --syncrtc "$1"&
record_pid $!
wait $!
erase_pid

View File

@ -2,5 +2,12 @@
export HOME=/tmp/funkey
mkdir -p ${HOME}
# Launch the process in background, record the PID into a file, wait
# for the process to terminate and erase the recorded PID
cd ${HOME}
gpsp "$1"
gpsp "$1"&
record_pid $!
wait $!
erase_pid

View File

@ -3,4 +3,10 @@
export HOME=/tmp/funkey
mkdir -p ${HOME}
cd ${HOME}
gpsp "$1"
# Launch the process in background, record the PID into a file, wait
# for the process to terminate and erase the recorded PID
gpsp "$1"&
record_pid $!
wait $!
erase_pid

View File

@ -1,8 +1,13 @@
#!/bin/sh
# Security
cp /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/
export HOME=/tmp/funkey
mkdir -p ${HOME}
cd ${HOME}
mednafen -fs 1 -lynx.stretch full "$1"
# Launch the process in background, record the PID into a file, wait
# for the process to terminate and erase the recorded PID
mednafen -fs 1 -lynx.stretch full "$1"&
record_pid $!
wait $!
erase_pid

View File

@ -1,8 +1,13 @@
#!/bin/sh
# Security
cp /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/
export HOME=/tmp/funkey
mkdir -p ${HOME}
cd ${HOME}
mednafen -sound 1 -soundrate 22050 -soundbufsize 100 -vdriver sdl -frameskip 1 -fs 0 "$1"
# Launch the process in background, record the PID into a file, wait
# for the process to terminate and erase the recorded PID
mednafen -sound 1 -soundrate 22050 -soundbufsize 100 -vdriver sdl -frameskip 1 -fs 0 "$1"&
record_pid $!
wait $!
erase_pid

View File

@ -3,4 +3,10 @@
export HOME=/tmp/funkey
mkdir -p ${HOME}
cd ${HOME}
PicoDrive "$1"
# Launch the process in background, record the PID into a file, wait
# for the process to terminate and erase the recorded PID
PicoDrive "$1"&
record_pid $!
wait $!
erase_pid

View File

@ -3,5 +3,10 @@
export HOME=/tmp/funkey
mkdir -p ${HOME}
cd ${HOME}
fceux "$1"
# Launch the process in background, record the PID into a file, wait
# for the process to terminate and erase the recorded PID
fceux "$1"&
record_pid $!
wait $!
erase_pid

View File

@ -1,8 +1,13 @@
#!/bin/sh
# Security
cp /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/
export HOME=/tmp/funkey
mkdir -p ${HOME}
cd ${HOME}
mednafen -fs 1 -ngp.stretch full "$1"
# Launch the process in background, record the PID into a file, wait
# for the process to terminate and erase the recorded PID
mednafen -fs 1 -ngp.stretch full "$1"&
record_pid $!
wait $!
erase_pid

View File

@ -1,8 +1,13 @@
#!/bin/sh
# Security
cp /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/
export HOME=/tmp/funkey
mkdir -p ${HOME}
cd ${HOME}
mednafen -fs 1 -force_module pce_fast -pce_fast.stretch full "$1"
# Launch the process in background, record the PID into a file, wait
# for the process to terminate and erase the recorded PID
mednafen -fs 1 -force_module pce_fast -pce_fast.stretch full "$1"&
record_pid $!
wait $!
erase_pid

View File

@ -1,6 +1,11 @@
#!/bin/sh
export HOME=/tmp/funkey
mkdir -p ${HOME}
cd ${HOME}
pcsx -frameskip -cdfile "$1"
# Launch the process in background, record the PID into a file, wait
# for the process to terminate and erase the recorded PID
pcsx -frameskip -cdfile "$1"&
record_pid $!
wait $!
erase_pid

View File

@ -3,5 +3,10 @@
export HOME=/tmp/funkey
mkdir -p ${HOME}
cd ${HOME}
#pcsx -frameskip -cdfile "$1"
pcsx -cdfile "$1"
# Launch the process in background, record the PID into a file, wait
# for the process to terminate and erase the recorded PID
pcsx -cdfile "$1"&
record_pid $!
wait $!
erase_pid

View File

@ -3,4 +3,10 @@
export HOME=/tmp/funkey
mkdir -p ${HOME}
cd ${HOME}
PicoDrive "$1"
# Launch the process in background, record the PID into a file, wait
# for the process to terminate and erase the recorded PID
PicoDrive "$1"&
record_pid $!
wait $!
erase_pid

View File

@ -3,4 +3,10 @@
export HOME=/tmp/funkey
mkdir -p ${HOME}
cd ${HOME}
psnes "$1"
# Launch the process in background, record the PID into a file, wait
# for the process to terminate and erase the recorded PID
psnes "$1"&
record_pid $!
wait $!
erase_pid

View File

@ -3,4 +3,10 @@
export HOME=/tmp/funkey
mkdir -p ${HOME}
cd ${HOME}
psnes "$1"
# Launch the process in background, record the PID into a file, wait
# for the process to terminate and erase the recorded PID
psnes "$1"&
record_pid $!
wait $!
erase_pid

View File

@ -1,8 +1,13 @@
#!/bin/sh
# Security
cp /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/
export HOME=/tmp/funkey
mkdir -p ${HOME}
cd ${HOME}
mednafen -fs 1 -wswan.stretch full "$1"
# Launch the process in background, record the PID into a file, wait
# for the process to terminate and erase the recorded PID
mednafen -fs 1 -wswan.stretch full "$1"&
record_pid $!
wait $!
erase_pid

View File

@ -1,5 +1,9 @@
#!/bin/sh
## Register ourself as the running FunKey task for receiving USR1
## signal for shutting down
echo $$ > "/var/run/funkey.pid"
## Check if tests must be run
RUN_ENV_VAR=$(fw_printenv -n assembly_tests 2>/dev/null)
if [ "x${RUN_ENV_VAR}" != "x1" ]; then
@ -40,6 +44,9 @@ function function_magnet_detected_ok {
## Kill scheduled shutdown
pkill sched_shutdown
## Kill the funkey_prod_screen binary
killall -s USR1 "${PROD_SCREEN_BIN} > /dev/null 2>&1
## Write magnet_detected file
if $test_failed; then
echo "1" > $MAGNET_DETECTED_FILE
@ -58,6 +65,9 @@ function function_magnet_detected_ok {
## Function called when SIGUSR1 is caught while NOT waiting for it
function function_magnet_detected_ko {
echo "ERROR: Caught SIGUSR1 signal (magnet detected!)"
## Kill the funkey_prod_screen binary
killall -s USR1 "${PROD_SCREEN_BIN} > /dev/null 2>&1
sync
}

View File

@ -0,0 +1,11 @@
#!/bin/sh
# Uncomment the following line to get debug info
#set -x
if [ ${#} != 0 ]; then
echo "Usage: $(basename ${0})"
exit 1
fi
pkill sched_powerdown
exit 0

View File

@ -0,0 +1,12 @@
#!/bin/sh
# Uncomment the following line to get debug info
#set -x
# Check args
if [ ${#} -ne 0 ]; then
echo "Usage: $(basename ${0})"
exit 1
fi
rm -f /var/run/funkey.pid
exit 0

View File

@ -0,0 +1,37 @@
#!/bin/sh
# Uncomment the following line to get debug info
#set -x
# Check args
if [ ${#} -eq 0 ]; then
echo "Usage: $(basename ${0}) args..."
exit 1
fi
INSTANT_PLAY_FILE="/mnt/instant_play"
# Write quick load file args
echo -n "" > "${INSTANT_PLAY_FILE}"
for arg in "$@"; do
if $(echo "${arg}" | egrep -q '[[:space:]]'); then
# Add quotes around arguments containing spaces
echo -n "\"${arg}\" " >> "${INSTANT_PLAY_FILE}"
else
echo -n "${arg} " >> "${INSTANT_PLAY_FILE}"
fi
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 \$!
wait \$!
erase_pid
EOF
# Now terminate gracefully
exec shutdown_funkey

View File

@ -1,4 +0,0 @@
#!/bin/sh
killall mednafen gpsp psnes pcsx sdlgnuboy PicoDriveBin
exit 0

View File

@ -0,0 +1,12 @@
#!/bin/sh
# Uncomment the following line to get debug info
#set -x
# Check args
if [ ${#} -ne 1 ]; then
echo "Usage: $(basename ${0}) pid"
exit 1
fi
echo ${1} > /var/run/funkey.pid
exit 0

View File

@ -1,15 +1,21 @@
#!/bin/sh
if [ ${#} != 1 ]; then
echo "Usage: $0 seconds_before_shutdown"
# Uncomment the following line to get debug info
#set -x
if [ ${#} != 1 -o "${1}" -eq 0 ]; then
echo "Usage: $(basename ${0}) grace_delay"
exit 1
fi
nb_secs_to_wait=$1
# Send USR1 signal to the running FunKey process to warn about
# impending shutdown
pkill -USR1 -F /var/run/funkey.pid > /dev/null 2>&1
# Wait $nb_secs_to_wait seconds to catch signal USR2
# If the signal is caught, then it means a process canceled this shutdown
sleep ${nb_secs_to_wait}
# Delay for the given grace period seconds to catch signal USR2.
# If the signal is caught, then it means the running FunKey process
# canceled this shutdown and will handle it by itself.
sleep ${1}
# Too late to cancel: init shutdown
# Delay expired, initiate shutdown
shutdown_funkey

View File

@ -9,5 +9,7 @@ start_audio_amp 0 >/dev/null 2>&1
# Force Read Only
ro
umount -r /mnt
# Poweroff
poweroff

View File

@ -1,23 +0,0 @@
#!/bin/sh
# This should replaced by storing the correct PID before
# launching an emulator and signaling only this one.
RUN_ENV_VAR=$(fw_printenv -n assembly_tests 2>/dev/null)
if [ "x${RUN_ENV_VAR}" == "x1" ]; then
# First this one
killall -s USR1 assembly_tests > /dev/null 2>&1
# Then this one
killall -s USR1 funkey_prod_screens > /dev/null 2>&1
fi
# Send signal to all PCSX first (time critical)
killall -s USR1 pcsx > /dev/null 2>&1
# Send signal to all other emulators
killall -s USR1 gpsp psnes sdlgnuboy PicoDrive mednafen fceux > /dev/null 2>&1
# Send signal to launchers
killall -s USR1 retrofe gmenu2x > /dev/null 2>&1
exit 0

View File

@ -1,58 +1,60 @@
#!/bin/sh
LOCK_FILE=/var/lock/launcher.lock
PREVENT_LAUNCHER_FILE=/mnt/prevent_launcher
PREVENT_LAUNCHER_FILE2=/boot/prevent_launcher
QUICK_LOAD_FILE=/mnt/quick_load_cmd
GMENU2X_FILE=/mnt/gmenu2x
GMENU2X_HOME=/mnt/funkey/.gmenu2x
# Uncomment the following line to get debug info
#set -x
if [ -f ${LOCK_FILE} ]; then
LOCK_FILE="/var/lock/launcher.lock"
INSTANT_PLAY_FILE="/mnt/instant_play"
GMENU2X_FILE="/mnt/gmenu2x"
GMENU2X_HOME="/mnt/funkey/.gmenu2x"
if [ -f "${LOCK_FILE}" ]; then
echo "${LOCK_FILE} already exists"
exit 1
fi
touch ${LOCK_FILE}
touch "${LOCK_FILE}"
mkdir -p ${MEDNAFEN_HOME}
cp /usr/games/lynxboot.img /usr/games/mednafen-09x.cfg ${MEDNAFEN_HOME}/
mkdir -p "${MEDNAFEN_HOME}"
cp "/usr/games/lynxboot.img" "/usr/games/mednafen-09x.cfg" "${MEDNAFEN_HOME}/"
mkdir -p ${GMENU2X_HOME}
mkdir -p /mnt/apps
mkdir -p "${GMENU2X_HOME}"
mkdir -p "/mnt/apps"
# Launch Previous Game
if [ -f ${QUICK_LOAD_FILE} ]; then
command=$(cat ${QUICK_LOAD_FILE})
echo "Found quick load file, restarting previous game with command:"
echo ${command}
rm ${QUICK_LOAD_FILE}
eval ${command}
# Launch Previous Game if any
if [ -f "${INSTANT_PLAY_FILE}" ]; then
echo "Found Instant Play file, restarting previous game with command: "$(head -n 1 "${INSTANT_PLAY_FILE}")
source "${INSTANT_PLAY_FILE}"
rm -f "${INSTANT_PLAY_FILE}"
termfix_all
fi
# Loop to launch launcher indefinitely
# Then loop to launch the launcher indefinitely
while true; do
# Check if prevent launcher file present
if [ -f ${PREVENT_LAUNCHER_FILE} ]; then
echo "Found file: ${PREVENT_LAUNCHER_FILE}, not launching launcher"
sleep 5
elif [ -f ${PREVENT_LAUNCHER_FILE2} ]; then
echo "Found file: ${PREVENT_LAUNCHER_FILE2}, not launching launcher"
if [ -f "${PREVENT_LAUNCHER_FILE}" ]; then
echo "${PREVENT_LAUNCHER_FILE} file found, not starting launcher"
sleep 5
else
if [ -f ${GMENU2X_FILE} ]; then
if [ -f "${GMENU2X_FILE}" ]; then
# Launch gmenu2x
gmenu2x
gmenu2x&
else
# Launch Retrofe
retrofe
retrofe&
fi
# Record the PID into a file, wait for the
# process to terminate and erase the recorded PID
record_pid $!
wait $!
erase_pid
# In case retrofe quits with errors, clear graphic VT
termfix_all
fi
done
rm ${LOCK_FILE}
rm "${LOCK_FILE}"
exit 0

View File

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

View File

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

View File

@ -4,7 +4,7 @@
#
################################################################################
POCKETSNES_VERSION = PocketSNES-FunKey-1.00
POCKETSNES_VERSION = 2d5e38d
POCKETSNES_SITE_METHOD = git
POCKETSNES_SITE = https://github.com/FunKey-Project/PocketSNES.git
POCKETSNES_LICENSE = GPL-2.0

View File

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

View File

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

View File

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

View File

@ -4,7 +4,7 @@
#
################################################################################
PICODRIVE_VERSION = picodrive-FunKey-1.00
PICODRIVE_VERSION = e37c0fa
PICODRIVE_SITE_METHOD = git
PICODRIVE_SITE = https://github.com/FunKey-Project/picodrive.git
PICODRIVE_LICENSE = MAME