Navigation Menu

Skip to content

Commit

Permalink
Don't check the HIDAPI driver for the virtual device created by xow
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Mar 23, 2020
1 parent 2c02b74 commit 885b3f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/joystick/linux/SDL_sysjoystick.c
Expand Up @@ -104,6 +104,18 @@ FixupDeviceInfoForMapping(int fd, struct input_id *inpid)
}
}

#ifdef SDL_JOYSTICK_HIDAPI
static SDL_bool
IsVirtualJoystick(Uint16 vendor, Uint16 product, Uint16 version, const char *name)
{
if (vendor == USB_VENDOR_MICROSOFT && product == USB_PRODUCT_XBOX_ONE_S && version == 0 &&
SDL_strcmp(name, "Xbox One S Controller") == 0) {
/* This is the virtual device created by the xow driver */
return SDL_TRUE;
}
return SDL_FALSE;
}
#endif /* SDL_JOYSTICK_HIDAPI */

static int
IsJoystick(int fd, char **name_return, SDL_JoystickGUID *guid)
Expand Down Expand Up @@ -145,7 +157,8 @@ IsJoystick(int fd, char **name_return, SDL_JoystickGUID *guid)
}

#ifdef SDL_JOYSTICK_HIDAPI
if (HIDAPI_IsDevicePresent(inpid.vendor, inpid.product, inpid.version, name)) {
if (!IsVirtualJoystick(inpid.vendor, inpid.product, inpid.version, name) &&
HIDAPI_IsDevicePresent(inpid.vendor, inpid.product, inpid.version, name)) {
/* The HIDAPI driver is taking care of this device */
SDL_free(name);
return 0;
Expand Down
1 change: 1 addition & 0 deletions src/joystick/usb_ids.h
Expand Up @@ -44,6 +44,7 @@
#define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_1 0x02e3
#define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2 0x0b00
#define USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH 0x0b05
#define USB_PRODUCT_XBOX_ONE_S 0x02ea
#define USB_PRODUCT_XBOX_ONE_S_REV1_BLUETOOTH 0x02e0
#define USB_PRODUCT_XBOX_ONE_S_REV2_BLUETOOTH 0x02fd

Expand Down

0 comments on commit 885b3f6

Please sign in to comment.