canvis de paleta amb L i R del mando

This commit is contained in:
2026-04-13 21:05:52 +02:00
parent 49fb895984
commit acc1b0e8a1
2 changed files with 13 additions and 7 deletions

View File

@@ -65,7 +65,10 @@ class Input {
{Action::EXIT, ButtonState{.button = static_cast<int>(SDL_GAMEPAD_BUTTON_BACK)}}, {Action::EXIT, ButtonState{.button = static_cast<int>(SDL_GAMEPAD_BUTTON_BACK)}},
{Action::CANCEL, ButtonState{.button = static_cast<int>(SDL_GAMEPAD_BUTTON_BACK)}}, {Action::CANCEL, ButtonState{.button = static_cast<int>(SDL_GAMEPAD_BUTTON_BACK)}},
// Botó START del mando → pausa // Botó START del mando → pausa
{Action::PAUSE, ButtonState{.button = static_cast<int>(SDL_GAMEPAD_BUTTON_START)}}} {} {Action::PAUSE, ButtonState{.button = static_cast<int>(SDL_GAMEPAD_BUTTON_START)}},
// Shoulders → paleta següent / mode d'ordenació de paleta següent
{Action::NEXT_PALETTE, ButtonState{.button = static_cast<int>(SDL_GAMEPAD_BUTTON_LEFT_SHOULDER)}},
{Action::NEXT_PALETTE_SORT, ButtonState{.button = static_cast<int>(SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER)}}} {}
~Gamepad() { ~Gamepad() {
if (pad != nullptr) { if (pad != nullptr) {

View File

@@ -41,18 +41,21 @@ namespace GlobalEvents {
} }
// Marcar polsació de qualsevol botó del comandament (els consumirà GlobalInputs // Marcar polsació de qualsevol botó del comandament (els consumirà GlobalInputs
// per saltar escenes d'attract mode). El botó BACK queda exclòs perquè es // per saltar escenes d'attract mode). Queden exclosos els botons reservats a
// reserva per a l'acció EXIT. A emscripten només l'excloem a l'escena GAME // accions globals perquè el "any button → ACCEPT" no se'ls mengi abans que
// (tornar al menú); a la resta d'escenes web BACK actua com a botó genèric, // checkAction() els pugui enrutar:
// ja que no pot activar el procés de tancament del joc. // - BACK → EXIT (a emscripten només a l'escena GAME, ja que no pot tancar).
// - LEFT_SHOULDER / RIGHT_SHOULDER → NEXT_PALETTE / NEXT_PALETTE_SORT.
if (event.type == SDL_EVENT_GAMEPAD_BUTTON_DOWN) { if (event.type == SDL_EVENT_GAMEPAD_BUTTON_DOWN) {
const bool IS_BACK = (event.gbutton.button == SDL_GAMEPAD_BUTTON_BACK); const auto BUTTON = event.gbutton.button;
const bool IS_BACK = (BUTTON == SDL_GAMEPAD_BUTTON_BACK);
const bool IS_SHOULDER = (BUTTON == SDL_GAMEPAD_BUTTON_LEFT_SHOULDER || BUTTON == SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER);
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
const bool RESERVE_BACK = IS_BACK && SceneManager::current == SceneManager::Scene::GAME; const bool RESERVE_BACK = IS_BACK && SceneManager::current == SceneManager::Scene::GAME;
#else #else
const bool RESERVE_BACK = IS_BACK; const bool RESERVE_BACK = IS_BACK;
#endif #endif
if (!RESERVE_BACK) { if (!RESERVE_BACK && !IS_SHOULDER) {
gamepad_button_pressed_ = true; gamepad_button_pressed_ = true;
} }
} }