mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 19:38:14 +00:00
Fixed double SDL_EVENT_GAMEPAD_ADDED for controllers with automatic gamepad mappings
(cherry picked from commit 6babade758
)
This commit is contained in:
@@ -311,7 +311,7 @@ void SDL_PrivateGamepadAdded(SDL_JoystickID instance_id)
|
||||
{
|
||||
SDL_Event event;
|
||||
|
||||
if (!SDL_gamepads_initialized) {
|
||||
if (!SDL_gamepads_initialized || SDL_IsJoystickBeingAdded()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -2143,6 +2143,7 @@ void SDL_PrivateJoystickAdded(SDL_JoystickID instance_id)
|
||||
SDL_JoystickDriver *driver;
|
||||
int device_index;
|
||||
int player_index = -1;
|
||||
bool is_gamepad;
|
||||
|
||||
SDL_AssertJoysticksLocked();
|
||||
|
||||
@@ -2177,9 +2178,12 @@ void SDL_PrivateJoystickAdded(SDL_JoystickID instance_id)
|
||||
}
|
||||
}
|
||||
|
||||
// This might create an automatic gamepad mapping, so wait to send the event
|
||||
is_gamepad = SDL_IsGamepad(instance_id);
|
||||
|
||||
SDL_joystick_being_added = false;
|
||||
|
||||
if (SDL_IsGamepad(instance_id)) {
|
||||
if (is_gamepad) {
|
||||
SDL_PrivateGamepadAdded(instance_id);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user