Skip to content

Commit

Permalink
Send EVENT_TYPE_CLOSE when joystick disconnects
Browse files Browse the repository at this point in the history
  • Loading branch information
Nopey committed Dec 1, 2024
1 parent c0d363d commit 90bc319
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/controller/joystick.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ int joystick_name_to_id(const char *name, int offset) {
}

static int internal_joystick_poll(joystick *k, controller *ctrl, ctrl_event **ev) {
if(!SDL_GameControllerGetAttached(k->joy)) {
controller_close(ctrl, ev);
return 0;
}

Sint16 x_axis = SDL_GameControllerGetAxis(k->joy, k->keys->x_axis);
Sint16 y_axis = SDL_GameControllerGetAxis(k->joy, k->keys->y_axis);
int dpadup = SDL_GameControllerGetButton(k->joy, k->keys->dpad[0]);
Expand Down

0 comments on commit 90bc319

Please sign in to comment.