From 0c47a30eeaea70cedf36894f50d0a091517a42e3 Mon Sep 17 00:00:00 2001 From: worstcase-scenario <83265453+worstcase-scenario@users.noreply.github.com> Date: Fri, 23 Oct 2026 12:44:39 +0200 Subject: [PATCH 1/2] mod_EmuELEC: also clear oversized sdl_controllerconfig for ports calling get_controls before sourcing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The existing E2BIG fix wraps get_controls, but the wrapper is only installed if the mod file is sourced before get_controls runs. Several ports (e.g. Sonic 1, Sonic 2, Sonic CD) call get_controls first and source mod_${CFW_NAME}.txt afterwards. In that case sdl_controllerconfig still holds the full gamecontrollerdb, gets exported as SDL_GAMECONTROLLERCONFIG, and every execve() fails with “Argument list too long”. This adds a one-line check right after the wrapper that clears the variable when it is already oversized at source time. Both call orders are now covered, and SDL still receives the mappings via SDL_GAMECONTROLLERCONFIG_FILE. --- PortMaster/mod_EmuELEC.txt | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/PortMaster/mod_EmuELEC.txt b/PortMaster/mod_EmuELEC.txt index 40f59f2d..2258a744 100644 --- a/PortMaster/mod_EmuELEC.txt +++ b/PortMaster/mod_EmuELEC.txt @@ -2,6 +2,7 @@ # # SPDX-License-Identifier: MIT # + ## Modular - EmuELEC # # A modular file that is sourced for specific script lines required by ports running on EmuELEC. @@ -19,18 +20,23 @@ GODOT_OPTS="--resolution ${DISPLAY_WIDTH}x${DISPLAY_HEIGHT} -f" # exceeds MAX_ARG_STRLEN (131072 bytes) and makes every execve() fail with E2BIG. # SDL still gets the mappings via SDL_GAMECONTROLLERCONFIG_FILE. if declare -f get_controls >/dev/null 2>&1; then - eval "_pm_get_controls_orig() $(declare -f get_controls | tail -n +2)" - - get_controls() { - _pm_get_controls_orig "$@" - [ "${#sdl_controllerconfig}" -gt 100000 ] && sdl_controllerconfig="" - } + eval "_pm_get_controls_orig() $(declare -f get_controls | tail -n +2)" + get_controls() { + _pm_get_controls_orig "$@" + [ "${#sdl_controllerconfig}" -gt 100000 ] && sdl_controllerconfig="" + } fi +# Older ports call get_controls before sourcing this file. +[ "${#sdl_controllerconfig}" -gt 100000 ] && sdl_controllerconfig="" + pm_platform_helper() { - if [ -e "$PM_PIPE" ]; then - PortMasterDialogExit - fi - # DO SOMETHING HERE - printf "" + pm_message_close + + if [ -e "$PM_PIPE" ]; then + PortMasterDialogExit + fi + + # DO SOMETHING HERE + printf "" } From b2929ab791870f0bc89a4e43b9a6549fc8cc5a3b Mon Sep 17 00:00:00 2001 From: worstcase-scenario <83265453+worstcase-scenario@users.noreply.github.com> Date: Fri, 23 Oct 2026 12:48:30 +0200 Subject: [PATCH 2/2] Refactor get_controls function and clean up code --- PortMaster/mod_EmuELEC.txt | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/PortMaster/mod_EmuELEC.txt b/PortMaster/mod_EmuELEC.txt index 2258a744..15fe25d7 100644 --- a/PortMaster/mod_EmuELEC.txt +++ b/PortMaster/mod_EmuELEC.txt @@ -2,7 +2,6 @@ # # SPDX-License-Identifier: MIT # - ## Modular - EmuELEC # # A modular file that is sourced for specific script lines required by ports running on EmuELEC. @@ -20,23 +19,23 @@ GODOT_OPTS="--resolution ${DISPLAY_WIDTH}x${DISPLAY_HEIGHT} -f" # exceeds MAX_ARG_STRLEN (131072 bytes) and makes every execve() fail with E2BIG. # SDL still gets the mappings via SDL_GAMECONTROLLERCONFIG_FILE. if declare -f get_controls >/dev/null 2>&1; then - eval "_pm_get_controls_orig() $(declare -f get_controls | tail -n +2)" - get_controls() { - _pm_get_controls_orig "$@" - [ "${#sdl_controllerconfig}" -gt 100000 ] && sdl_controllerconfig="" - } + eval "_pm_get_controls_orig() $(declare -f get_controls | tail -n +2)" + + get_controls() { + _pm_get_controls_orig "$@" + [ "${#sdl_controllerconfig}" -gt 100000 ] && sdl_controllerconfig="" + } fi # Older ports call get_controls before sourcing this file. [ "${#sdl_controllerconfig}" -gt 100000 ] && sdl_controllerconfig="" pm_platform_helper() { - pm_message_close - - if [ -e "$PM_PIPE" ]; then - PortMasterDialogExit - fi + pm_message_close - # DO SOMETHING HERE - printf "" + if [ -e "$PM_PIPE" ]; then + PortMasterDialogExit + fi + # DO SOMETHING HERE + printf "" }