fix DefineButtons i Title: ja no fa coses rares al definir la ultima tecla

This commit is contained in:
2025-06-21 14:13:36 +02:00
parent e8b67d3be1
commit f5731c8181
5 changed files with 65 additions and 45 deletions

View File

@@ -143,42 +143,33 @@ void Title::checkEvents()
{
if (event.type == SDL_EVENT_KEY_DOWN && event.key.repeat == 0)
{
bool should_reset = false;
switch (event.key.key)
{
case SDLK_1: // Redefine los botones del mando #0
should_reset = define_buttons_->enable(0);
define_buttons_->enable(0);
break;
case SDLK_2: // Redefine los botones del mando #1
should_reset = define_buttons_->enable(1);
define_buttons_->enable(1);
break;
case SDLK_3: // Intercambia los mandos entre los dos jugadores
swapControllers();
should_reset = true;
break;
case SDLK_4: // Intercambia la asignación del teclado
swapKeyboard();
should_reset = true;
break;
case SDLK_5: // Muestra la asignación de mandos y teclado
showControllers();
should_reset = true;
break;
default:
break;
}
// Resetear el contador si es necesario
if (should_reset)
{
resetCounter();
}
resetCounter();
}
GlobalEvents::check(event);
@@ -198,8 +189,7 @@ void Title::checkInput()
for (const auto &CONTROLLER : Options::controllers)
{
// START
if (Input::get()->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index) &&
!Input::get()->checkInput(InputAction::SERVICE, INPUT_DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index))
if (Input::get()->checkInput(InputAction::START, INPUT_DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index))
{
if ((state_ == TitleState::LOGO_FINISHED || ALLOW_TITLE_ANIMATION_SKIP) && !fade_->isEnabled())
{
@@ -222,28 +212,15 @@ void Title::checkInput()
return;
}
}
// SWAP_CONTROLLERS
if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index) &&
Input::get()->checkInput(InputAction::SWAP_CONTROLLERS, INPUT_DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index))
{
swapControllers();
return;
}
// CONFIG
if (Input::get()->checkInput(InputAction::SERVICE, INPUT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index) &&
Input::get()->checkInput(InputAction::CONFIG, INPUT_DO_NOT_ALLOW_REPEAT, CONTROLLER.type, CONTROLLER.index))
{
define_buttons_->enable(CONTROLLER.index);
return;
}
}
}
}
// Comprueba los inputs que se pueden introducir en cualquier sección del juego
GlobalInputs::check();
if (!define_buttons_->isEnabled())
{
GlobalInputs::check();
}
}
// Bucle para el titulo del juego