correccions en la detecció de mandos
This commit is contained in:
@@ -17,12 +17,28 @@
|
||||
#include "game/ui/service_menu.hpp" // Para ServiceMenu
|
||||
|
||||
namespace GlobalEvents {
|
||||
namespace {
|
||||
// Durante el arranque se drenan los SDL_EVENT_GAMEPAD_ADDED de los mandos
|
||||
// ya conectados. Esos eventos sí deben reasignar mandos a jugadores, pero
|
||||
// no deben mostrar notificación: no son hotplug, son detección inicial.
|
||||
bool startup_in_progress = true;
|
||||
} // namespace
|
||||
|
||||
// Comprueba los eventos de Input y muestra notificaciones
|
||||
void handleInputEvents(const SDL_Event& event) {
|
||||
if (event.type != SDL_EVENT_GAMEPAD_ADDED && event.type != SDL_EVENT_GAMEPAD_REMOVED) {
|
||||
return;
|
||||
}
|
||||
|
||||
static auto* input_ = Input::get();
|
||||
auto message = input_->handleEvent(event);
|
||||
|
||||
if (message.empty()) {
|
||||
// Reasignar siempre: tanto en arranque como en hotplug en caliente.
|
||||
Options::gamepad_manager.assignAndLinkGamepads();
|
||||
Options::gamepad_manager.resyncGamepadsWithPlayers();
|
||||
ServiceMenu::get()->refresh();
|
||||
|
||||
if (startup_in_progress || message.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -35,10 +51,11 @@ namespace GlobalEvents {
|
||||
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();
|
||||
}
|
||||
|
||||
void markStartupComplete() {
|
||||
startup_in_progress = false;
|
||||
}
|
||||
|
||||
// Comprueba los eventos que se pueden producir en cualquier sección del juego
|
||||
|
||||
Reference in New Issue
Block a user