Skip to content

Commit

Permalink
Fixed incorrect error message when a joystick can't be opened
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jan 3, 2025
1 parent 4e41288 commit 8948822
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/testcontroller.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,8 +910,10 @@ static void AddController(SDL_JoystickID id, bool verbose)
new_controller->id = id;

new_controller->joystick = SDL_OpenJoystick(id);
new_controller->num_axes = SDL_GetNumJoystickAxes(new_controller->joystick);
new_controller->axis_state = (AxisState *)SDL_calloc(new_controller->num_axes, sizeof(*new_controller->axis_state));
if (new_controller->joystick) {
new_controller->num_axes = SDL_GetNumJoystickAxes(new_controller->joystick);
new_controller->axis_state = (AxisState *)SDL_calloc(new_controller->num_axes, sizeof(*new_controller->axis_state));
}

joystick = new_controller->joystick;
if (joystick) {
Expand Down Expand Up @@ -2002,8 +2004,7 @@ int main(int argc, char *argv[])
}

SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI, "1");
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1");
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");
SDL_SetHint(SDL_HINT_JOYSTICK_ENHANCED_REPORTS, "auto");
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_STEAM, "1");
SDL_SetHint(SDL_HINT_JOYSTICK_ROG_CHAKRAM, "1");
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
Expand Down

0 comments on commit 8948822

Please sign in to comment.