Skip to content

Commit

Permalink
Fixed Xbox One Elite Series 2 showing up as 2 devices in Bluetooth mo…
Browse files Browse the repository at this point in the history
…de on Windows
  • Loading branch information
slouken committed Nov 20, 2019
1 parent 200d37d commit ce8411c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/joystick/windows/SDL_dinputjoystick.c
Expand Up @@ -504,8 +504,7 @@ EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
return DIENUM_CONTINUE; /* better luck next time? */
}

SDL_memcpy(&(pNewJoystick->dxdevice), pdidInstance,
sizeof(DIDEVICEINSTANCE));
SDL_memcpy(&pNewJoystick->dxdevice, pdidInstance, sizeof(DIDEVICEINSTANCE));

SDL_memset(pNewJoystick->guid.data, 0, sizeof(pNewJoystick->guid.data));

Expand All @@ -529,14 +528,25 @@ EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
SDL_strlcpy((char*)guid16, pNewJoystick->joystickname, sizeof(pNewJoystick->guid.data) - 4);
}

if (SDL_strstr(pNewJoystick->joystickname, " XINPUT ") != NULL) {
/* This is a duplicate interface for a controller that will show up with XInput,
e.g. Xbox One Elite Series 2 in Bluetooth mode.
*/
SDL_free(pNewJoystick->joystickname);
SDL_free(pNewJoystick);
return DIENUM_CONTINUE;
}

if (SDL_ShouldIgnoreJoystick(pNewJoystick->joystickname, pNewJoystick->guid)) {
SDL_free(pNewJoystick->joystickname);
SDL_free(pNewJoystick);
return DIENUM_CONTINUE;
}

#ifdef SDL_JOYSTICK_HIDAPI
if (HIDAPI_IsDevicePresent(vendor, product, 0, pNewJoystick->joystickname)) {
/* The HIDAPI driver is taking care of this device */
SDL_free(pNewJoystick->joystickname);
SDL_free(pNewJoystick);
return DIENUM_CONTINUE;
}
Expand Down

0 comments on commit ce8411c

Please sign in to comment.