fix DefineButtons i Title: ja no fa coses rares al definir la ultima tecla
This commit is contained in:
@@ -63,9 +63,19 @@ void DefineButtons::bindButtons()
|
||||
// Comprueba los eventos
|
||||
void DefineButtons::checkEvents(const SDL_Event &event)
|
||||
{
|
||||
if (enabled_ && event.type == SDL_EVENT_GAMEPAD_BUTTON_DOWN)
|
||||
if (enabled_)
|
||||
{
|
||||
doControllerButtonDown(event.gbutton);
|
||||
switch (event.type)
|
||||
{
|
||||
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
||||
doControllerButtonDown(event.gbutton);
|
||||
break;
|
||||
case SDL_EVENT_GAMEPAD_BUTTON_UP:
|
||||
checkEnd();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +85,7 @@ bool DefineButtons::enable(int index)
|
||||
if (index < input_->getNumControllers())
|
||||
{
|
||||
enabled_ = true;
|
||||
finished_ = false;
|
||||
index_controller_ = index;
|
||||
index_button_ = 0;
|
||||
clearButtons();
|
||||
@@ -90,19 +101,13 @@ bool DefineButtons::isEnabled() const { return enabled_; }
|
||||
// Incrementa el indice de los botones
|
||||
void DefineButtons::incIndexButton()
|
||||
{
|
||||
++index_button_;
|
||||
|
||||
// Comprueba si ha finalizado
|
||||
if (index_button_ == buttons_.size())
|
||||
if (index_button_ < buttons_.size() - 1)
|
||||
{
|
||||
// Asigna los botones definidos al input_
|
||||
bindButtons();
|
||||
|
||||
// Guarda los cambios en las opciones
|
||||
saveBindingsToOptions();
|
||||
|
||||
// Deshabilita
|
||||
enabled_ = false;
|
||||
++index_button_;
|
||||
}
|
||||
else
|
||||
{
|
||||
finished_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,4 +145,24 @@ void DefineButtons::clearButtons()
|
||||
buttons_.emplace_back(Lang::getText("[DEFINE_BUTTONS] FIRE_RIGHT"), InputAction::FIRE_RIGHT, SDL_GAMEPAD_BUTTON_INVALID);
|
||||
buttons_.emplace_back(Lang::getText("[DEFINE_BUTTONS] START"), InputAction::START, SDL_GAMEPAD_BUTTON_INVALID);
|
||||
buttons_.emplace_back(Lang::getText("[DEFINE_BUTTONS] SERVICE_MENU"), InputAction::SERVICE, SDL_GAMEPAD_BUTTON_INVALID);
|
||||
}
|
||||
|
||||
// Comprueba si ha finalizado
|
||||
void DefineButtons::checkEnd()
|
||||
{
|
||||
// Comprueba si ha finalizado
|
||||
if (finished_)
|
||||
{
|
||||
// Asigna los botones definidos al input_
|
||||
bindButtons();
|
||||
|
||||
// Guarda los cambios en las opciones
|
||||
saveBindingsToOptions();
|
||||
|
||||
// Reinicia los estados de las pulsaciones de los botones
|
||||
input_->resetInputStates();
|
||||
|
||||
// Deshabilita
|
||||
enabled_ = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user