ja es pot redefinir el mando correctament

This commit is contained in:
2025-11-02 19:07:46 +01:00
parent 87527d01a8
commit 0d19cf18aa

View File

@@ -219,22 +219,29 @@ auto Input::getControllerBinding(const std::shared_ptr<Gamepad>& gamepad, Action
// Comprueba el eje del mando
auto Input::checkAxisInput(Action action, const std::shared_ptr<Gamepad>& 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