Skip to content
This repository has been archived by the owner on Oct 30, 2019. It is now read-only.

Commit

Permalink
Cleaner duplicate joystick instance check
Browse files Browse the repository at this point in the history
  • Loading branch information
flibitijibibo committed Jun 25, 2015
1 parent 242871e commit 042d9cb
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/SDL2/Input/SDL2_GamePad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,15 @@ internal static void INTERNAL_AddInstance(int dev)
IntPtr thisJoystick = SDL.SDL_GameControllerGetJoystick(INTERNAL_devices[which]);

// Pair up the instance ID to the player index.
// FIXME: Remove try/catch after 2.0.4! -flibit
try
{
INTERNAL_instanceList.Add(SDL.SDL_JoystickInstanceID(thisJoystick), which);
} catch
// FIXME: Remove check after 2.0.4? -flibit
int thisInstance = SDL.SDL_JoystickInstanceID(thisJoystick);
if (INTERNAL_instanceList.ContainsKey(thisInstance))
{
// OSX duplicate, WOOPS
// Duplicate? Usually this is OSX being dumb, but...?
INTERNAL_devices[which] = IntPtr.Zero;
return;
}
INTERNAL_instanceList.Add(thisInstance, which);

// Start with a fresh state.
INTERNAL_states[which] = InitializedState;
Expand Down

0 comments on commit 042d9cb

Please sign in to comment.