Refactor volume sense into input sense, improve its response time + cpu usage, and merge jslisten's kill function into the daemon.

This commit is contained in:
fewtarius 2024-02-27 19:46:25 +00:00
parent e6a39f1840
commit 05c4a27750
No known key found for this signature in database
GPG key ID: F4AE55305D1B8C1A
84 changed files with 362 additions and 337 deletions

View file

@ -115,7 +115,7 @@ This document describes all available systems emulators and cores available for
|SNK|Neo Geo CD (neocd)|1994|`neocd`|.cue .iso .chd|**retroarch:** neocd (default)<br>**retroarch:** fbneo<br>|
|SNK|Neo Geo Pocket (ngp)|1998|`ngp`|.ngc .ngp .zip .7z|**retroarch:** beetle_ngp (default)<br>**retroarch:** race<br>**mednafen:** ngp<br>|
|SNK|Neo Geo Pocket Color (ngpc)|1999|`ngpc`|.ngc .zip .7z|**retroarch:** beetle_ngp (default)<br>**retroarch:** race<br>**mednafen:** ngp<br>|
|Sony|PlayStation (psx)|1994|`psx`|.bin .cue .img .mdf .pbp .toc .cbn .m3u .ccd .chd .iso|**retroarch:** beetle_psx (default)<br>**duckstation:** duckstation-sa<br>**mednafen:** psx<br>**retroarch:** duckstation<br>**retroarch:** swanstation<br>|
|Sony|PlayStation (psx)|1994|`psx`|.bin .cue .img .mdf .pbp .toc .cbn .m3u .ccd .chd .iso|**retroarch:** beetle_psx (default)<br>**mednafen:** psx<br>**duckstation:** duckstation-sa<br>**retroarch:** duckstation<br>**retroarch:** swanstation<br>|
|Sony|PlayStation 2 (ps2)|2000|`ps2`|.iso .mdf .nrg .bin .img .dump .gz .cso .chd|**pcsx2:** pcsx2-sa (default)<br>**retroarch:** pcsx2<br>|
|Sony|PlayStation 3 (ps3)|2006|`ps3`|.ps3 .psn|**rpcs3:** rpcs3-sa (default)<br>|
|Sony|PlayStation Portable (psp)|2004|`psp`|.iso .cso .pbp .chd|**ppsspp:** ppsspp-sa (default)<br>**retroarch:** ppsspp<br>|

View file

@ -1,5 +1,5 @@
#!/bin/bash
. /etc/profile
jslisten set "moonlight"
set_kill set "moonlight"
QT_QPA_PLATFORM=wayland moonlight

View file

@ -4,7 +4,7 @@
# Copyright (C) 2022-present JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile
jslisten set "PortMaster"
set_kill set "PortMaster"
#Make sure PortMaster exists in .config/PortMaster
if [ ! -d "/storage/.config/PortMaster" ]; then

View file

@ -164,5 +164,5 @@ export MESA_GLSL_VERSION_OVERRIDE=330
#Run Aethersx2 emulator
export SDL_AUDIODRIVER=pulseaudio
jslisten set "-9 aethersx2"
set_kill set "-9 aethersx2"
${EMUPERF} /usr/bin/@APPIMAGE@ -fullscreen "${1}"

View file

@ -6,7 +6,7 @@
. /etc/profile
jslisten set "-9 amiberry"
set_kill set "-9 amiberry"
# Set some common variables
AMIBERRY_DIR="/storage/.config/amiberry"

View file

@ -8,7 +8,7 @@
# Ensure we're using pulseaudio
export SDL_AUDIODRIVER=pulseaudio
jslisten set "-9 cemu"
set_kill set "-9 cemu"
if [ -z "${PASINK}" ]
then

View file

@ -4,7 +4,7 @@
# Copyright (C) 2022-present JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile
jslisten set "-9 citra"
set_kill set "-9 citra"
#load gptokeyb support files
control-gen_init.sh

View file

@ -4,7 +4,7 @@
# Copyright (C) 2022-present JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile
jslisten set "-9 dolphin-emu-nogui"
set_kill set "-9 dolphin-emu-nogui"
#Check if dolphin-emu exists in .config
if [ ! -d "/storage/.config/dolphin-emu" ]; then

View file

@ -4,7 +4,7 @@
# Copyright (C) 2022-present JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile
jslisten set "-9 dolphin-emu-nogui"
set_kill set "-9 dolphin-emu-nogui"
#Check if dolphin-emu exists in .config
if [ ! -d "/storage/.config/dolphin-emu" ]; then

View file

@ -5,7 +5,7 @@
. /etc/profile
jslisten set "-9 drastic"
set_kill set "-9 drastic"
#load gptokeyb support files
control-gen_init.sh

View file

@ -4,7 +4,7 @@
# Copyright (C) 2022-present JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile
jslisten set "-9 duckstation-nogui"
set_kill set "-9 duckstation-nogui"
#Copy config folder to .config/duckstation
if [ ! -d "/storage/.config/duckstation" ]; then

View file

@ -4,7 +4,7 @@
# Copyright (C) 2022-present JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile
jslisten set "-9 flycast"
set_kill set "-9 flycast"
#Check if flycast exists in .config
if [ ! -d "/storage/.config/flycast" ]; then

View file

@ -4,7 +4,7 @@
# Copyright (C) 2021-present 351ELEC (https://github.com/351ELEC)
. /etc/profile
jslisten set "-9 gzdoom"
set_kill set "-9 gzdoom"
RUN_DIR="/storage/roms/doom"
CONFIG="/storage/.config/gzdoom/gzdoom.ini"

View file

@ -5,7 +5,7 @@
# Source predefined functions and variables
. /etc/profile
jslisten set "-9 kronos"
set_kill set "-9 kronos"
ROM_DIR="/storage/roms/saturn/kronos"
CONFIG_DIR="/storage/.config/kronos/qt"

