mirror of https://github.com/PCSX2/pcsx2.git
SDLInputSource: Deduplicate controllers based on instance ID
This commit is contained in:
parent
217999912a
commit
f46c3b36cc
|
@ -592,6 +592,20 @@ bool SDLInputSource::OpenDevice(int index, bool is_gamecontroller)
|
|||
|
||||
const int joystick_id = SDL_JoystickInstanceID(joystick);
|
||||
int player_id = gcontroller ? SDL_GameControllerGetPlayerIndex(gcontroller) : SDL_JoystickGetPlayerIndex(joystick);
|
||||
for (auto it = m_controllers.begin(); it != m_controllers.end(); ++it)
|
||||
{
|
||||
if (it->joystick_id == joystick_id)
|
||||
{
|
||||
Console.Error("(SDLInputSource) Controller %d, instance %d, player %d already connected, ignoring.", index, joystick_id, player_id);
|
||||
if (gcontroller)
|
||||
SDL_GameControllerClose(gcontroller);
|
||||
else
|
||||
SDL_JoystickClose(joystick);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (player_id < 0 || GetControllerDataForPlayerId(player_id) != m_controllers.end())
|
||||
{
|
||||
const int free_player_id = GetFreePlayerId();
|
||||
|
|
Loading…
Reference in New Issue