Ja es poden conectar i desconectar mandos en calent, que tot el mon s'entera

This commit is contained in:
2025-08-10 11:02:20 +02:00
parent 8eb8e07e0a
commit 983eb7ee6f
10 changed files with 109 additions and 64 deletions

View File

@@ -3,13 +3,37 @@
#include <SDL3/SDL.h> // Para SDL_LogInfo, SDL_LogCategory
#include "input.h" // Para Input
#include "lang.h" // Para Lang
#include "mouse.h" // Para handleEvent
#include "options.h" // Para Options
#include "screen.h" // Para Screen
#include "section.hpp" // Para Name, Options, name, options
#include "ui/notifier.h" // Para Notifier
#include "ui/service_menu.h" // Para ServiceMenu
namespace GlobalEvents {
// Comprueba los eventos de Input y muestra notificaciones
void handleInputEvents(const SDL_Event &event) {
static auto *input_ = Input::get();
auto message = input_->handleEvent(event);
if (message.empty()) return;
// Reemplazo de palabras clave por texto localizado
size_t pos;
while ((pos = message.find(" CONNECTED")) != std::string::npos) {
message.replace(pos, std::string(" CONNECTED").length(), " " + Lang::getText("[NOTIFICATIONS] CONNECTED"));
}
while ((pos = message.find(" DISCONNECTED")) != std::string::npos) {
message.replace(pos, std::string(" DISCONNECTED").length(), " " + Lang::getText("[NOTIFICATIONS] DISCONNECTED"));
}
Options::gamepad_manager.assignAndLinkGamepads();
Options::gamepad_manager.resyncGamepadsWithPlayers();
Notifier::get()->show({message});
ServiceMenu::get()->refresh();
}
// Comprueba los eventos que se pueden producir en cualquier sección del juego
void check(const SDL_Event &event) {
switch (event.type) {
@@ -33,10 +57,6 @@ void check(const SDL_Event &event) {
ServiceMenu::get()->handleEvent(event);
Mouse::handleEvent(event);
static auto *input_ = Input::get();
if (input_->handleEvent(event)) {
Options::gamepad_manager.assignAndLinkGamepads();
}
handleInputEvents(event);
}
} // namespace GlobalEvents