Skip to content

Commit

Permalink
Fixed controller issue
Browse files Browse the repository at this point in the history
  • Loading branch information
complexlogic committed Mar 7, 2022
1 parent 74d6afc commit 72027d5
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/launcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -1294,16 +1294,18 @@ int main(int argc, char *argv[])
}
break;

case SDL_CONTROLLERDEVICEADDED:
output_log(LOGLEVEL_DEBUG, "Gamepad connected with device index %i\n", event.cdevice.which);
if (event.cdevice.which == config.gamepad_device) {
connect_gamepad(event.cdevice.which);
case SDL_JOYDEVICEADDED:
if (SDL_IsGameController(event.jdevice.which) == SDL_TRUE) {
output_log(LOGLEVEL_DEBUG, "Gamepad connected with device index %i\n", event.jdevice.which);
if (event.jdevice.which == config.gamepad_device) {
connect_gamepad(event.jdevice.which);
}
}
break;

case SDL_CONTROLLERDEVICEREMOVED:
output_log(LOGLEVEL_DEBUG, "Gamepad removed with device index %i\n", event.cdevice.which);
if (event.cdevice.which == config.gamepad_device) {
case SDL_JOYDEVICEREMOVED:
if (event.jdevice.which == config.gamepad_device && gamepad != NULL) {
output_log(LOGLEVEL_DEBUG, "Gamepad disconnected\n");
SDL_GameControllerClose(gamepad);
gamepad = NULL;
}
Expand Down

0 comments on commit 72027d5

Please sign in to comment.