feat(input): binding START per jugador (teclat 1/2 fix, mando remapejable; pausa només per F11)

This commit is contained in:
JailDesigner committed 2026-05-06 08:23:01 +02:00
1 parent 165499b9d4
commit 5710568af8
9 files changed
+21 -9

No files matched your search

+3 -4
View File
@@ -14,7 +14,6 @@
#include <vector>
#include "core/audio/audio.hpp"
#include "core/input/gamepad_manager.hpp"
#include "core/input/global_inputs.hpp"
#include "core/input/key_config.hpp"
#include "core/locale/locale.hpp"
@@ -348,6 +347,7 @@ GameScene::GameScene(Config config)
.right = kb_p1.right,
.jump = kb_p1.jump,
.attack = kb_p1.attack,
.start = Defaults::KeysGame::START,
};
const Player::Controls CONTROLS_P2{
.up = kb_p2.up,
@@ -356,6 +356,7 @@ GameScene::GameScene(Config config)
.right = kb_p2.right,
.jump = kb_p2.jump,
.attack = kb_p2.attack,
.start = Defaults::KeysGameP2::START,
};
// Spawn lligat a la porta: tots els jugadors apareixen davant del
// passadís de sortida. `computeSpawn` deriva les coordenades de
@@ -1044,11 +1045,9 @@ void GameScene::handlePauseInput() {
if (editor_.active()) { return; }
#endif
const SDL_Scancode PAUSE_SC = KeyConfig::get().scancode("pause");
SDL_Gamepad* pad = GamepadManager::get().getPrimary();
for (const auto& event : EventBuffer::events) {
const bool KEY_HIT = (event.type == SDL_EVENT_KEY_DOWN && PAUSE_SC != SDL_SCANCODE_UNKNOWN && event.key.scancode == PAUSE_SC);
const bool PAD_HIT = (event.type == SDL_EVENT_GAMEPAD_BUTTON_DOWN && pad != nullptr && event.gbutton.which == SDL_GetGamepadID(pad) && event.gbutton.button == SDL_GAMEPAD_BUTTON_START);
if (!KEY_HIT && !PAD_HIT) { continue; }
if (!KEY_HIT) { continue; }
// Determinem cap a quin estat anem. Si estem quiets (IDLE o
// PAUSED) arranquem la transició contrària. Si estem en marxa