From 364e7dc282bc3ef3f53daead9fe5a24ee04e5790 Mon Sep 17 00:00:00 2001 From: Voyager Date: Sun, 16 Aug 2026 10:38:24 -0400 Subject: [PATCH] fix: preserve PortMaster controller mappings through Weston --- docs/PORTMASTER.md | 18 +++++++++++------ scripts/build_portmaster.sh | 27 +++++++++++++++---------- scripts/portmaster/NETfishing.sh | 9 ++++++--- scripts/portmaster/launch-netfishing.sh | 23 +++++++++++++++++++++ 4 files changed, 57 insertions(+), 20 deletions(-) create mode 100755 scripts/portmaster/launch-netfishing.sh diff --git a/docs/PORTMASTER.md b/docs/PORTMASTER.md index 91c8457..f83b252 100644 --- a/docs/PORTMASTER.md +++ b/docs/PORTMASTER.md @@ -154,12 +154,18 @@ The device-verified Godot mapping is: `scripts/portmaster/NETfishing.sh` must replace the incompatible SDL2 entry with the Godot entry when that SDL2 GUID is selected. Do not append the two entries with a newline. WestonPack reconstructs the wrapped game command -through a shell, so values passed in that command can be split into unintended -commands. Controller names may legally contain spaces, which caused this -failure with the `GO-Super Gamepad` mapping. Export the single selected -`SDL_GAMECONTROLLERCONFIG` value through the outer `env` invocation, before -`westonwrap.sh`, so Weston and the game inherit it without tokenizing the -mapping text. +through a shell, so raw mapping values passed in that command can be split into +unintended commands. Controller names may legally contain spaces, which caused +this failure with the `GO-Super Gamepad` mapping. The outer Weston environment +also does not reliably preserve the corrected muOS mapping for the game. + +Write the exact selected mapping to `conf/cache/controller_mapping.txt` before +starting Weston. Weston must launch `launch-netfishing.sh`, which reads that +file, exports `SDL_GAMECONTROLLERCONFIG`, and immediately replaces itself with +the game process. This applies the mapping at the same point as the working +0.10.1 launcher without passing its raw text through WestonPack's command +reconstruction. Do not move the mapping back to either side of +`westonwrap.sh`. Legacy GPTOKEYB builds can load their compiled default keyboard map when no `-c` file is supplied. That map translates face buttons, D-pad directions, and diff --git a/scripts/build_portmaster.sh b/scripts/build_portmaster.sh index 752fe9d..3d7a585 100755 --- a/scripts/build_portmaster.sh +++ b/scripts/build_portmaster.sh @@ -117,6 +117,8 @@ install -m 0755 "${TEMPLATE_ROOT}/NETfishing.sh" "${STAGE_ROOT}/NETfishing.sh" install -m 0644 "${TEMPLATE_ROOT}/port.json" "${GAME_ROOT}/port.json" install -m 0644 "${TEMPLATE_ROOT}/netfishing.gptk" \ "${GAME_ROOT}/netfishing.gptk" +install -m 0755 "${TEMPLATE_ROOT}/launch-netfishing.sh" \ + "${GAME_ROOT}/launch-netfishing.sh" install -m 0755 "${ARM64_EXECUTABLE}" "${GAME_ROOT}/NETfishing.aarch64" install -m 0644 "${ARM64_PCK}" "${GAME_ROOT}/NETfishing.pck" install -m 0644 "${TEMPLATE_ROOT}/gameinfo.xml" "${GAME_ROOT}/gameinfo.xml" @@ -219,19 +221,22 @@ grep -Fq 'PROFILE_PATH="$CONFDIR/performance_profile"' \ "${STAGE_ROOT}/NETfishing.sh" grep -Fq 'NETFISHING_PERFORMANCE_PROFILE=light' \ "${STAGE_ROOT}/NETfishing.sh" -readonly CONTROLLER_ENV_LINE="$( - grep -nF 'SDL_GAMECONTROLLERCONFIG="$netfishing_controllerconfig"' \ - "${STAGE_ROOT}/NETfishing.sh" | cut -d: -f1 -)" -readonly WESTON_LAUNCH_LINE="$( - grep -nF '"$WESTON_DIR/westonwrap.sh" headless noop kiosk crusty_x11egl' \ - "${STAGE_ROOT}/NETfishing.sh" | cut -d: -f1 -)" -if [[ -z "${CONTROLLER_ENV_LINE}" || -z "${WESTON_LAUNCH_LINE}" || \ - "${CONTROLLER_ENV_LINE}" -ge "${WESTON_LAUNCH_LINE}" ]]; then - echo "SDL_GAMECONTROLLERCONFIG must be exported before westonwrap.sh." >&2 +grep -Fq 'CONTROLLER_MAPPING_FILE="$CONFDIR/cache/controller_mapping.txt"' \ + "${STAGE_ROOT}/NETfishing.sh" +grep -Fq 'printf '\''%s\n'\'' "$netfishing_controllerconfig" > "$CONTROLLER_MAPPING_FILE"' \ + "${STAGE_ROOT}/NETfishing.sh" +grep -Fq '"$GAME_LAUNCHER"' "${STAGE_ROOT}/NETfishing.sh" +grep -Fq '"$CONTROLLER_MAPPING_FILE"' "${STAGE_ROOT}/NETfishing.sh" +if grep -Fq 'SDL_GAMECONTROLLERCONFIG="$netfishing_controllerconfig"' \ + "${STAGE_ROOT}/NETfishing.sh"; then + echo "Raw controller mappings must not be passed through westonwrap.sh." >&2 exit 1 fi +grep -Fq 'SDL_GAMECONTROLLERCONFIG="$(<"$CONTROLLER_MAPPING_FILE")"' \ + "${GAME_ROOT}/launch-netfishing.sh" +grep -Fq 'export SDL_GAMECONTROLLERCONFIG' \ + "${GAME_ROOT}/launch-netfishing.sh" +grep -Fq 'exec "$@"' "${GAME_ROOT}/launch-netfishing.sh" grep -Fq 'GPTOKEYB_CONFIG="$GAMEDIR/netfishing.gptk"' \ "${STAGE_ROOT}/NETfishing.sh" grep -Fq '$GPTOKEYB "NETfishing.aarch64" -c "$GPTOKEYB_CONFIG" &' \ diff --git a/scripts/portmaster/NETfishing.sh b/scripts/portmaster/NETfishing.sh index fe23caf..a2574de 100755 --- a/scripts/portmaster/NETfishing.sh +++ b/scripts/portmaster/NETfishing.sh @@ -29,7 +29,9 @@ fi CONFDIR="$GAMEDIR/conf" GAME_EXECUTABLE="$GAMEDIR/NETfishing.aarch64" +GAME_LAUNCHER="$GAMEDIR/launch-netfishing.sh" GPTOKEYB_CONFIG="$GAMEDIR/netfishing.gptk" +CONTROLLER_MAPPING_FILE="$CONFDIR/cache/controller_mapping.txt" WESTON_DIR="/tmp/netfishing-weston" WESTON_RUNTIME="weston_pkg_0.2" HARBOURMASTER="$controlfolder/harbourmaster" @@ -76,6 +78,7 @@ elif [ -n "$sdl_controllerconfig" ]; then else netfishing_controllerconfig="$GODOT_MUOS_MAPPING" fi +printf '%s\n' "$netfishing_controllerconfig" > "$CONTROLLER_MAPPING_FILE" NETFISHING_GODOT_OPTIONS=() NETFISHING_GAME_ENVIRONMENT=() @@ -125,15 +128,15 @@ esac $GPTOKEYB "NETfishing.aarch64" -c "$GPTOKEYB_CONFIG" & pm_platform_helper "$GAME_EXECUTABLE" -$ESUDO env \ - CRUSTY_RESOLUTION="${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}" \ - SDL_GAMECONTROLLERCONFIG="$netfishing_controllerconfig" \ +$ESUDO env CRUSTY_RESOLUTION="${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}" \ "$WESTON_DIR/westonwrap.sh" headless noop kiosk crusty_x11egl \ XDG_DATA_HOME="$CONFDIR/data" \ XDG_CONFIG_HOME="$CONFDIR/config" \ XDG_CACHE_HOME="$CONFDIR/cache" \ GODOT_SILENCE_ROOT_WARNING=1 \ "${NETFISHING_GAME_ENVIRONMENT[@]}" \ + "$GAME_LAUNCHER" \ + "$CONTROLLER_MAPPING_FILE" \ "$GAME_EXECUTABLE" \ "${NETFISHING_GODOT_OPTIONS[@]}" \ --resolution "${DISPLAY_WIDTH}x${DISPLAY_HEIGHT}" \ diff --git a/scripts/portmaster/launch-netfishing.sh b/scripts/portmaster/launch-netfishing.sh new file mode 100755 index 0000000..50f2ec9 --- /dev/null +++ b/scripts/portmaster/launch-netfishing.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +if [[ $# -lt 2 ]]; then + echo "Usage: $0 [arguments...]" >&2 + exit 2 +fi + +CONTROLLER_MAPPING_FILE="$1" +shift + +if [[ ! -r "$CONTROLLER_MAPPING_FILE" ]]; then + echo "Controller mapping file is not readable: $CONTROLLER_MAPPING_FILE" >&2 + exit 1 +fi + +SDL_GAMECONTROLLERCONFIG="$(<"$CONTROLLER_MAPPING_FILE")" +if [[ "$SDL_GAMECONTROLLERCONFIG" != *,*,* ]]; then + echo "Controller mapping file is malformed: $CONTROLLER_MAPPING_FILE" >&2 + exit 1 +fi + +export SDL_GAMECONTROLLERCONFIG +exec "$@"