Fixed build
authorSam Lantinga <slouken@libsdl.org>
Fri, 22 Nov 2019 14:09:24 -0800
changeset 13277b72b5a030eee
parent 13276 c95ba765e925
child 13278 f0c01449a659
Fixed build
src/joystick/SDL_gamecontroller.c
src/joystick/SDL_joystick.c
src/joystick/SDL_joystick_c.h
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/windows/SDL_dinputjoystick.c
     1.1 --- a/src/joystick/SDL_gamecontroller.c	Fri Nov 22 13:44:40 2019 -0800
     1.2 +++ b/src/joystick/SDL_gamecontroller.c	Fri Nov 22 14:09:24 2019 -0800
     1.3 @@ -1418,8 +1418,7 @@
     1.4  SDL_GameControllerType
     1.5  SDL_GameControllerTypeForIndex(int joystick_index)
     1.6  {
     1.7 -    SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(joystick_index);
     1.8 -    return SDL_GetGameControllerTypeFromGUID(guid);
     1.9 +    return SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGetDeviceGUID(joystick_index), SDL_JoystickNameForIndex(joystick_index));
    1.10  }
    1.11  
    1.12  
    1.13 @@ -1757,10 +1756,7 @@
    1.14  SDL_GameControllerType
    1.15  SDL_GameControllerGetType(SDL_GameController *gamecontroller)
    1.16  {
    1.17 -    if (!gamecontroller) {
    1.18 -        return SDL_CONTROLLER_TYPE_UNKNOWN;
    1.19 -    }
    1.20 -    return SDL_GetGameControllerTypeFromGUID(gamecontroller->joystick->guid);
    1.21 +    return SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGetGUID(SDL_GameControllerGetJoystick(gamecontroller)), SDL_JoystickName(SDL_GameControllerGetJoystick(gamecontroller)));
    1.22  }
    1.23  
    1.24  int
     2.1 --- a/src/joystick/SDL_joystick.c	Fri Nov 22 13:44:40 2019 -0800
     2.2 +++ b/src/joystick/SDL_joystick.c	Fri Nov 22 14:09:24 2019 -0800
     2.3 @@ -1167,13 +1167,13 @@
     2.4  }
     2.5  
     2.6  SDL_GameControllerType
     2.7 -SDL_GetGameControllerTypeFromGUID(SDL_JoystickGUID guid)
     2.8 +SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGUID guid, const char *name)
     2.9  {
    2.10      SDL_GameControllerType type;
    2.11      Uint16 vendor, product;
    2.12  
    2.13      SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL);
    2.14 -    type = SDL_GetGameControllerType(vendor, product);
    2.15 +    type = SDL_GetJoystickGameControllerType(vendor, product, name);
    2.16      if (type == SDL_CONTROLLER_TYPE_UNKNOWN) {
    2.17          if (SDL_IsJoystickXInput(guid)) {
    2.18              /* This is probably an Xbox One controller */
    2.19 @@ -1184,10 +1184,16 @@
    2.20  }
    2.21  
    2.22  SDL_GameControllerType
    2.23 -SDL_GetGameControllerType(Uint16 vendor, Uint16 product)
    2.24 +SDL_GetJoystickGameControllerType(Uint16 vendor, Uint16 product, const char *name)
    2.25  {
    2.26 -    /* Filter out some bogus values here */
    2.27      if (vendor == 0x0000 && product == 0x0000) {
    2.28 +        /* Some devices are only identifiable by their name */
    2.29 +        if (SDL_strcmp(name, "Lic Pro Controller") == 0 ||
    2.30 +            SDL_strcmp(name, "Nintendo Wireless Gamepad") == 0 ||
    2.31 +            SDL_strcmp(name, "Wireless Gamepad") == 0) {
    2.32 +            /* HORI or PowerA Switch Pro Controller clone */
    2.33 +            return SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO;
    2.34 +        }
    2.35          return SDL_CONTROLLER_TYPE_UNKNOWN;
    2.36      }
    2.37      if (vendor == 0x0001 && product == 0x0001) {
    2.38 @@ -1501,7 +1507,7 @@
    2.39          }
    2.40      }
    2.41  
    2.42 -    if (SDL_GetGameControllerType(vendor, product) == SDL_CONTROLLER_TYPE_PS4 && SDL_IsPS4RemapperRunning()) {
    2.43 +    if (SDL_GetJoystickGameControllerType(vendor, product, name) == SDL_CONTROLLER_TYPE_PS4 && SDL_IsPS4RemapperRunning()) {
    2.44          return SDL_TRUE;
    2.45      }
    2.46  
     3.1 --- a/src/joystick/SDL_joystick_c.h	Fri Nov 22 13:44:40 2019 -0800
     3.2 +++ b/src/joystick/SDL_joystick_c.h	Fri Nov 22 14:09:24 2019 -0800
     3.3 @@ -53,8 +53,8 @@
     3.4  extern void SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version);
     3.5  
     3.6  /* Function to return the type of a controller */
     3.7 -extern SDL_GameControllerType SDL_GetGameControllerTypeFromGUID(SDL_JoystickGUID guid);
     3.8 -extern SDL_GameControllerType SDL_GetGameControllerType(Uint16 vendor, Uint16 product);
     3.9 +extern SDL_GameControllerType SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGUID guid, const char *name);
    3.10 +extern SDL_GameControllerType SDL_GetJoystickGameControllerType(Uint16 vendor, Uint16 product, const char *name);
    3.11  
    3.12  /* Function to return whether a joystick is a Nintendo Switch Pro controller */
    3.13  extern SDL_bool SDL_IsJoystickNintendoSwitchProInputOnly(Uint16 vendor_id, Uint16 product_id);
     4.1 --- a/src/joystick/hidapi/SDL_hidapi_ps4.c	Fri Nov 22 13:44:40 2019 -0800
     4.2 +++ b/src/joystick/hidapi/SDL_hidapi_ps4.c	Fri Nov 22 14:09:24 2019 -0800
     4.3 @@ -141,7 +141,7 @@
     4.4  static SDL_bool
     4.5  HIDAPI_DriverPS4_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, const char *name)
     4.6  {
     4.7 -    return (SDL_GetGameControllerType(vendor_id, product_id) == SDL_CONTROLLER_TYPE_PS4);
     4.8 +    return (SDL_GetJoystickGameControllerType(vendor_id, product_id, name) == SDL_CONTROLLER_TYPE_PS4);
     4.9  }
    4.10  
    4.11  static const char *
     5.1 --- a/src/joystick/hidapi/SDL_hidapi_switch.c	Fri Nov 22 13:44:40 2019 -0800
     5.2 +++ b/src/joystick/hidapi/SDL_hidapi_switch.c	Fri Nov 22 14:09:24 2019 -0800
     5.3 @@ -226,16 +226,7 @@
     5.4  static SDL_bool
     5.5  HIDAPI_DriverSwitch_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, const char *name)
     5.6  {
     5.7 -    if (vendor_id == 0 && product_id == 0) {
     5.8 -        /* Some devices are only identifiable by their name */
     5.9 -        if (SDL_strcmp(name, "Lic Pro Controller") == 0 ||
    5.10 -            SDL_strcmp(name, "Nintendo Wireless Gamepad") == 0 ||
    5.11 -            SDL_strcmp(name, "Wireless Gamepad") == 0) {
    5.12 -            /* HORI or PowerA Switch Pro Controller clone */
    5.13 -            return SDL_TRUE;
    5.14 -        }
    5.15 -    }
    5.16 -    return SDL_IsJoystickNintendoSwitchPro(vendor_id, product_id);
    5.17 +    return (SDL_GetJoystickGameControllerType(vendor_id, product_id, name) == SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO);
    5.18  }
    5.19  
    5.20  static const char *
     6.1 --- a/src/joystick/hidapi/SDL_hidapi_xbox360.c	Fri Nov 22 13:44:40 2019 -0800
     6.2 +++ b/src/joystick/hidapi/SDL_hidapi_xbox360.c	Fri Nov 22 14:09:24 2019 -0800
     6.3 @@ -249,7 +249,7 @@
     6.4  static SDL_bool
     6.5  HIDAPI_DriverXbox360_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, const char *name)
     6.6  {
     6.7 -    SDL_GameControllerType type = SDL_GameControllerType(vendor_id, product_id);
     6.8 +    SDL_GameControllerType type = SDL_GetJoystickGameControllerType(vendor_id, product_id, name);
     6.9  
    6.10  #if defined(__MACOSX__) || defined(__WIN32__)
    6.11      if (vendor_id == 0x045e && product_id == 0x028e && version == 1) {
     7.1 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c	Fri Nov 22 13:44:40 2019 -0800
     7.2 +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c	Fri Nov 22 14:09:24 2019 -0800
     7.3 @@ -197,7 +197,7 @@
     7.4          return SDL_FALSE;
     7.5      }
     7.6  #endif
     7.7 -    return (SDL_GetGameControllerType(vendor_id, product_id) == SDL_CONTROLLER_TYPE_XBOXONE);
     7.8 +    return (SDL_GetJoystickGameControllerType(vendor_id, product_id, name) == SDL_CONTROLLER_TYPE_XBOXONE);
     7.9  }
    7.10  
    7.11  static const char *
     8.1 --- a/src/joystick/windows/SDL_dinputjoystick.c	Fri Nov 22 13:44:40 2019 -0800
     8.2 +++ b/src/joystick/windows/SDL_dinputjoystick.c	Fri Nov 22 14:09:24 2019 -0800
     8.3 @@ -374,7 +374,7 @@
     8.4      if (SDL_memcmp(&pGuidProductFromDirectInput->Data4[2], "PIDVID", 6) == 0) {
     8.5          Uint16 vendor_id = (Uint16)LOWORD(pGuidProductFromDirectInput->Data1);
     8.6          Uint16 product_id = (Uint16)HIWORD(pGuidProductFromDirectInput->Data1);
     8.7 -        SDL_GameControllerType type = SDL_GetGameControllerType(vendor_id, product_id);
     8.8 +        SDL_GameControllerType type = SDL_GetJoystickGameControllerType(vendor_id, product_id, "");
     8.9          if (type == SDL_CONTROLLER_TYPE_XBOX360 ||
    8.10              type == SDL_CONTROLLER_TYPE_XBOXONE ||
    8.11              (vendor_id == 0x28DE && product_id == 0x11FF)) {