Skip to content

Commit ed715e1

Browse files
committed
SDL_IsGamepad cache verdict obtained from joystick type check
1 parent 912781d commit ed715e1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/joystick/SDL_gamepad.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2631,14 +2631,14 @@ bool SDL_IsGamepad(SDL_JoystickID instance_id)
26312631
{
26322632
const void *value;
26332633
SDL_JoystickType js_type = SDL_GetJoystickTypeForID(instance_id);
2634-
if (js_type != SDL_JOYSTICK_TYPE_GAMEPAD && js_type != SDL_JOYSTICK_TYPE_UNKNOWN)
2635-
{
2636-
// avoid creating HIDAPI mapping if type is SDL_Joystick knows it is not a game pad
2637-
result = false;
2638-
} else if (SDL_FindInHashTable(s_gamepadInstanceIDs, (void *)(uintptr_t)instance_id, &value)) {
2634+
if (SDL_FindInHashTable(s_gamepadInstanceIDs, (void *)(uintptr_t)instance_id, &value)) {
26392635
result = (bool)(uintptr_t)value;
26402636
} else {
2641-
if (SDL_PrivateGetGamepadMapping(instance_id, true) != NULL) {
2637+
SDL_JoystickType js_type = SDL_GetJoystickTypeForID(instance_id);
2638+
if (js_type != SDL_JOYSTICK_TYPE_GAMEPAD && js_type != SDL_JOYSTICK_TYPE_UNKNOWN) {
2639+
// avoid creating HIDAPI mapping if SDL_Joystick knows it is not a game pad
2640+
result = false;
2641+
} else if (SDL_PrivateGetGamepadMapping(instance_id, true) != NULL) {
26422642
result = true;
26432643
} else {
26442644
result = false;

0 commit comments

Comments
 (0)