sdl_callbacks

This commit is contained in:
2026-04-14 12:21:00 +02:00
parent c0accd25e2
commit f5da35bfb2
20 changed files with 406 additions and 177 deletions

View File

@@ -306,10 +306,17 @@ void Input::addGamepadMappingsFromFile() {
}
void Input::discoverGamepads() {
SDL_Event event;
while (SDL_PollEvent(&event)) {
handleEvent(event); // Comprueba mandos conectados
// Enumera los gamepads ya conectados sin drenar la cola de eventos de SDL
// (necesario con SDL_MAIN_USE_CALLBACKS, que entrega los eventos por SDL_AppEvent).
int count = 0;
SDL_JoystickID* joysticks = SDL_GetGamepads(&count);
if (joysticks == nullptr) {
return;
}
for (int i = 0; i < count; ++i) {
addGamepad(joysticks[i]);
}
SDL_free(joysticks);
}
void Input::initSDLGamePad() {