Skip to content

Commit

Permalink
SDLInputSource: Deduplicate controllers based on instance ID
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek committed Sep 7, 2023
1 parent 2179999 commit f46c3b3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pcsx2/Input/SDLInputSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f46c3b3

Please sign in to comment.