mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-25 09:17:12 +01:00
Automatically switch to testing a new controller when it's plugged in
This commit is contained in:
parent
46a844786b
commit
e16afa792f
@ -165,7 +165,10 @@ loop(void *arg)
|
|||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case SDL_CONTROLLERDEVICEADDED:
|
case SDL_CONTROLLERDEVICEADDED:
|
||||||
SDL_Log("Game controller device %d added.\n", (int) event.cdevice.which);
|
SDL_Log("Game controller device %d added.\n", (int) event.cdevice.which);
|
||||||
if (!gamecontroller) {
|
if (gamecontroller) {
|
||||||
|
SDL_GameControllerClose(gamecontroller);
|
||||||
|
}
|
||||||
|
|
||||||
gamecontroller = SDL_GameControllerOpen(event.cdevice.which);
|
gamecontroller = SDL_GameControllerOpen(event.cdevice.which);
|
||||||
if (gamecontroller) {
|
if (gamecontroller) {
|
||||||
InitGameController();
|
InitGameController();
|
||||||
@ -173,7 +176,6 @@ loop(void *arg)
|
|||||||
SDL_Log("Couldn't open controller: %s\n", SDL_GetError());
|
SDL_Log("Couldn't open controller: %s\n", SDL_GetError());
|
||||||
}
|
}
|
||||||
UpdateWindowTitle();
|
UpdateWindowTitle();
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDL_CONTROLLERDEVICEREMOVED:
|
case SDL_CONTROLLERDEVICEREMOVED:
|
||||||
|
Loading…
Reference in New Issue
Block a user