From 0d19cf18aa01a0e8ba07a24c879de7da62102b97 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sun, 2 Nov 2025 19:07:46 +0100 Subject: [PATCH] ja es pot redefinir el mando correctament --- source/core/input/input.cpp | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/source/core/input/input.cpp b/source/core/input/input.cpp index 38556f1..d21b5d5 100644 --- a/source/core/input/input.cpp +++ b/source/core/input/input.cpp @@ -219,22 +219,29 @@ auto Input::getControllerBinding(const std::shared_ptr& gamepad, Action // Comprueba el eje del mando auto Input::checkAxisInput(Action action, const std::shared_ptr& gamepad, bool repeat) -> bool { - // Umbral para considerar el eje como activo - bool axis_active_now = false; + // Obtener el binding configurado para esta acción + auto& binding = gamepad->bindings[action]; - switch (action) { - case Action::LEFT: - axis_active_now = SDL_GetGamepadAxis(gamepad->pad, SDL_GAMEPAD_AXIS_LEFTX) < -AXIS_THRESHOLD; - break; - case Action::RIGHT: - axis_active_now = SDL_GetGamepadAxis(gamepad->pad, SDL_GAMEPAD_AXIS_LEFTX) > AXIS_THRESHOLD; - break; - default: - return false; + // Solo revisar ejes si el binding está configurado como eje (valores 200+) + // 200 = Left stick izquierda, 201 = Left stick derecha + if (binding.button < 200) { + // El binding no es un eje, no revisar axis + return false; } - // Referencia al binding correspondiente - auto& binding = gamepad->bindings[action]; + // Determinar qué eje y dirección revisar según el binding + bool axis_active_now = false; + + if (binding.button == 200) { + // Left stick izquierda + axis_active_now = SDL_GetGamepadAxis(gamepad->pad, SDL_GAMEPAD_AXIS_LEFTX) < -AXIS_THRESHOLD; + } else if (binding.button == 201) { + // Left stick derecha + axis_active_now = SDL_GetGamepadAxis(gamepad->pad, SDL_GAMEPAD_AXIS_LEFTX) > AXIS_THRESHOLD; + } else { + // Binding de eje no soportado + return false; + } if (repeat) { // Si se permite repetir, simplemente devolvemos el estado actual