make keymap work with Instant Play
Signed-off-by: Michel-FK <michel.stempin@funkey-project.com>
This commit is contained in:
parent
fd35689bdf
commit
240b8fea15
|
@ -1,14 +1,113 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Check number of args
|
# Uncomment the following line to get debug info
|
||||||
if [ ${#} -ne 1 ]; then
|
#set -x
|
||||||
echo "Usage: $(basename ${0}) keymap_file"
|
|
||||||
|
SELF=$(basename ${0})
|
||||||
|
LAST_MAPPING="/mnt/FunKey/.last_mapping.key"
|
||||||
|
FIFO="/tmp/fkgpiod.fifo"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: ${SELF} default"
|
||||||
|
echo " ${SELF} load <config_file>"
|
||||||
|
echo " ${SELF} resume"
|
||||||
|
echo " ${SELF} rom <rom_path>"
|
||||||
|
echo " ${SELF} save <config_file>"
|
||||||
exit 1
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
log() {
|
||||||
|
logger -t "${SELF}[$$]" "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
write_fifo() {
|
||||||
|
echo "${1}" >"${FIFO}" 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check number of args
|
||||||
|
if [ ${#} -lt 1 ]; then
|
||||||
|
usage
|
||||||
fi
|
fi
|
||||||
if [ "${1}" = "reset" ]; then
|
|
||||||
keymap_file="/etc/fkgpiod.conf"
|
# Create FIFO it it does not exist yet
|
||||||
else
|
if [ ! -p "${FIFO}" ]; then
|
||||||
keymap_file="${1}"
|
rm -f "${FIFO}"
|
||||||
|
log "FIFO does not exist, create it"
|
||||||
|
mkfifo "${FIFO}"
|
||||||
|
chmod 0640 "${FIFO}"
|
||||||
fi
|
fi
|
||||||
echo "LOAD ${keymap_file}" >/tmp/fkgpiod.fifo 2>/dev/null
|
|
||||||
|
case "${1}" in
|
||||||
|
default)
|
||||||
|
if [ ${#} -ne 1 ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
log "default: LOAD /etc/fkgpiod.conf"
|
||||||
|
write_fifo "LOAD /etc/fkgpiod.conf"
|
||||||
|
;;
|
||||||
|
|
||||||
|
load)
|
||||||
|
if [ ${#} -ne 2 ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
config_file="${2}"
|
||||||
|
log "load: LOAD ${config_file}"
|
||||||
|
write_fifo "LOAD ${config_file}"
|
||||||
|
log "load: SAVE ${LAST_MAPPING}"
|
||||||
|
write_fifo "SAVE ${LAST_MAPPING}"
|
||||||
|
;;
|
||||||
|
|
||||||
|
resume)
|
||||||
|
if [ ${#} -ne 1 ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
if [ -f "${LAST_MAPPING}" ]; then
|
||||||
|
log "resume: LOAD ${LAST_MAPPING}"
|
||||||
|
write_fifo "LOAD ${LAST_MAPPING}"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
rom)
|
||||||
|
if [ ${#} -gt 2 ]; then
|
||||||
|
usage
|
||||||
|
elif [ ${#} -eq 1 ]; then
|
||||||
|
console_keymap=""
|
||||||
|
rom_keymap=""
|
||||||
|
else
|
||||||
|
rom_path="${2}"
|
||||||
|
console_keymap="$(dirname "${rom_path}")/default_config.key"
|
||||||
|
rom_keymap="${rom_path%.*}.key"
|
||||||
|
fi
|
||||||
|
if [ -f "${console_keymap}" ]; then
|
||||||
|
log "rom: LOAD ${console_keymap}"
|
||||||
|
write_fifo "LOAD ${console_keymap}"
|
||||||
|
fi
|
||||||
|
for desktop_file in $(ls /opk/*.desktop 2>/dev/null); do
|
||||||
|
opk_keymap=$(grep FK-Keymap= "${desktop_file}" | cut -d '=' -f 2)
|
||||||
|
if [ -f "${opk_keymap}" ]; then
|
||||||
|
log "rom: LOAD ${opk_keymap}"
|
||||||
|
write_fifo "LOAD ${opk_keymap}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ -f "${rom_keymap}" ]; then
|
||||||
|
log "rom: LOAD ${rom_keymap}"
|
||||||
|
write_fifo "LOAD ${rom_keymap}"
|
||||||
|
fi
|
||||||
|
log "rom: SAVE ${LAST_MAPPING}"
|
||||||
|
write_fifo "SAVE ${LAST_MAPPING}"
|
||||||
|
;;
|
||||||
|
|
||||||
|
save)
|
||||||
|
if [ ${#} -ne 2 ]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
config_file="${2}"
|
||||||
|
log "save: SAVE ${config_file}"
|
||||||
|
write_fifo "SAVE ${config_file}"
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -22,11 +22,13 @@ cp "/usr/games/lynxboot.img" "/usr/games/mednafen-09x.cfg" "${MEDNAFEN_HOME}/"
|
||||||
|
|
||||||
# Launch Previous Game if any
|
# Launch Previous Game if any
|
||||||
if [ -f "${INSTANT_PLAY_FILE}" ]; then
|
if [ -f "${INSTANT_PLAY_FILE}" ]; then
|
||||||
|
keymap resume
|
||||||
echo "Found Instant Play file, restarting previous game with command: "$(head -n 1 "${INSTANT_PLAY_FILE}")
|
echo "Found Instant Play file, restarting previous game with command: "$(head -n 1 "${INSTANT_PLAY_FILE}")
|
||||||
rm -f "${RESUME_PLAY_FILE}"
|
rm -f "${RESUME_PLAY_FILE}"
|
||||||
mv "${INSTANT_PLAY_FILE}" "${RESUME_PLAY_FILE}"
|
mv "${INSTANT_PLAY_FILE}" "${RESUME_PLAY_FILE}"
|
||||||
source "${RESUME_PLAY_FILE}"
|
source "${RESUME_PLAY_FILE}"
|
||||||
rm -f "${RESUME_PLAY_FILE}"
|
rm -f "${RESUME_PLAY_FILE}"
|
||||||
|
keymap default
|
||||||
termfix_all
|
termfix_all
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -64,7 +66,7 @@ while true; do
|
||||||
termfix_all
|
termfix_all
|
||||||
|
|
||||||
# In case retrofe/opkrun quits with errors, reset default key mapping
|
# In case retrofe/opkrun quits with errors, reset default key mapping
|
||||||
keymap reset
|
keymap default
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# WD to prevent 100% CPU
|
# WD to prevent 100% CPU
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
FKGPIOD_VERSION = fkgpiod-FunKey-1.0.0
|
FKGPIOD_VERSION = 20b1a37
|
||||||
FKGPIOD_SITE_METHOD = git
|
FKGPIOD_SITE_METHOD = git
|
||||||
FKGPIOD_SITE = https://github.com/FunKey-Project/fkgpiod.git
|
FKGPIOD_SITE = https://github.com/FunKey-Project/fkgpiod.git
|
||||||
FKGPIOD_SITE_LICENSE = GPL-2.1+
|
FKGPIOD_SITE_LICENSE = GPL-2.1+
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
# libopk
|
# libopk
|
||||||
#
|
#
|
||||||
#############################################################
|
#############################################################
|
||||||
LIBOPK_VERSION = libopk-FunKey-1.0.2
|
LIBOPK_VERSION = 4ad3eb6
|
||||||
LIBOPK_SITE_METHOD = git
|
LIBOPK_SITE_METHOD = git
|
||||||
LIBOPK_SITE = https://github.com/FunKey-Project/libopk.git
|
LIBOPK_SITE = https://github.com/FunKey-Project/libopk.git
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
RETROFE_VERSION = RetroFE-FunKey-1.1.2
|
RETROFE_VERSION = 9a9989d
|
||||||
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
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
FKGPIOD_VERSION = e74f688
|
FKGPIOD_VERSION = 20b1a37
|
||||||
FKGPIOD_SITE_METHOD = git
|
FKGPIOD_SITE_METHOD = git
|
||||||
FKGPIOD_SITE = https://github.com/FunKey-Project/fkgpiod.git
|
FKGPIOD_SITE = https://github.com/FunKey-Project/fkgpiod.git
|
||||||
FKGPIOD_SITE_LICENSE = GPL-2.1+
|
FKGPIOD_SITE_LICENSE = GPL-2.1+
|
||||||
|
|
Loading…
Reference in New Issue