canvis de paleta amb L i R del mando
This commit is contained in:
@@ -65,7 +65,10 @@ class Input {
|
||||
{Action::EXIT, 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
|
||||
{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() {
|
||||
if (pad != nullptr) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user