Fixed input from the Steam Virtual Gamepad on Mac OS X
authorSam Lantinga <slouken@libsdl.org>
Wed, 15 Aug 2018 19:53:34 -0700
changeset 121150d9277d27e2d
parent 12114 34cc14308155
child 12116 b65fb56dcf88
Fixed input from the Steam Virtual Gamepad on Mac OS X
src/joystick/SDL_gamecontrollerdb.h
src/joystick/android/SDL_sysjoystick.c
src/joystick/darwin/SDL_sysjoystick.c
src/joystick/hidapi/SDL_hidapi_ps4.c
src/joystick/hidapi/SDL_hidapi_switch.c
src/joystick/hidapi/SDL_hidapi_xbox360.c
src/joystick/hidapi/SDL_hidapi_xboxone.c
src/joystick/hidapi/SDL_hidapijoystick.c
src/joystick/hidapi/SDL_hidapijoystick_c.h
src/joystick/linux/SDL_sysjoystick.c
src/joystick/windows/SDL_dinputjoystick.c
src/joystick/windows/SDL_xinputjoystick.c
     1.1 --- a/src/joystick/SDL_gamecontrollerdb.h	Wed Aug 15 19:53:31 2018 -0700
     1.2 +++ b/src/joystick/SDL_gamecontrollerdb.h	Wed Aug 15 19:53:34 2018 -0700
     1.3 @@ -324,7 +324,7 @@
     1.4      "03000000811700007e05000000000000,Sega Saturn,a:b2,b:b4,dpdown:b16,dpleft:b15,dpright:b14,dpup:b17,leftshoulder:b8,lefttrigger:a5,leftx:a0,lefty:a2,rightshoulder:b9,righttrigger:a4,start:b13,x:b0,y:b6,",
     1.5      "030000004c050000cc09000000000000,Sony DualShock 4 V2,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
     1.6      "030000004c050000a00b000000000000,Sony DualShock 4 Wireless Adaptor,a:b1,b:b2,back:b13,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:a4,rightx:a2,righty:a5,start:b9,x:b0,y:b3,",
     1.7 -    "030000005e0400008e02000001000000,Steam Virtual GamePad,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,",
     1.8 +    "030000005e0400008e02000001000000,Steam Virtual Gamepad,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b8,x:b2,y:b3,",
     1.9      "03000000110100002014000000000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3,start:b12,x:b2,y:b3,",
    1.10      "03000000110100002014000001000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,x:b2,y:b3,",
    1.11      "03000000381000002014000001000000,SteelSeries Nimbus,a:b0,b:b1,dpdown:b9,dpleft:b11,dpright:b10,dpup:b8,guide:b12,leftshoulder:b4,lefttrigger:b6,leftx:a0,lefty:a1~,rightshoulder:b5,righttrigger:b7,rightx:a2,righty:a3~,x:b2,y:b3,",
     2.1 --- a/src/joystick/android/SDL_sysjoystick.c	Wed Aug 15 19:53:31 2018 -0700
     2.2 +++ b/src/joystick/android/SDL_sysjoystick.c	Wed Aug 15 19:53:34 2018 -0700
     2.3 @@ -344,7 +344,7 @@
     2.4      }
     2.5  
     2.6  #ifdef SDL_JOYSTICK_HIDAPI
     2.7 -    if (HIDAPI_IsDevicePresent(vendor_id, product_id)) {
     2.8 +    if (HIDAPI_IsDevicePresent(vendor_id, product_id, 0)) {
     2.9          /* The HIDAPI driver is taking care of this device */
    2.10          return -1;
    2.11      }
     3.1 --- a/src/joystick/darwin/SDL_sysjoystick.c	Wed Aug 15 19:53:31 2018 -0700
     3.2 +++ b/src/joystick/darwin/SDL_sysjoystick.c	Wed Aug 15 19:53:34 2018 -0700
     3.3 @@ -451,7 +451,7 @@
     3.4      }
     3.5  
     3.6  #ifdef SDL_JOYSTICK_HIDAPI
     3.7 -    if (HIDAPI_IsDevicePresent(vendor, product)) {
     3.8 +    if (HIDAPI_IsDevicePresent(vendor, product, version)) {
     3.9          /* The HIDAPI driver is taking care of this device */
    3.10          return 0;
    3.11      }
     4.1 --- a/src/joystick/hidapi/SDL_hidapi_ps4.c	Wed Aug 15 19:53:31 2018 -0700
     4.2 +++ b/src/joystick/hidapi/SDL_hidapi_ps4.c	Wed Aug 15 19:53:34 2018 -0700
     4.3 @@ -206,7 +206,7 @@
     4.4  }
     4.5  
     4.6  static SDL_bool
     4.7 -HIDAPI_DriverPS4_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, int interface_number, Uint16 usage_page, Uint16 usage)
     4.8 +HIDAPI_DriverPS4_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, Uint16 usage_page, Uint16 usage)
     4.9  {
    4.10      /* The Revolution Pro Controller exposes multiple interfaces on Windows */
    4.11      const Uint16 NACON_USB_VID = 0x146b;
     5.1 --- a/src/joystick/hidapi/SDL_hidapi_switch.c	Wed Aug 15 19:53:31 2018 -0700
     5.2 +++ b/src/joystick/hidapi/SDL_hidapi_switch.c	Wed Aug 15 19:53:34 2018 -0700
     5.3 @@ -210,7 +210,7 @@
     5.4  
     5.5  
     5.6  static SDL_bool
     5.7 -HIDAPI_DriverSwitch_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, int interface_number, Uint16 usage_page, Uint16 usage)
     5.8 +HIDAPI_DriverSwitch_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, Uint16 usage_page, Uint16 usage)
     5.9  {
    5.10      return SDL_IsJoystickNintendoSwitchPro(vendor_id, product_id);
    5.11  }
     6.1 --- a/src/joystick/hidapi/SDL_hidapi_xbox360.c	Wed Aug 15 19:53:31 2018 -0700
     6.2 +++ b/src/joystick/hidapi/SDL_hidapi_xbox360.c	Wed Aug 15 19:53:34 2018 -0700
     6.3 @@ -170,9 +170,13 @@
     6.4  
     6.5  
     6.6  static SDL_bool
     6.7 -HIDAPI_DriverXbox360_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, int interface_number, Uint16 usage_page, Uint16 usage)
     6.8 +HIDAPI_DriverXbox360_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, Uint16 usage_page, Uint16 usage)
     6.9  {
    6.10  #ifdef __MACOSX__
    6.11 +	if (vendor_id == 0x045e && product_id == 0x028e && version == 1) {
    6.12 +		/* This is the Steam Virtual Gamepad, which isn't supported by this driver */
    6.13 +		return SDL_FALSE;
    6.14 +	}
    6.15      return SDL_IsJoystickXbox360(vendor_id, product_id) || SDL_IsJoystickXboxOne(vendor_id, product_id);
    6.16  #else
    6.17      return SDL_IsJoystickXbox360(vendor_id, product_id);
     7.1 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c	Wed Aug 15 19:53:31 2018 -0700
     7.2 +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c	Wed Aug 15 19:53:34 2018 -0700
     7.3 @@ -171,7 +171,7 @@
     7.4  
     7.5  
     7.6  static SDL_bool
     7.7 -HIDAPI_DriverXboxOne_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, int interface_number, Uint16 usage_page, Uint16 usage)
     7.8 +HIDAPI_DriverXboxOne_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, Uint16 usage_page, Uint16 usage)
     7.9  {
    7.10      return SDL_IsJoystickXboxOne(vendor_id, product_id);
    7.11  }
     8.1 --- a/src/joystick/hidapi/SDL_hidapijoystick.c	Wed Aug 15 19:53:31 2018 -0700
     8.2 +++ b/src/joystick/hidapi/SDL_hidapijoystick.c	Wed Aug 15 19:53:34 2018 -0700
     8.3 @@ -64,6 +64,7 @@
     8.4      char *path;
     8.5      Uint16 vendor_id;
     8.6      Uint16 product_id;
     8.7 +	Uint16 version;
     8.8      SDL_JoystickGUID guid;
     8.9      int interface_number;   /* Available on Windows and Linux */
    8.10      Uint16 usage_page;      /* Available on Windows and Mac OS X */
    8.11 @@ -378,13 +379,13 @@
    8.12  
    8.13  
    8.14  static SDL_bool
    8.15 -HIDAPI_IsDeviceSupported(Uint16 vendor_id, Uint16 product_id)
    8.16 +HIDAPI_IsDeviceSupported(Uint16 vendor_id, Uint16 product_id, Uint16 version)
    8.17  {
    8.18      int i;
    8.19  
    8.20      for (i = 0; i < SDL_arraysize(SDL_HIDAPI_drivers); ++i) {
    8.21          SDL_HIDAPI_DeviceDriver *driver = SDL_HIDAPI_drivers[i];
    8.22 -        if (driver->enabled && driver->IsSupportedDevice(vendor_id, product_id, -1, 0, 0)) {
    8.23 +        if (driver->enabled && driver->IsSupportedDevice(vendor_id, product_id, version, -1, 0, 0)) {
    8.24              return SDL_TRUE;
    8.25          }
    8.26      }
    8.27 @@ -402,7 +403,7 @@
    8.28  
    8.29      for (i = 0; i < SDL_arraysize(SDL_HIDAPI_drivers); ++i) {
    8.30          SDL_HIDAPI_DeviceDriver *driver = SDL_HIDAPI_drivers[i];
    8.31 -        if (driver->enabled && driver->IsSupportedDevice(device->vendor_id, device->product_id, device->interface_number, device->usage_page, device->usage)) {
    8.32 +        if (driver->enabled && driver->IsSupportedDevice(device->vendor_id, device->product_id, device->version, device->interface_number, device->usage_page, device->usage)) {
    8.33              return driver;
    8.34          }
    8.35      }
    8.36 @@ -532,6 +533,7 @@
    8.37      device->seen = SDL_TRUE;
    8.38      device->vendor_id = info->vendor_id;
    8.39      device->product_id = info->product_id;
    8.40 +	device->version = info->release_number;
    8.41      device->interface_number = info->interface_number;
    8.42      device->usage_page = info->usage_page;
    8.43      device->usage = info->usage;
    8.44 @@ -539,7 +541,7 @@
    8.45          /* FIXME: Is there any way to tell whether this is a Bluetooth device? */
    8.46          const Uint16 vendor = device->vendor_id;
    8.47          const Uint16 product = device->product_id;
    8.48 -        const Uint16 version = 0;
    8.49 +        const Uint16 version = device->version;
    8.50          Uint16 *guid16 = (Uint16 *)device->guid.data;
    8.51  
    8.52          *guid16++ = SDL_SwapLE16(SDL_HARDWARE_BUS_USB);
    8.53 @@ -608,7 +610,7 @@
    8.54      }
    8.55  
    8.56  #ifdef DEBUG_HIDAPI
    8.57 -    SDL_Log("Adding HIDAPI device '%s' interface %d, usage page 0x%.4x, usage 0x%.4x\n", device->name, device->interface_number, device->usage_page, device->usage);
    8.58 +    SDL_Log("Adding HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, interface %d, usage page 0x%.4x, usage 0x%.4x\n", device->name, device->vendor_id, device->product_id, device->version, device->interface_number, device->usage_page, device->usage);
    8.59  #endif
    8.60  
    8.61      /* Add it to the list */
    8.62 @@ -696,12 +698,12 @@
    8.63  }
    8.64  
    8.65  SDL_bool
    8.66 -HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id)
    8.67 +HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version)
    8.68  {
    8.69      SDL_HIDAPI_Device *device;
    8.70  
    8.71      /* Don't update the device list for devices we know aren't supported */
    8.72 -    if (!HIDAPI_IsDeviceSupported(vendor_id, product_id)) {
    8.73 +    if (!HIDAPI_IsDeviceSupported(vendor_id, product_id, version)) {
    8.74          return SDL_FALSE;
    8.75      }
    8.76  
     9.1 --- a/src/joystick/hidapi/SDL_hidapijoystick_c.h	Wed Aug 15 19:53:31 2018 -0700
     9.2 +++ b/src/joystick/hidapi/SDL_hidapijoystick_c.h	Wed Aug 15 19:53:34 2018 -0700
     9.3 @@ -46,7 +46,7 @@
     9.4  {
     9.5      const char *hint;
     9.6      SDL_bool enabled;
     9.7 -    SDL_bool (*IsSupportedDevice)(Uint16 vendor_id, Uint16 product_id, int interface_number, Uint16 usage_page, Uint16 usage);
     9.8 +    SDL_bool (*IsSupportedDevice)(Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, Uint16 usage_page, Uint16 usage);
     9.9      const char *(*GetDeviceName)(Uint16 vendor_id, Uint16 product_id);
    9.10      SDL_bool (*Init)(SDL_Joystick *joystick, hid_device *dev, Uint16 vendor_id, Uint16 product_id, void **context);
    9.11      int (*Rumble)(SDL_Joystick *joystick, hid_device *dev, void *context, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
    9.12 @@ -63,7 +63,7 @@
    9.13  extern SDL_HIDAPI_DeviceDriver SDL_HIDAPI_DriverXboxOne;
    9.14  
    9.15  /* Return true if a HID device is present and supported as a joystick */
    9.16 -extern SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id);
    9.17 +extern SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version);
    9.18  
    9.19  #endif /* SDL_JOYSTICK_HIDAPI_H */
    9.20  
    10.1 --- a/src/joystick/linux/SDL_sysjoystick.c	Wed Aug 15 19:53:31 2018 -0700
    10.2 +++ b/src/joystick/linux/SDL_sysjoystick.c	Wed Aug 15 19:53:34 2018 -0700
    10.3 @@ -211,7 +211,7 @@
    10.4      }
    10.5  
    10.6  #ifdef SDL_JOYSTICK_HIDAPI
    10.7 -    if (HIDAPI_IsDevicePresent(inpid.vendor, inpid.product)) {
    10.8 +    if (HIDAPI_IsDevicePresent(inpid.vendor, inpid.product, inpid.version)) {
    10.9          /* The HIDAPI driver is taking care of this device */
   10.10          return 0;
   10.11      }
    11.1 --- a/src/joystick/windows/SDL_dinputjoystick.c	Wed Aug 15 19:53:31 2018 -0700
    11.2 +++ b/src/joystick/windows/SDL_dinputjoystick.c	Wed Aug 15 19:53:34 2018 -0700
    11.3 @@ -535,7 +535,7 @@
    11.4      }
    11.5  
    11.6  #ifdef SDL_JOYSTICK_HIDAPI
    11.7 -    if (HIDAPI_IsDevicePresent(vendor, product)) {
    11.8 +    if (HIDAPI_IsDevicePresent(vendor, product, 0)) {
    11.9          /* The HIDAPI driver is taking care of this device */
   11.10          SDL_free(pNewJoystick);
   11.11          return DIENUM_CONTINUE;
    12.1 --- a/src/joystick/windows/SDL_xinputjoystick.c	Wed Aug 15 19:53:31 2018 -0700
    12.2 +++ b/src/joystick/windows/SDL_xinputjoystick.c	Wed Aug 15 19:53:34 2018 -0700
    12.3 @@ -261,7 +261,7 @@
    12.4  
    12.5  #if 0 /* There's no controller that's supported by both XInput and HIDAPI */
    12.6  #ifdef SDL_JOYSTICK_HIDAPI
    12.7 -    if (HIDAPI_IsDevicePresent(vendor, product)) {
    12.8 +    if (HIDAPI_IsDevicePresent(vendor, product, version)) {
    12.9          /* The HIDAPI driver is taking care of this device */
   12.10          SDL_free(pNewJoystick);
   12.11          return;