Skip to content

Commit 97d6113

Browse files
authored
Merge pull request #2 from loicmagne/double_added_gamepad
fix double added gamepad
2 parents 71247be + 04b72e8 commit 97d6113

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/device/gamepad.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ std::string button_to_string(SDL_GamepadButton button)
5353

5454
void GamepadDevice::add_gamepad(SDL_JoystickID joystickid)
5555
{
56+
// Return if the gamepad is already opened
57+
int idx = get_gamepad_idx(joystickid);
58+
if (idx >= 0 && m_gamepads[idx]) { return; }
59+
5660
SDL_Gamepad *gamepad = SDL_OpenGamepad(joystickid);
5761
if (gamepad) {
5862
m_gamepads.push_back(gamepad);

0 commit comments

Comments
 (0)