From 885b3f6948debb2726427a1e9de642b7e73afb93 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 23 Mar 2020 14:10:25 -0700 Subject: [PATCH] Don't check the HIDAPI driver for the virtual device created by xow --- src/joystick/linux/SDL_sysjoystick.c | 15 ++++++++++++++- src/joystick/usb_ids.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index 2321ba23d6544..28bccd8eab51f 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -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) @@ -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; diff --git a/src/joystick/usb_ids.h b/src/joystick/usb_ids.h index cf806bdd995e4..519742da4e695 100644 --- a/src/joystick/usb_ids.h +++ b/src/joystick/usb_ids.h @@ -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