soport per a gamepad
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user