ja es pot redefinir el mando correctament
This commit is contained in:
@@ -219,22 +219,29 @@ auto Input::getControllerBinding(const std::shared_ptr<Gamepad>& gamepad, Action
|
|||||||
|
|
||||||
// Comprueba el eje del mando
|
// Comprueba el eje del mando
|
||||||
auto Input::checkAxisInput(Action action, const std::shared_ptr<Gamepad>& gamepad, bool repeat) -> bool {
|
auto Input::checkAxisInput(Action action, const std::shared_ptr<Gamepad>& gamepad, bool repeat) -> bool {
|
||||||
// Umbral para considerar el eje como activo
|
// Obtener el binding configurado para esta acción
|
||||||
bool axis_active_now = false;
|
auto& binding = gamepad->bindings[action];
|
||||||
|
|
||||||
switch (action) {
|
// Solo revisar ejes si el binding está configurado como eje (valores 200+)
|
||||||
case Action::LEFT:
|
// 200 = Left stick izquierda, 201 = Left stick derecha
|
||||||
axis_active_now = SDL_GetGamepadAxis(gamepad->pad, SDL_GAMEPAD_AXIS_LEFTX) < -AXIS_THRESHOLD;
|
if (binding.button < 200) {
|
||||||
break;
|
// El binding no es un eje, no revisar axis
|
||||||
case Action::RIGHT:
|
return false;
|
||||||
axis_active_now = SDL_GetGamepadAxis(gamepad->pad, SDL_GAMEPAD_AXIS_LEFTX) > AXIS_THRESHOLD;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Referencia al binding correspondiente
|
// Determinar qué eje y dirección revisar según el binding
|
||||||
auto& binding = gamepad->bindings[action];
|
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) {
|
if (repeat) {
|
||||||
// Si se permite repetir, simplemente devolvemos el estado actual
|
// Si se permite repetir, simplemente devolvemos el estado actual
|
||||||
|
|||||||
Reference in New Issue
Block a user