diff --git a/source/core/input/input.hpp b/source/core/input/input.hpp index ade32619e..66879f93b 100644 --- a/source/core/input/input.hpp +++ b/source/core/input/input.hpp @@ -65,7 +65,10 @@ class Input { {Action::EXIT, ButtonState{.button = static_cast(SDL_GAMEPAD_BUTTON_BACK)}}, {Action::CANCEL, ButtonState{.button = static_cast(SDL_GAMEPAD_BUTTON_BACK)}}, // Botó START del mando → pausa - {Action::PAUSE, ButtonState{.button = static_cast(SDL_GAMEPAD_BUTTON_START)}}} {} + {Action::PAUSE, ButtonState{.button = static_cast(SDL_GAMEPAD_BUTTON_START)}}, + // Shoulders → paleta següent / mode d'ordenació de paleta següent + {Action::NEXT_PALETTE, ButtonState{.button = static_cast(SDL_GAMEPAD_BUTTON_LEFT_SHOULDER)}}, + {Action::NEXT_PALETTE_SORT, ButtonState{.button = static_cast(SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER)}}} {} ~Gamepad() { if (pad != nullptr) { diff --git a/source/core/system/global_events.cpp b/source/core/system/global_events.cpp index 62479698c..905ee7ff2 100644 --- a/source/core/system/global_events.cpp +++ b/source/core/system/global_events.cpp @@ -41,18 +41,21 @@ 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. 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. + // per saltar escenes d'attract mode). Queden exclosos els botons reservats a + // accions globals perquè el "any button → ACCEPT" no se'ls mengi abans que + // checkAction() els pugui enrutar: + // - 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) { - 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__ const bool RESERVE_BACK = IS_BACK && SceneManager::current == SceneManager::Scene::GAME; #else const bool RESERVE_BACK = IS_BACK; #endif - if (!RESERVE_BACK) { + if (!RESERVE_BACK && !IS_SHOULDER) { gamepad_button_pressed_ = true; } }