diff --git a/source/core/input/input.cpp b/source/core/input/input.cpp index 670e3c7..cc19d43 100644 --- a/source/core/input/input.cpp +++ b/source/core/input/input.cpp @@ -377,9 +377,25 @@ void Input::update() { // --- MANDOS --- for (const auto& gamepad : gamepads_) { + // LEFT i RIGHT NO son redefinibles al mando (assumits dpad o stick). + // Llegim el left stick X i el fusionem amb l'estat del dpad: qualsevol + // de les dos fonts activa l'accio. Llindar AXIS_THRESHOLD (30000). + const Sint16 STICK_X = SDL_GetGamepadAxis(gamepad->pad, SDL_GAMEPAD_AXIS_LEFTX); + const bool STICK_LEFT = STICK_X < -AXIS_THRESHOLD; + const bool STICK_RIGHT = STICK_X > AXIS_THRESHOLD; + for (auto& binding : gamepad->bindings) { bool button_is_down_now = static_cast(SDL_GetGamepadButton(gamepad->pad, static_cast(binding.second.button))) != 0; + // Per a LEFT/RIGHT, fer un OR amb el stick X. La resta d'accions + // (THRUST/SHOOT/START/MENU) ignoren el stick aqui — si es vol + // dispar amb trigger L2/R2 cal binding amb codi 100/101. + if (binding.first == Action::LEFT) { + button_is_down_now = button_is_down_now || STICK_LEFT; + } else if (binding.first == Action::RIGHT) { + button_is_down_now = button_is_down_now || STICK_RIGHT; + } + // El estado .is_held del fotograma anterior nos sirve para saber si es un pulso nuevo binding.second.just_pressed = button_is_down_now && !binding.second.is_held; binding.second.is_held = button_is_down_now;