GlobalInputs: ja es pot eixir del joc mentre redefinixes botons
This commit is contained in:
@@ -547,7 +547,7 @@ void ServiceMenu::handleEvent(const SDL_Event &event) {
|
||||
// Si DefineButtons está activo, que maneje todos los eventos
|
||||
if (define_buttons_ && define_buttons_->isEnabled()) {
|
||||
define_buttons_->checkEvents(event);
|
||||
return; // No procesar otros eventos mientras DefineButtons está activo
|
||||
//return; // No procesar otros eventos mientras DefineButtons está activo
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,85 +557,39 @@ bool ServiceMenu::checkInput() {
|
||||
}
|
||||
|
||||
if (define_buttons_ && define_buttons_->isEnabled()) {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
static auto input = Input::get();
|
||||
// --- Teclado ---
|
||||
// Arriba
|
||||
if (input->checkAction(Input::Action::UP, Input::DO_NOT_ALLOW_REPEAT, Input::CHECK_KEYBOARD)) {
|
||||
setSelectorUp();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Abajo
|
||||
if (input->checkAction(Input::Action::DOWN, Input::DO_NOT_ALLOW_REPEAT, Input::CHECK_KEYBOARD)) {
|
||||
setSelectorDown();
|
||||
return true;
|
||||
}
|
||||
using Action = Input::Action;
|
||||
|
||||
// Derecha
|
||||
if (input->checkAction(Input::Action::RIGHT, Input::DO_NOT_ALLOW_REPEAT, Input::CHECK_KEYBOARD)) {
|
||||
adjustOption(true);
|
||||
return true;
|
||||
}
|
||||
const std::vector<std::pair<Action, std::function<void()>>> actions = {
|
||||
{ Action::UP, [this]() { setSelectorUp(); } },
|
||||
{ Action::DOWN, [this]() { setSelectorDown(); } },
|
||||
{ Action::RIGHT, [this]() { adjustOption(true); } },
|
||||
{ Action::LEFT, [this]() { adjustOption(false); } },
|
||||
{ Action::SM_SELECT, [this]() { selectOption(); } },
|
||||
{ Action::SM_BACK, [this]() { moveBack(); } },
|
||||
};
|
||||
|
||||
// Izquierda
|
||||
if (input->checkAction(Input::Action::LEFT, Input::DO_NOT_ALLOW_REPEAT, Input::CHECK_KEYBOARD)) {
|
||||
adjustOption(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Aceptar
|
||||
if (input->checkAction(Input::Action::SM_SELECT, Input::DO_NOT_ALLOW_REPEAT, Input::CHECK_KEYBOARD)) {
|
||||
selectOption();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Atras
|
||||
if (input->checkAction(Input::Action::SM_BACK, Input::DO_NOT_ALLOW_REPEAT, Input::CHECK_KEYBOARD)) {
|
||||
moveBack();
|
||||
return true;
|
||||
}
|
||||
|
||||
// --- Mandos ---
|
||||
auto gamepads = input->getGamepads();
|
||||
for (auto gamepad : gamepads) {
|
||||
// Arriba
|
||||
if (input->checkAction(Input::Action::UP, Input::DO_NOT_ALLOW_REPEAT, Input::DO_NOT_CHECK_KEYBOARD, gamepad)) {
|
||||
setSelectorUp();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Abajo
|
||||
if (input->checkAction(Input::Action::DOWN, Input::DO_NOT_ALLOW_REPEAT, Input::DO_NOT_CHECK_KEYBOARD, gamepad)) {
|
||||
setSelectorDown();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Derecha
|
||||
if (input->checkAction(Input::Action::RIGHT, Input::DO_NOT_ALLOW_REPEAT, Input::DO_NOT_CHECK_KEYBOARD, gamepad)) {
|
||||
adjustOption(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Izquierda
|
||||
if (input->checkAction(Input::Action::LEFT, Input::DO_NOT_ALLOW_REPEAT, Input::DO_NOT_CHECK_KEYBOARD, gamepad)) {
|
||||
adjustOption(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Aceptar
|
||||
if (input->checkAction(Input::Action::SM_SELECT, Input::DO_NOT_ALLOW_REPEAT, Input::DO_NOT_CHECK_KEYBOARD, gamepad)) {
|
||||
selectOption();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Atras
|
||||
if (input->checkAction(Input::Action::SM_BACK, Input::DO_NOT_ALLOW_REPEAT, Input::DO_NOT_CHECK_KEYBOARD, gamepad)) {
|
||||
moveBack();
|
||||
// Teclado
|
||||
for (const auto& [action, func] : actions) {
|
||||
if (input->checkAction(action, Input::DO_NOT_ALLOW_REPEAT, Input::CHECK_KEYBOARD)) {
|
||||
func();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Mandos
|
||||
for (auto gamepad : input->getGamepads()) {
|
||||
for (const auto& [action, func] : actions) {
|
||||
if (input->checkAction(action, Input::DO_NOT_ALLOW_REPEAT, Input::DO_NOT_CHECK_KEYBOARD, gamepad)) {
|
||||
func();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user