src/joystick/linux/SDL_sysjoystick.c
changeset 13670 63387e8920f5
parent 13611 bcbfec15e25f
     1.1 --- a/src/joystick/linux/SDL_sysjoystick.c	Mon Mar 23 12:10:05 2020 -0700
     1.2 +++ b/src/joystick/linux/SDL_sysjoystick.c	Mon Mar 23 14:10:25 2020 -0700
     1.3 @@ -104,6 +104,18 @@
     1.4      }
     1.5  }
     1.6  
     1.7 +#ifdef SDL_JOYSTICK_HIDAPI
     1.8 +static SDL_bool
     1.9 +IsVirtualJoystick(Uint16 vendor, Uint16 product, Uint16 version, const char *name)
    1.10 +{
    1.11 +    if (vendor == USB_VENDOR_MICROSOFT && product == USB_PRODUCT_XBOX_ONE_S && version == 0 &&
    1.12 +        SDL_strcmp(name, "Xbox One S Controller") == 0) {
    1.13 +        /* This is the virtual device created by the xow driver */
    1.14 +        return SDL_TRUE;
    1.15 +    }
    1.16 +    return SDL_FALSE;
    1.17 +}
    1.18 +#endif /* SDL_JOYSTICK_HIDAPI */
    1.19  
    1.20  static int
    1.21  IsJoystick(int fd, char **name_return, SDL_JoystickGUID *guid)
    1.22 @@ -145,7 +157,8 @@
    1.23      }
    1.24  
    1.25  #ifdef SDL_JOYSTICK_HIDAPI
    1.26 -    if (HIDAPI_IsDevicePresent(inpid.vendor, inpid.product, inpid.version, name)) {
    1.27 +    if (!IsVirtualJoystick(inpid.vendor, inpid.product, inpid.version, name) &&
    1.28 +        HIDAPI_IsDevicePresent(inpid.vendor, inpid.product, inpid.version, name)) {
    1.29          /* The HIDAPI driver is taking care of this device */
    1.30          SDL_free(name);
    1.31          return 0;