Skip to content

Commit

Permalink
fix game controller id on device added
Browse files Browse the repository at this point in the history
  • Loading branch information
ncannasse committed Nov 10, 2023
1 parent c51d460 commit a502906
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libs/sdl/sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,13 @@ HL_PRIM bool HL_NAME(event_loop)( event_data *event ) {
break;
case SDL_CONTROLLERDEVICEADDED:
event->type = GControllerAdded;
event->controller = e.jdevice.which;
SDL_GameController * controller = SDL_GameControllerOpen(e.cdevice.which);
SDL_Joystick* j = SDL_GameControllerGetJoystick(controller);
event->controller = SDL_JoystickInstanceID(j);
break;
case SDL_CONTROLLERDEVICEREMOVED:
event->type = GControllerRemoved;
event->controller = e.jdevice.which;
event->controller = e.cdevice.which;
break;
case SDL_CONTROLLERBUTTONDOWN:
event->type = GControllerDown;
Expand Down

0 comments on commit a502906

Please sign in to comment.