Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions lib/rpcs3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
22 changes: 22 additions & 0 deletions tests/test_rpcs3.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
}
Loading