emscripten: no anava back en game

This commit is contained in:
2026-04-13 18:06:54 +02:00
parent 40766ad122
commit 8bfc32de40

View File

@@ -4,6 +4,7 @@
#include "core/input/mouse.hpp"
#include "core/locale/locale.hpp" // Para Locale
#include "game/options.hpp" // Para Options, options, OptionsGame, OptionsAudio
#include "game/scene_manager.hpp" // Para SceneManager::current (filtrar BACK a GAME)
#include "game/ui/console.hpp" // Para Console
#include "game/ui/notifier.hpp" // Para Notifier
@@ -41,16 +42,19 @@ namespace GlobalEvents {
// Marcar polsació de qualsevol botó del comandament (els consumirà GlobalInputs
// per saltar escenes d'attract mode). El botó BACK queda exclòs perquè es
// reserva per a l'acció EXIT — excepte a emscripten, on no es pot sortir del
// joc i el BACK pot actuar com a botó genèric per saltar escenes.
// reserva per a l'acció EXIT. A emscripten només l'excloem a l'escena GAME
// (tornar al menú); a la resta d'escenes web BACK actua com a botó genèric,
// ja que no pot activar el procés de tancament del joc.
if (event.type == SDL_EVENT_GAMEPAD_BUTTON_DOWN) {
const bool IS_BACK = (event.gbutton.button == SDL_GAMEPAD_BUTTON_BACK);
#ifdef __EMSCRIPTEN__
gamepad_button_pressed_ = true;
const bool RESERVE_BACK = IS_BACK && SceneManager::current == SceneManager::Scene::GAME;
#else
if (event.gbutton.button != SDL_GAMEPAD_BUTTON_BACK) {
const bool RESERVE_BACK = IS_BACK;
#endif
if (!RESERVE_BACK) {
gamepad_button_pressed_ = true;
}
#endif
}
// Enrutar eventos de texto a la consola cuando está activa