View file

@ -5,7 +5,7 @@
. /etc/profile
jslisten set "-9 melonDS"
set_kill set "-9 melonDS"
if [ ! -d "/storage/.config/melonDS" ]; then
mkdir -p "/storage/.config/melonDS"

View file

@ -6,7 +6,7 @@
. /etc/profile
jslisten set "-9 mupen64plus"
set_kill set "-9 mupen64plus"
# Emulation Station features
GAME=$(echo "${1}"| sed "s#^/.*/##")

View file

@ -4,7 +4,7 @@
# Copyright (C) 2022-present JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile
jslisten set "-9 NanoBoyAdvance"
set_kill set "-9 NanoBoyAdvance"
#Check if nanoboyadvance exists in .config
if [ ! -d "/storage/.config/nanoboyadvance" ]; then

View file

@ -6,7 +6,7 @@
GAME=${1//[\\]/}
jslisten set "-9 pcsx2-qt"
set_kill set "-9 pcsx2-qt"
FPS=$(get_setting show_fps ps2 "${GAME}")

View file

@ -44,5 +44,5 @@ cp -f /usr/config/SDL-GameControllerDB/gamecontrollerdb.txt ${GAME_DIR}/sdl_cont
# mark the binary executable to cover cases where the user adding the binaries doesn't know or forgets.
chmod 0755 ${LAUNCH_DIR}/${STATIC_BIN}
jslisten set "-9 ${STATIC_BIN} start_pico8.sh"
set_kill set "-9 ${STATIC_BIN} start_pico8.sh"
${LAUNCH_DIR}/${STATIC_BIN} -home -root_path ${GAME_DIR} -joystick 0 ${OPTIONS} "${CART}"

View file

@ -129,6 +129,6 @@ fi
ARG=${1//[\\]/}
jslisten set "-9 ppsspp"
set_kill set "-9 ppsspp"
${EMUPERF} ppsspp --pause-menu-exit "${ARG}"

View file

@ -49,11 +49,11 @@ sed -i "s#Resolution:.*\$#Resolution: $(fbwidth)x$(fbheight)#g" /storage/.config
# Run rpcs3
if [ "$SUI" = "1" ]; then
export QT_QPA_PLATFORM=wayland
jslisten set "-9 rpcs3"
set_kill set "-9 rpcs3"
/usr/bin/rpcs3
else
export QT_QPA_PLATFORM=xcb
export SDL_AUDIODRIVER=pulseaudio
jslisten set "-9 rpcs3"
set_kill set "-9 rpcs3"
/usr/bin/rpcs3 --no-gui "$GAME_PATH"
fi

View file

@ -4,7 +4,7 @@
# Copyright (C) 2022-present JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile
jslisten set "-9 Ryujinx"
set_kill set "-9 Ryujinx"
if [ ! -d "/storage/.config/Ryujinx" ]; then
mkdir -p "/storage/.config/Ryujinx"

View file

@ -4,7 +4,7 @@
. /etc/profile
jslisten set "-9 @EMU@"
set_kill set "-9 @EMU@"
CONFIG_PATH="/storage/.config/vice"
SOURCE_PATH="/usr/config/vice"

View file

@ -4,7 +4,7 @@
# Copyright (C) 2022-present JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile
jslisten set "-9 Vita3K"
set_kill set "-9 Vita3K"
OUTPUT_PATH="/storage/.config/vita3k/launcher"
GAME="${1}"

View file

@ -2,7 +2,7 @@
# Copyright (C) 2022-present JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile
jslisten set "-9 xemu"
set_kill set "-9 xemu"
#Check if xemu exists in .config
if [ ! -d "/storage/.config/xemu" ]; then

View file

@ -6,7 +6,7 @@
# Source predefined functions and variables
. /etc/profile
jslisten set "-9 yabasanshiro"
set_kill set "-9 yabasanshiro"
ROM_DIR="/storage/roms/saturn/yabasanshiro"
CONFIG_DIR="/storage/.config/yabasanshiro"

View file

@ -266,7 +266,7 @@ export QT_QPA_PLATFORM=wayland-egl
#Yuzu won't work with the pipewire driver yet
export SDL_AUDIODRIVER=pulseaudio
jslisten set "-9 yuzu"
set_kill set "-9 yuzu"
#Run Yuzu emulator
if [ "$SUI" = "1" ]

View file

@ -4,7 +4,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
# Device Features
DEVICE_VOLUMECTL="true"
DEVICE_POWER_LED="false"
DEVICE_PLAYBACK_PATH_SPK="HP"
DEVICE_PLAYBACK_PATH_HP="SPK"

View file

@ -1,8 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
#Set dummy key for RG351M/P
cat <<EOF >/storage/.config/profile.d/100-jslisten-hotkey
BTN_VOLBRIGHT_HOTKEY=999 # Select
EOF

View file

@ -4,7 +4,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
# Device Features
DEVICE_VOLUMECTL="true"
DEVICE_POWER_LED="false"
DEVICE_PLAYBACK_PATH_SPK="SPK"
DEVICE_PLAYBACK_PATH_HP="HP"

View file

@ -4,7 +4,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
DEVICE_FAKE_JACKSENSE="true"
DEVICE_VOLUMECTL="true"
DEVICE_POWER_LED="true"
DEVICE_HEADPHONE_DEV="/dev/input/by-path/platform-rk817-sound-event"
DEVICE_BRIGHTNESS="70"

View file

@ -4,7 +4,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
DEVICE_FAKE_JACKSENSE="false"
DEVICE_VOLUMECTL="true"
DEVICE_POWER_LED="false"
DEVICE_BRIGHTNESS="153"
EOF

View file

@ -5,7 +5,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
# Device Features
DEVICE_FAKE_JACKSENSE="true"
DEVICE_VOLUMECTL="true"
DEVICE_AUDIO_MIXER="DAC"
DEVICE_PLAYBACK_PATH_SPK="1*"
DEVICE_PLAYBACK_PATH_HP="0*"

View file

@ -4,7 +4,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
# Device Features
DEVICE_VOLUMECTL="true"
DEVICE_POWER_LED="false"
DEVICE_PLAYBACK_PATH_SPK="HP"
DEVICE_PLAYBACK_PATH_HP="SPK"

View file

@ -4,7 +4,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
# Device Features
DEVICE_VOLUMECTL="true"
DEVICE_POWER_LED="false"
DEVICE_PLAYBACK_PATH_SPK="HP"
DEVICE_PLAYBACK_PATH_HP="SPK"

View file

@ -5,7 +5,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
# Device Features
#DEVICE_FAKE_JACKSENSE="true"
DEVICE_VOLUMECTL="true"
#DEVICE_AUDIO_MIXER="DAC"
#DEVICE_PLAYBACK_PATH_SPK="1*"
#DEVICE_PLAYBACK_PATH_HP="0*"

View file

@ -4,7 +4,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
# Device Features
DEVICE_VOLUMECTL="true"
DEVICE_POWER_LED="false"
DEVICE_PLAYBACK_PATH_SPK="HP"
DEVICE_PLAYBACK_PATH_HP="SPK"

View file

@ -1,8 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
#Set dummy key for RG351M/P
cat <<EOF >/storage/.config/profile.d/100-jslisten-hotkey
BTN_VOLBRIGHT_HOTKEY=16 # Select
EOF

View file

@ -5,7 +5,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
DEVICE_FAKE_JACKSENSE="true"
DEVICE_HEADPHONE_DEV="/dev/input/by-path/platform-gpio-keys-event"
DEVICE_VOLUMECTL="true"
DEVICE_POWER_LED="false"
DEVICE_BRIGHTNESS="128"
DEVICE_TEMP_SENSOR=("/sys/devices/virtual/thermal/thermal_zone0/temp" "/sys/devices/virtual/thermal/thermal_zone3/temp" "/sys/devices/virtual/thermal/thermal_zone2/temp")

View file

@ -4,7 +4,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
# Device Features
DEVICE_VOLUMECTL="true"
DEVICE_VOLUME="100"
DEVICE_POWER_LED="false"
DEVICE_BRIGHTNESS="hardware"

View file

@ -4,7 +4,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
# Device Features
DEVICE_VOLUMECTL="true"
DEVICE_POWER_LED="false"
DEVICE_PLAYBACK_PATH_SPK="SPK"
DEVICE_PLAYBACK_PATH_HP="HP"

View file

@ -4,7 +4,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
# Device Features
DEVICE_VOLUMECTL="true"
DEVICE_POWER_LED="false"
DEVICE_SW_HP_SWITCH="true"
DEVICE_PLAYBACK_PATH_SPK="SPK"

View file

@ -4,7 +4,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
# Device Features
DEVICE_VOLUMECTL="true"
DEVICE_POWER_LED="false"
DEVICE_PLAYBACK_PATH_SPK="SPK"
DEVICE_PLAYBACK_PATH_HP="HP"

View file

@ -4,7 +4,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
# Device Features
DEVICE_VOLUMECTL="true"
DEVICE_POWER_LED="false"
DEVICE_PLAYBACK_PATH_SPK="SPK"
DEVICE_PLAYBACK_PATH_HP="HP"

View file

@ -1,7 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
cat <<EOF >/storage/.config/profile.d/100-jslisten-hotkey
BTN_VOLBRIGHT_HOTKEY=12 # Select
EOF

View file

@ -4,7 +4,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
# Device Features
DEVICE_VOLUMECTL="true"
DEVICE_POWER_LED="false"
DEVICE_PLAYBACK_PATH_SPK="HP"
DEVICE_PLAYBACK_PATH_HP="SPK"

View file

@ -4,7 +4,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
DEVICE_FAKE_JACKSENSE="true"
DEVICE_VOLUMECTL="true"
DEVICE_POWER_LED="false"
DEVICE_BRIGHTNESS="128"
EOF

View file

@ -7,6 +7,5 @@
### Set the default device configuration
cat <<EOF >/storage/.config/profile.d/001-device_config
DEVICE_BASE_TDP="6w"
DEVICE_VOLUMECTL="true"
DEVICE_BRIGHTNESS="hardware"
EOF

View file

@ -7,6 +7,5 @@
### Set the default device configuration
cat <<EOF >/storage/.config/profile.d/001-device_config
DEVICE_BASE_TDP="15w"
DEVICE_VOLUMECTL="true"
DEVICE_BRIGHTNESS="hardware"
EOF

View file

@ -4,7 +4,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
DEVICE_FAKE_JACKSENSE="false"
DEVICE_VOLUMECTL="true"
DEVICE_POWER_LED="false"
DEVICE_BRIGHTNESS="128"
EOF

View file

@ -4,7 +4,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
DEVICE_FAKE_JACKSENSE="false"
DEVICE_VOLUMECTL="true"
DEVICE_POWER_LED="false"
DEVICE_BRIGHTNESS="128"
EOF

View file

@ -3,7 +3,6 @@
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
cat <<EOF >/storage/.config/profile.d/001-device_config
DEVICE_VOLUMECTL="true"
DEVICE_BRIGHTNESS="128"
DEVICE_TEMP_SENSOR="/sys/devices/virtual/thermal/thermal_zone*/temp"

View file

@ -4,7 +4,6 @@
cat <<EOF >/storage/.config/profile.d/001-device_config
# Device Features
DEVICE_VOLUMECTL="true"
DEVICE_POWER_LED="false"
DEVICE_BRIGHTNESS="128"
DEVICE_TEMP_SENSOR=("/sys/devices/virtual/thermal/thermal_zone0/temp" "/sys/devices/virtual/thermal/thermal_zone3/temp" "/sys/devices/virtual/thermal/thermal_zone2/temp")

View file

@ -44,7 +44,6 @@ export SLOW_CORES \
DEVICE_TEMP_SENSOR \
DEVICE_TURBO_MODE \
DEVICE_VOLUME \
DEVICE_VOLUMECTL \
DEVICE_WIFI \
HDMI_DETECT_PATTERN \
HDMI_STATE \

View file

@ -12,7 +12,6 @@ J_DIR="/storage/.config/system"
J_CONF="${J_DIR}/configs/system.cfg"
J_CONF_LOCK="/tmp/.system.cfg.lock"
ES_CONF="/storage/.emulationstation/es_settings.cfg"
JSLISTENCONF="${J_DIR}/configs/jslisten.cfg"
function tocon() {
echo -ne "\033[1000H\033[2K==> ${*}" >/dev/console
@ -107,6 +106,21 @@ function sort_settings() {
rm -f "${J_CONF_LOCK}"
}
function set_kill() {
if [ "${1}" = "set" ]
then
cat <<EOF >/tmp/.process-kill-data
${2}
EOF
elif [ "${1}" = "stop" ]
then
if [ -e "/tmp/.process-kill-data" ]
then
rm -f "/tmp/.process-kill-data"
fi
fi
}
function set_setting() {
if [ ! -d "/storage/.config/system/configs" ]

View file

@ -69,12 +69,6 @@ ln -sf /usr/share/locale /storage/.config/emulationstation/locale >>/var/log/con
### Add items below this line that are safe to remove after a period of time.
################################################################################
### 20240111 - Add new jslisten hotkey
if [ -e "/storage/.config/jslisten_hotkeys" ]
then
grep BTN_VOLBRIGHT_HOTKEY /storage/.config/jslisten_hotkeys || echo -e "\nBTN_VOLBRIGHT_HOTKEY=999" >>/storage/.config/jslisten_hotkeys
fi
### 20240207 - Update Vita launchers and data.
rsync -ah --update /usr/config/vita3k/* /storage/.config/vita3k 2>/dev/null
rm -f "/storage/.config/vita3k/launcher/Start Vita3K.sh"

View file

@ -87,7 +87,7 @@ EOF
function quit() {
${VERBOSE} && log $0 "Cleaning up and exiting"
bluetooth enable
jslisten set "emulationstation"
set_kill set "emulationstation"
clear_screen
DEVICE_CPU_GOVERNOR=$(get_setting system.cpugovernor)
${DEVICE_CPU_GOVERNOR}
@ -138,13 +138,13 @@ esac
loginit "$1" "$2" "$3" "$4"
clear_screen
bluetooth disable
jslisten stop
set_kill stop
### Determine which emulator we're launching and make appropriate adjustments before launching.
${VERBOSE} && log $0 "Configuring for ${EMULATOR}"
case ${EMULATOR} in
mednafen)
jslisten set "-9 mednafen"
set_kill set "-9 mednafen"
RUNTHIS='${RUN_SHELL} /usr/bin/start_mednafen.sh "${ROMNAME}" "${CORE}" "${PLATFORM}"'
;;
retroarch)
@ -172,8 +172,8 @@ case ${EMULATOR} in
;;
esac
### Set jslisten to kill the appropriate retroarch
jslisten set "retroarch retroarch32"
### Set set_kill to kill the appropriate retroarch
set_kill set "retroarch retroarch32"
### Assume we're running 64bit Retroarch
RABIN="retroarch"

View file

@ -4,7 +4,7 @@
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
. /etc/profile
jslisten set "mpv"
set_kill set "mpv"
FBWIDTH="$(fbwidth)"
FBHEIGHT="$(fbheight)"

View file

@ -5,6 +5,6 @@
source /etc/profile
jslisten set "installer"
set_kill set "installer"
weston-terminal -f --command "/usr/bin/installer"

View file

@ -5,6 +5,6 @@
source /etc/profile
jslisten set "retroarch32"
set_kill set "retroarch32"
export LIBGL_DRIVERS_PATH="/usr/lib32/dri"
/usr/bin/retroarch32 --appendconfig /usr/config/retroarch/retroarch32bit-append.cfg

View file

@ -5,6 +5,6 @@
source /etc/profile
jslisten set "retroarch"
set_kill set "retroarch"
/usr/bin/retroarch --appendconfig /usr/config/retroarch/retroarch64bit-append.cfg

View file

@ -7,7 +7,7 @@
gptokeyb fileman textinput &
. /etc/profile
jslisten set "FileMan"
set_kill set "FileMan"
fileman

View file

@ -4,7 +4,7 @@
. /etc/profile
jslisten set "-HUP gmu.bin"
set_kill set "-HUP gmu.bin"
GMUPATH="/storage/.config/gmu"
GMUCONFIG="${GMUPATH}/gmu.conf"

View file

@ -22,12 +22,9 @@ headphones() {
fi
}
volumectl() {
if [ "${DEVICE_VOLUMECTL}" == "true" ]
then
log $0 "Volume control: ${1}"
systemctl ${1} volume >${EVENTLOG} 2>&1
fi
inputsense() {
log $0 "Input sense: ${1}"
systemctl ${1} input >${EVENTLOG} 2>&1
}
powerstate() {
@ -102,7 +99,7 @@ quirks() {
case $1 in
pre)
headphones stop
volumectl stop
inputsense stop
bluetooth stop
runtime_power_management on
wake_events disabled
@ -116,7 +113,7 @@ case $1 in
modules start
powerstate start
headphones start
volumectl start
inputsense start
bluetooth start
if [ "$(get_setting network.enabled)" == "1" ]
@ -133,7 +130,5 @@ case $1 in
log $0 "Restoring brightness to ${BRIGHTNESS}."
brightness set ${BRIGHTNESS} >${EVENTLOG} 2>&1
quirks post
systemctl restart jslisten >${EVENTLOG} 2>&1
;;
esac

View file

@ -19,7 +19,7 @@ makeinstall_target() {
cp ${PKG_DIR}/sources/scripts/fancontrol ${INSTALL}/usr/bin
cp ${PKG_DIR}/sources/scripts/headphone_sense ${INSTALL}/usr/bin
cp ${PKG_DIR}/sources/scripts/hdmi_sense ${INSTALL}/usr/bin
cp ${PKG_DIR}/sources/scripts/volume_sense ${INSTALL}/usr/bin
cp ${PKG_DIR}/sources/scripts/input_sense ${INSTALL}/usr/bin
cp ${PKG_DIR}/sources/scripts/bluetooth_sense ${INSTALL}/usr/bin
cp ${PKG_DIR}/sources/scripts/ledcontrol ${INSTALL}/usr/bin
cp ${PKG_DIR}/sources/scripts/turbomode ${INSTALL}/usr/bin

View file

@ -20,14 +20,6 @@ else
nohup systemctl stop headphones &
fi
if [ "${DEVICE_VOLUMECTL}" == "true" ]
then
tocon "Starting volume service..."
nohup systemctl start volume &
else
nohup systemctl stop volume &
fi
if [ "${DEVICE_HAS_HDMI}" == "true" ]
then
tocon "Starting hdmi service..."
@ -43,3 +35,6 @@ then
else
nohup systemctl stop batteryledstatus &
fi
tocon "Starting input service..."
nohup systemctl start input &

View file

@ -0,0 +1,282 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
# 2021-present pkegg
. /etc/profile
set -e
set -o pipefail
### Summary
# This script listens to input events and takes actions.
###
DEBUG=false
### Define matching values from evtest.
FUNCTION_VOLUME_UP_EVENT='*(KEY_VOLUME*UP), value 1' # Differentiate 'up' volume event
FUNCTION_VOLUME_DOWN_EVENT='*(KEY_VOLUME**DOWN), value 1' #Differentiate 'down' volume event
FUNCTION_MODIFIER_A_EVENT='*('${DEVICE_FUNC_KEYA_MODIFIER}'), value *'
FUNCTION_MODIFIER_B_EVENT='*('${DEVICE_FUNC_KEYB_MODIFIER}'), value *'
FUNCTION_HOTKEY_EVENT='*(BTN_TL), value *'
FUNCTION_SELECT_EVENT='*(BTN_SELECT), value *'
FUNCTION_START_EVENT='*(BTN_START), value *'
CONTROLLER_DISCONNECTED="*error reading: No such device"
DEVICE_DISCONNECTED="*error reading: No such device"
### Matches if a button was pressed (1), released (0) or held down (2)
PRESS='value [1-9]'
RELEASE='value 0'
### Function buttons should be defined as not pressed for later matching.
FN_A_PRESSED=false
FN_B_PRESSED=false
### Allow actions to be overriden in system.cfg
FN_A_ACTION_UP="$(get_setting fn_a.action.up)"
FN_A_ACTION_DOWN="$(get_setting fn_a.action.down)"
FN_B_ACTION_UP="$(get_setting fn_b.action.up)"
FN_B_ACTION_DOWN="$(get_setting fn_b.action.down)"
FN_AB_ACTION_UP="$(get_setting fn_ab.action.up)"
FN_AB_ACTION_DOWN="$(get_setting fn_ab.action.down)"
### Set sane defaults to manage volume, brightness, wireless on/off, and led on/off.
if [ -z "${FN_A_ACTION_UP}" ]
then
FN_A_ACTION_UP="brightness up"
fi
if [ -z "${FN_A_ACTION_DOWN}" ]
then
FN_A_ACTION_DOWN="brightness down"
fi
if [ -z "${FN_B_ACTION_UP}" ]
then
FN_B_ACTION_UP="wifictl enable"
fi
if [ -z "${FN_B_ACTION_DOWN}" ]
then
FN_B_ACTION_DOWN="wifictl disable"
fi
if [ -z "${FN_AB_ACTION_UP}" ]
then
FN_AB_ACTION_UP="ledcontrol"
fi
if [ -z "${FN_AB_ACTION_DOWN}" ]
then
FN_AB_ACTION_DOWN="ledcontrol poweroff"
fi
### Simple functions to execute button actions, including global kill.
execute_kill() {
if [ -e "/tmp/.process-kill-data" ]
then
TO_KILL="$(cat /tmp/.process-kill-data)"
${DEBUG} && log $0 "Execute: killall ${TO_KILL}"
killall ${TO_KILL} 2>/dev/null
fi
}
execute_action() {
${DEBUG} && log $0 "FN_A_PRESSED = ${FN_A_PRESSED} | FN_B_PRESSED = ${FN_B_PRESSED} | VAL = ${1}"
if [ "${FN_A_PRESSED}" = true ] && \
[ "${FN_B_PRESSED}" = true ]
then
${DEBUG} && log $0 "Executing FN_AB action"
case ${1} in
up)
${DEBUG} && log $0 "FN_AB (${FN_AB_ACTION_UP})"
${FN_AB_ACTION_UP}
;;
down)
${DEBUG} && log $0 "FN_AB (${FN_AB_ACTION_DOWN})"
${FN_AB_ACTION_DOWN}
;;
esac
elif [ "${FN_A_PRESSED}" = true ] && \
[ "${FN_B_PRESSED}" = false ]
then
${DEBUG} && log $0 "Executing FN_A action"
case ${1} in
up)
${DEBUG} && log $0 "FN_A (${FN_A_ACTION_UP})"
${FN_A_ACTION_UP}
;;
down)
${DEBUG} && log $0 "FN_A (${FN_A_ACTION_DOWN})"
${FN_A_ACTION_DOWN}
;;
esac
elif [ "${FN_A_PRESSED}" = false ] && \
[ "${FN_B_PRESSED}" = true ]
then
${DEBUG} && log $0 "Executing FN_B action"
case ${1} in
up)
${DEBUG} && log $0 "FN_B (${FN_B_ACTION_UP})"
${FN_B_ACTION_UP}
;;
down)
${DEBUG} && log $0 "FN_B (${FN_B_ACTION_DOWN})"
${FN_B_ACTION_DOWN}
;;
esac
else
${DEBUG} && log $0 "Executing Volume action"
volume ${1}
fi
}
### Search the system for useful devices to monitor for inputs.
get_devices() {
KJDEVS=false
FOUNDKEYS=false
FOUNDJOY=false
RETRY=5
while [ ${KJDEVS} = false ]
do
# Detect input devices automatically
for DEV in /dev/input/ev*
do
unset SUPPORTS
SUPPORTS=$(udevadm info ${DEV} | awk '/ID_INPUT_KEY=|ID_INPUT_JOYSTICK=/ {print $2}')
if [ -n "${SUPPORTS}" ]
then
DEVICE=$(udevadm info ${DEV} | awk 'BEGIN {FS="="} /DEVNAME=/ {print $2}')
INPUT_DEVICES+=("${DEVICE}")
if [[ "${SUPPORTS}" =~ ID_INPUT_KEY ]]
then
${DEBUG} && log $0 "Found Keyboard: ${DEVICE}"
FOUNDKEYS=true
elif [[ "${SUPPORTS}" =~ ID_INPUT_JOYSTICK ]]
then
${DEBUG} && log $0 "Found Joystick: ${DEVICE}"
FOUNDJOY=true
fi
fi
done
if [ "${FOUNDKEYS}" = "true" ] &&
[ "${FOUNDJOY}" = "true" ]
then
${DEBUG} && log $0 "Found all of the needed devices."
KJDEVS=true
break
fi
if [ "${RETRY}" -ge 5 ]
then
${DEBUG} && log $0 "Did not find all of the needed devices, but that may be OK. Breaking."
break
else
RETRY=$(( ${RETRY} + 1 ))
fi
sleep 1
done
}
get_devices
# If the input devices change, it may be a new controller
# so handle it here.
mkcontroller 2>/dev/null ||:
### Go into a cpu friendly loop that idles until a key is pressed. Take action when a known pattern of keys are pressed together.
(
for INPUT_DEVICE in ${INPUT_DEVICES[@]}
do
evtest "${INPUT_DEVICE}" 2>&1 &
done
wait
) | while read line; do
case ${line} in
(${CONTROLLER_DISCONNECTED})
${DEBUG} && log $0 "Reloading due to ${CONTROLLER_DEVICE} reattach..."
get_devices
;;
(${DEVICE_DISCONNECTED})
${DEBUG} && log $0 "Reloading due to ${DEVICE} reattach..."
get_devices
;;
(${FUNCTION_MODIFIER_A_EVENT})
if [[ "${line}" =~ ${PRESS} ]]
then
${DEBUG} && log $0 "${FUNCTION_MODIFIER_A_EVENT}: Pressed"
FN_A_PRESSED=true
elif [[ "${line}" =~ ${RELEASE} ]]
then
${DEBUG} && log $0 "${FUNCTION_MODIFIER_A_EVENT}: Released"
FN_A_PRESSED=false
fi
;;
(${FUNCTION_MODIFIER_B_EVENT})
if [[ "${line}" =~ ${PRESS} ]]
then
${DEBUG} && log $0 "${FUNCTION_MODIFIER_B_EVENT}: Pressed"
FN_B_PRESSED=true
elif [[ "${line}" =~ ${RELEASE} ]]
then
${DEBUG} && log $0 "${FUNCTION_MODIFIER_B_EVENT}: Released"
FN_B_PRESSED=false
fi
;;
(${FUNCTION_HOTKEY_EVENT})
if [[ "${line}" =~ ${PRESS} ]]
then
${DEBUG} && log $0 "${FUNCTION_HOTKEY_EVENT}: Pressed"
HOTKEY_PRESSED=true
elif [[ "${line}" =~ ${RELEASE} ]]
then
${DEBUG} && log $0 "${FUNCTION_HOTKEY_EVENT}: Released"
HOTKEY_PRESSED=false
fi
;;
(${FUNCTION_SELECT_EVENT})
if [[ "${line}" =~ ${PRESS} ]]
then
${DEBUG} && log $0 "${FUNCTION_SELECT_EVENT}: Pressed"
SELECT_PRESSED=true
if [ "${HOTKEY_PRESSED}" = true ] && \
[ "${START_PRESSED}" = true ]
then
execute_kill
fi
elif [[ "${line}" =~ ${RELEASE} ]]
then
${DEBUG} && log $0 "${FUNCTION_SELECT_EVENT}: Released"
SELECT_PRESSED=false
fi
;;
(${FUNCTION_START_EVENT})
if [[ "${line}" =~ ${PRESS} ]]
then
${DEBUG} && log $0 "${FUNCTION_START_EVENT}: Pressed"
START_PRESSED=true
if [ "${HOTKEY_PRESSED}" = true ] && \
[ "${SELECT_PRESSED}" = true ]
then
execute_kill
fi
elif [[ "${line}" =~ ${RELEASE} ]]
then
${DEBUG} && log $0 "${FUNCTION_START_EVENT}: Released"
START_PRESSED=false
fi
;;
(${FUNCTION_VOLUME_UP_EVENT})
execute_action up
;;
(${FUNCTION_VOLUME_DOWN_EVENT})
execute_action down
;;
esac
done

View file

@ -1,205 +0,0 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (C) 2023 JELOS (https://github.com/JustEnoughLinuxOS)
# 2021-present pkegg
. /etc/profile
set -e
set -o pipefail
LOG="/var/log/$(basename "$0").log"
### Summary
# This script listens to volume keys and adjusts volume
# Fn + Volume up/down will adjust brightness
###
# Event examples for reference
# type 1 (EV_KEY), code 114 (KEY_VOLUMEDOWN), value 1
# type 1 (EV_KEY), code 115 (KEY_VOLUMEUP), value 1
VOL_EVENT='*(KEY_VOLUME*, value *' # This matches all volume events
VOL_UP='*UP), value *' # Differentiate 'up' volume event
VOL_DOWN='*DOWN), value *' #Differentiate 'down' volume event
V_FUNC_KEYA_EVENT='*('${DEVICE_FUNC_KEYA_MODIFIER}'), value *'
V_FUNC_KEYB_EVENT='*('${DEVICE_FUNC_KEYB_MODIFIER}'), value *'
# Matches if a button was pressed (1), released (0) or held down (2)
PRESS='value [1-9]'
RELEASE='value 0'
# Volume repeat
VOLUME_REPEAT_MOD=4
# Brightness repeat
BRIGHTNESS_REPEAT_MOD=4
# Variable to keep track of Fn being currently pressed
FUNCA_PRESSED=no
FUNCB_PRESSED=no
CONTROLLER_DISCONNECTED="*error reading: No such device"
DEVICE_DISCONNECTED="*error reading: No such device"
get_devices() {
KJDEVS=false
FOUNDKEYS=false
FOUNDJOY=false
RETRY=5
while [ ${KJDEVS} = false ]
do
# Detect input devices automatically
for DEV in /dev/input/ev*
do
unset SUPPORTS
SUPPORTS=$(udevadm info ${DEV} | awk '/ID_INPUT_KEY=|ID_INPUT_JOYSTICK=/ {print $2}')
if [ -n "${SUPPORTS}" ]
then
DEVICE=$(udevadm info ${DEV} | awk 'BEGIN {FS="="} /DEVNAME=/ {print $2}')
INPUT_DEVICES+=("${DEVICE}")
if [[ "${SUPPORTS}" =~ ID_INPUT_KEY ]]
then
echo "Found Keyboard: ${DEVICE}" 2>&1 >${LOG}
FOUNDKEYS=true
elif [[ "${SUPPORTS}" =~ ID_INPUT_JOYSTICK ]]
then
echo "Found Joystick: ${DEVICE}" 2>&1 >${LOG}
FOUNDJOY=true
fi
fi
done
if [ "${FOUNDKEYS}" = "true" ] &&
[ "${FOUNDJOY}" = "true" ]
then
echo "Found all of the needed devices." 2>&1 >${LOG}
KJDEVS=true
break
fi
if [ "${RETRY}" -ge 5 ]
then
echo "Did not find all of the needed devices, but that may be OK. Breaking." 2>&1 >${LOG}
break
else
RETRY=$(( ${RETRY} + 1 ))
fi
sleep 1
done
}
get_devices
# If the input devices change, it may be a new controller
# so handle it here.
mkcontroller 2>/dev/null ||:
# Logic:
# - Listen to any input device events to get volume keys (not part of the joystick api)
# - Switch statement keeps high level cases to only 'volume' and 'V function key'
# this is to avoid processing for other events or creating a lot of cases as this will be called
# for all button pushes
# - Using 'read' means the loop is idle when no button is pressed
(
for INPUT_DEVICE in ${INPUT_DEVICES[@]}
do
evtest "${INPUT_DEVICE}" 2>&1 &
done
wait
) | while read line; do
case $line in
(${CONTROLLER_DISCONNECTED})
echo "Reloading due to ${CONTROLLER_DEVICE} reattach..." >${LOG} 2>&1
get_devices
;;
(${DEVICE_DISCONNECTED})
echo "Reloading due to ${DEVICE} reattach..." >${LOG} 2>&1
get_devices
;;
(${VOL_EVENT})
# We don't care when you 'let go' ('release') the volume button
if [[ "$line" =~ ${RELEASE} ]]; then
REPEAT_NUM=0
continue
fi
# Setup for 'brightness' if Fn pressed
if [[ "${FUNCA_PRESSED}" == "yes" ]]; then
COMMAND="/usr/bin/brightness"
UP="up"
DOWN="down"
REPEAT_MOD=${BRIGHTNESS_REPEAT_MOD}
elif [[ "${FUNCB_PRESSED}" == "yes" ]]; then
if [[ "${line}" == ${VOL_UP} ]]; then
COMMAND="/usr/bin/say"
UP="-b"
else
COMMAND="/usr/bin/wifictl"
WIFISTATE=$(get_setting network.enabled)
if [ "${WIFISTATE}" = 0 ]
then
DOWN="reconnect"
/usr/bin/say "WIFI On"
else
DOWN="disable"
/usr/bin/say "WIFI Off"
fi
fi
else
# Default to 'volume' if Fn a or b is not pressed
COMMAND="/usr/bin/volume"
UP="+"
DOWN="-"
REPEAT_MOD=${VOLUME_REPEAT_MOD}
fi
REPEAT_NUM=$(( ${REPEAT_NUM} + 1 ))
# This isn't time to evaluate repeat so just skip
if [[ "$line" == ${REPEAT_PRESS} && $(( ${REPEAT_NUM} % ${REPEAT_MOD} )) != "0" ]]; then
continue
fi
INCREMENT_AMOUNT=5
if [[ "${REPEAT_NUM}" -gt "20" ]]; then
INCREMENT_AMOUNT=10
fi
# Run the commands to adjust volume/brightness
if [[ "${line}" == ${VOL_UP} ]]; then
${COMMAND} ${UP} ${INCREMENT_AMOUNT} > /dev/null
read -t 0.1
elif [[ "${line}" == ${VOL_DOWN} ]]; then
${COMMAND} ${DOWN} ${INCREMENT_AMOUNT} > /dev/null
read -t 0.1
fi
;;
(${V_FUNC_KEYA_EVENT})
#Reset the number of repeats when Fn is pressed/release
# as repeat speed is different between volume/brightness
REPEAT_NUM=0
if [[ "${line}" =~ ${PRESS} ]]; then
FUNCA_PRESSED=yes
elif [[ "${line}" =~ ${RELEASE} ]]; then
FUNCA_PRESSED=no
fi
;;
(${V_FUNC_KEYB_EVENT})
#Reset the number of repeats when Fn is pressed/release
# as repeat speed is different between volume/brightness
REPEAT_NUM=0
if [[ "${line}" =~ ${PRESS} ]]; then
FUNCB_PRESSED=yes
elif [[ "${line}" =~ ${RELEASE} ]]; then
FUNCB_PRESSED=no
fi
;;
esac
done

View file

@ -7,7 +7,7 @@ StartLimitIntervalSec=0
[Service]
Environment=HOME=/storage
EnvironmentFile=/etc/profile
ExecStart=/usr/bin/volume_sense
ExecStart=/usr/bin/input_sense
Restart=always
RestartSec=1

View file

@ -2,6 +2,6 @@
### or detached so brightness and volume work across connected
### devices.
ACTION=="add|change", SUBSYSTEM=="input", KERNEL=="event*", RUN+="/usr/bin/killall volume_sense"
ACTION=="remove", SUBSYSTEM=="input", KERNEL=="event*", RUN+="/usr/bin/killall volume_sense"
ACTION=="add|change", KERNEL=="hci*", RUN+="/usr/bin/killall volume_sense"
ACTION=="add|change", SUBSYSTEM=="input", KERNEL=="event*", RUN+="/usr/bin/killall input_sense"
ACTION=="remove", SUBSYSTEM=="input", KERNEL=="event*", RUN+="/usr/bin/killall input_sense"
ACTION=="add|change", KERNEL=="hci*", RUN+="/usr/bin/killall input_sense"

View file

@ -49,4 +49,4 @@ do
systemctl import-environment ${VARIABLE}
done
jslisten set "emulationstation"
set_kill set "emulationstation"

View file

@ -43,6 +43,6 @@ then
systemctl import-environment LANGUAGE
fi
jslisten set "emulationstation"
set_kill set "emulationstation"
emulationstation --log-path /var/log --no-splash

View file

@ -75,8 +75,5 @@ DEVICE_BTN_DPAD_LEFT="${left}"
DEVICE_BTN_DPAD_RIGHT="${right}"
EOF
### Link jslisten to load after mkcontroller
ln -sf /usr/config/jslisten_profile /storage/.config/profile.d/099-jslisten
rm /tmp/${OUTFILE}

View file

@ -5,6 +5,6 @@
source /etc/profile
jslisten set "aethersx2-sa"
set_kill set "aethersx2-sa"
/usr/bin/aethersx2-sa >/dev/null 2>&1

View file

@ -5,6 +5,6 @@
source /etc/profile
jslisten set "cemu"
set_kill set "cemu"
/usr/bin/cemu >/dev/null 2>&1

View file

@ -5,6 +5,6 @@
source /etc/profile
jslisten set "hatarisa"
set_kill set "hatarisa"
/usr/bin/hatarisa >/dev/null 2>&1

View file

@ -5,6 +5,6 @@
source /etc/profile
jslisten set "pcsx2-sa"
set_kill set "pcsx2-sa"
/usr/bin/pcsx2-sa >/dev/null 2>&1

View file

@ -5,7 +5,7 @@
source /etc/profile
jslisten set "ppsspp"
set_kill set "ppsspp"
cp -f /storage/.config/SDL-GameControllerDB/gamecontrollerdb.txt /storage/.config/ppsspp/assets/gamecontrollerdb.txt

View file

@ -23,6 +23,6 @@ for FOLDER_LINK in "${FOLDER_LINKS[@]}"; do
ln -sf "$TARGET_FOLDER" "$SOURCE_FOLDER"
done
jslisten set "rpcs3"
set_kill set "rpcs3"
/usr/bin/rpcs3 >/dev/null 2>&1

View file

@ -5,6 +5,6 @@
source /etc/profile
jslisten set "Ryujinx"
set_kill set "Ryujinx"
/storage/.config/Ryujinx/Ryujinx >/dev/null 2>&1

View file

@ -5,6 +5,6 @@
source /etc/profile
jslisten set "scummvm"
set_kill set "scummvm"
/usr/bin/start_scummvm.sh sa

View file

@ -5,6 +5,6 @@
source /etc/profile
jslisten set "xemu-sa"
set_kill set "xemu-sa"
/usr/bin/xemu-sa >/dev/null 2>&1

View file

@ -5,6 +5,6 @@
source /etc/profile
jslisten set "yuzu"
set_kill set "yuzu"
/usr/bin/yuzu >/dev/null 2>&1

View file

@ -15,7 +15,7 @@ PKG_DEPENDS_TARGET="toolchain squashfs-tools:host dosfstools:host fakeroot:host
bash coreutils modules system-utils autostart quirks powerstate gnupg \
gzip six lynx xmlstarlet vim pyudev dialog dbus-python network jelos"
PKG_UI="emulationstation es-themes jslisten textviewer"
PKG_UI="emulationstation es-themes textviewer"
PKG_UI_TOOLS="fileman fbgrab"