Use first detected gamepad

This commit is contained in:
irisz64
2025-08-03 22:32:07 +02:00
parent 3da227613f
commit cdb826ba8e

View File

@@ -19,15 +19,18 @@ KaizenGui::~KaizenGui() {
void KaizenGui::QueryDevices(SDL_Event event) {
switch (event.type) {
case SDL_EVENT_GAMEPAD_ADDED:
{
if (!gamepad) {
const auto index = event.gdevice.which;
gamepad = SDL_OpenGamepad(index);
info("Found controller!");
info("Name: {}", SDL_GetGamepadName(gamepad));
info("Vendor: {}", SDL_GetGamepadVendor(gamepad));
}
break;
case SDL_EVENT_GAMEPAD_REMOVED:
SDL_CloseGamepad(gamepad);
if (gamepad)
SDL_CloseGamepad(gamepad);
break;
default: break;
}