soport per a gamepad

This commit is contained in:
2026-04-05 00:22:21 +02:00
parent 6d42f848a5
commit a328681365
6 changed files with 209 additions and 1 deletions

View File

@@ -3,6 +3,7 @@
#include <cstring>
#include <iostream>
#include "core/input/gamepad.hpp"
#include "core/input/global_inputs.hpp"
#include "core/input/mouse.hpp"
#include "core/jail/jgame.hpp"
@@ -22,9 +23,11 @@ Director* Director::instance_ = nullptr;
void Director::init() {
instance_ = new Director();
Gamepad::init();
}
void Director::destroy() {
Gamepad::destroy();
delete instance_;
instance_ = nullptr;
}
@@ -50,6 +53,7 @@ void Director::run() {
Uint32 frame_start = SDL_GetTicks();
handleEvents();
Gamepad::update();
GlobalInputs::handle();
Mouse::updateCursorVisibility();
@@ -108,6 +112,11 @@ void Director::handleEvents() {
JG_QuitSignal();
requestQuit();
}
// Hot-plug de gamepad
if (event.type == SDL_EVENT_GAMEPAD_ADDED || event.type == SDL_EVENT_GAMEPAD_REMOVED) {
Gamepad::handleEvent(event);
continue;
}
// Menú: F12 (o tecla configurada) obre/tanca el menú flotant
if (event.type == SDL_EVENT_KEY_DOWN && !event.key.repeat &&
event.key.scancode == Options::keys_gui.menu_toggle) {