mirror of https://github.com/encounter/SDL.git
Cache the fact that a device didn't look like a joystick
Fixes https://github.com/libsdl-org/SDL/issues/5211
This commit is contained in:
parent
138d96c8a6
commit
eb660e862c
|
@ -109,6 +109,7 @@ typedef struct SDL_joylist_item
|
||||||
/* Steam Controller support */
|
/* Steam Controller support */
|
||||||
SDL_bool m_bSteamController;
|
SDL_bool m_bSteamController;
|
||||||
|
|
||||||
|
SDL_bool checked_mapping;
|
||||||
SDL_GamepadMapping *mapping;
|
SDL_GamepadMapping *mapping;
|
||||||
} SDL_joylist_item;
|
} SDL_joylist_item;
|
||||||
|
|
||||||
|
@ -1573,9 +1574,13 @@ LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out)
|
||||||
SDL_Joystick *joystick;
|
SDL_Joystick *joystick;
|
||||||
SDL_joylist_item *item = JoystickByDevIndex(device_index);
|
SDL_joylist_item *item = JoystickByDevIndex(device_index);
|
||||||
|
|
||||||
if (item->mapping) {
|
if (item->checked_mapping) {
|
||||||
SDL_memcpy(out, item->mapping, sizeof(*out));
|
if (item->mapping) {
|
||||||
return SDL_TRUE;
|
SDL_memcpy(out, item->mapping, sizeof(*out));
|
||||||
|
return SDL_TRUE;
|
||||||
|
} else {
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We temporarily open the device to check how it's configured. Make
|
/* We temporarily open the device to check how it's configured. Make
|
||||||
|
@ -1595,6 +1600,8 @@ LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMapping *out)
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
item->checked_mapping = SDL_TRUE;
|
||||||
|
|
||||||
if (PrepareJoystickHwdata(joystick, item) == -1) {
|
if (PrepareJoystickHwdata(joystick, item) == -1) {
|
||||||
SDL_free(joystick->hwdata);
|
SDL_free(joystick->hwdata);
|
||||||
SDL_free(joystick);
|
SDL_free(joystick);
|
||||||
|
|
Loading…
Reference in New Issue