From c3485a9bb66e3313b3dbfe24b1d2f0498f78d163 Mon Sep 17 00:00:00 2001 From: Xalcker Date: Fri, 2 Oct 2026 01:15:24 -0700 Subject: [PATCH] fix: rpcs3-pads ignora guitarras y baterias, que SDL lista como controles Co-Authored-By: Claude Sonnet 5.5 --- README.md | 5 ++++- lib/rpcs3.sh | 13 +++++++++++-- tests/test_rpcs3.bats | 22 ++++++++++++++++++++++ 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c6da26a..f960292 100644 --- a/README.md +++ b/README.md @@ -831,7 +831,10 @@ Variables de Cage/RPCS3: `input_configs/global/Default.yml`: con un control, ese es el jugador 1; con dos, el primero detectado es el 1 y el segundo el 2, con el mismo mapeo de botones. Sin controles no toca nada. Asi no hace falta saber el nombre SDL de cada modelo ni - elegirlo en la GUI. Limites: un control conectado **despues** de arrancar no se + elegirlo en la GUI. Las guitarras y baterias, que SDL tambien lista como controles, + se ignoran por nombre (Santroller, Guitar, Drum, Rock Band, Harmonix...); la + variable de entorno `RPCS3_PAD_EXCLUDE` (expresion regular) sustituye esa lista. + Limites: un control conectado **despues** de arrancar no se asigna hasta reiniciar el juego, y el orden "primero/segundo" sigue el de deteccion de SDL, que tras un arranque con los dos ya conectados depende de como los enumere el kernel. Si un control esta en modo X-input (p. ej. un 8BitDo, `Start+X` segun el diff --git a/lib/rpcs3.sh b/lib/rpcs3.sh index b1e5db1..2a05a0d 100644 --- a/lib/rpcs3.sh +++ b/lib/rpcs3.sh @@ -735,11 +735,20 @@ Uso: rpcs3-pads.py [--dry-run] [--config RUTA] [--sdl RUTA] """ import ctypes import os +import re import sys DEFAULT_CONFIG = os.path.expanduser("~/.config/rpcs3/input_configs/global/Default.yml") DEFAULT_SDL = "/opt/RPCS3/usr/lib/libSDL3.so.0" SDL_INIT_JOYSTICK, SDL_INIT_GAMEPAD = 0x00000200, 0x00002000 +# Los instrumentos (guitarras, baterias...) aparecen en SDL como controles genericos +# y se quedarian con el jugador 1. Se descartan por nombre; RPCS3_PAD_EXCLUDE (una +# expresion regular, sin distinguir mayusculas) sustituye esta lista. +DEFAULT_EXCLUDE = r"Santroller|Guitar|Drum|Keytar|Rock ?Band|Harmonix|Mustang|Stratocaster" + + +def is_instrument(name): + return re.search(os.environ.get("RPCS3_PAD_EXCLUDE") or DEFAULT_EXCLUDE, name, re.I) is not None def list_gamepads(sdl_path): @@ -760,7 +769,7 @@ def list_gamepads(sdl_path): raw = sdl.SDL_GetGamepadNameForID(ids[i]) pads.append((ids[i], raw.decode("utf-8", "replace") if raw else "")) sdl.SDL_Quit() - return [name for _, name in sorted(pads) if name] + return [name for _, name in sorted(pads) if name and not is_instrument(name)] def rpcs3_names(sdl_names): @@ -837,7 +846,7 @@ def main(argv): print("rpcs3-pads: no se pudo cargar SDL (%s); no se asigna nada" % e) return 0 if not names: - print("rpcs3-pads: no hay controles conectados; la configuracion no cambia") + print("rpcs3-pads: no hay controles (se ignoran los instrumentos); la configuracion no cambia") return 0 with open(config, encoding="utf-8") as f: diff --git a/tests/test_rpcs3.bats b/tests/test_rpcs3.bats index 9f018af..701ab54 100644 --- a/tests/test_rpcs3.bats +++ b/tests/test_rpcs3.bats @@ -877,3 +877,25 @@ PY [ "$status" -eq 0 ] [[ "$output" == *"omitida"* ]] } + +@test "rpcs3-pads: las guitarras y baterias no cuentan como controles" { + command -v python3 >/dev/null || skip "python3 no esta instalado" + local script="$BATS_TEST_TMPDIR/rpcs3-pads.py" + printf '%s\n' "$RPCS3_PADS_TEMPLATE" > "$script" + + run python3 - "$script" <<'PY' +import importlib.util, os, sys +spec = importlib.util.spec_from_file_location("pads", sys.argv[1]) +m = importlib.util.module_from_spec(spec) +spec.loader.exec_module(m) + +for nombre in ("sanjay900 Santroller", "Harmonix Guitar for PlayStation 3", "Rock Band Drums"): + assert m.is_instrument(nombre), nombre +for nombre in ("Xbox Series X Controller", "Xbox 360 Controller", "8BitDo SN30 Pro"): + assert not m.is_instrument(nombre), nombre + +os.environ["RPCS3_PAD_EXCLUDE"] = "SN30" +assert m.is_instrument("8BitDo SN30 Pro") and not m.is_instrument("sanjay900 Santroller") +PY + [ "$status" -eq 0 ] +}