Don't check the HIDAPI driver for the virtual device created by xow
authorSam Lantinga <slouken@libsdl.org>
Mon, 23 Mar 2020 14:10:25 -0700
changeset 1367063387e8920f5
parent 13669 06adf174772e
child 13671 769f80095217
Don't check the HIDAPI driver for the virtual device created by xow
src/joystick/linux/SDL_sysjoystick.c
src/joystick/usb_ids.h
     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;
     2.1 --- a/src/joystick/usb_ids.h	Mon Mar 23 12:10:05 2020 -0700
     2.2 +++ b/src/joystick/usb_ids.h	Mon Mar 23 14:10:25 2020 -0700
     2.3 @@ -44,6 +44,7 @@
     2.4  #define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_1             0x02e3
     2.5  #define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2             0x0b00
     2.6  #define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH   0x0b05
     2.7 +#define USB_PRODUCT_XBOX_ONE_S                          0x02ea
     2.8  #define USB_PRODUCT_XBOX_ONE_S_REV1_BLUETOOTH           0x02e0
     2.9  #define USB_PRODUCT_XBOX_ONE_S_REV2_BLUETOOTH           0x02fd
    2.10