Standardized the format of the SDL joystick GUID and added functions to retrieve the USB VID/PID from a joystick and game controller.
authorSam Lantinga <slouken@libsdl.org>
Thu, 10 Nov 2016 17:19:34 -0800
changeset 105959da2701eeb4a
parent 10594 c5cb1db86a9f
child 10596 0a9eba05187e
Standardized the format of the SDL joystick GUID and added functions to retrieve the USB VID/PID from a joystick and game controller.
configure
configure.in
include/SDL_gamecontroller.h
include/SDL_joystick.h
src/dynapi/SDL_dynapi_overrides.h
src/dynapi/SDL_dynapi_procs.h
src/joystick/SDL_gamecontroller.c
src/joystick/SDL_gamecontrollerdb.h
src/joystick/SDL_joystick.c
src/joystick/darwin/SDL_sysjoystick.c
src/joystick/darwin/SDL_sysjoystick_c.h
src/joystick/linux/SDL_sysjoystick.c
src/joystick/windows/SDL_dinputjoystick.c
     1.1 --- a/configure	Thu Nov 10 12:07:34 2016 -0500
     1.2 +++ b/configure	Thu Nov 10 17:19:34 2016 -0800
     1.3 @@ -2691,7 +2691,7 @@
     1.4  SDL_MAJOR_VERSION=2
     1.5  SDL_MINOR_VERSION=0
     1.6  SDL_MICRO_VERSION=5
     1.7 -SDL_INTERFACE_AGE=1
     1.8 +SDL_INTERFACE_AGE=0
     1.9  SDL_BINARY_AGE=5
    1.10  SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
    1.11  
    1.12 @@ -5977,7 +5977,10 @@
    1.13  	  x86_64-*linux*)
    1.14  	    LD="${LD-ld} -m elf_x86_64"
    1.15  	    ;;
    1.16 -	  ppc*-*linux*|powerpc*-*linux*)
    1.17 +	  powerpc64le-*linux*)
    1.18 +	    LD="${LD-ld} -m elf64lppc"
    1.19 +	    ;;
    1.20 +	  powerpc64-*linux*)
    1.21  	    LD="${LD-ld} -m elf64ppc"
    1.22  	    ;;
    1.23  	  s390*-*linux*|s390*-*tpf*)
     2.1 --- a/configure.in	Thu Nov 10 12:07:34 2016 -0500
     2.2 +++ b/configure.in	Thu Nov 10 17:19:34 2016 -0800
     2.3 @@ -21,7 +21,7 @@
     2.4  SDL_MAJOR_VERSION=2
     2.5  SDL_MINOR_VERSION=0
     2.6  SDL_MICRO_VERSION=5
     2.7 -SDL_INTERFACE_AGE=1
     2.8 +SDL_INTERFACE_AGE=0
     2.9  SDL_BINARY_AGE=5
    2.10  SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
    2.11  
     3.1 --- a/include/SDL_gamecontroller.h	Thu Nov 10 12:07:34 2016 -0500
     3.2 +++ b/include/SDL_gamecontroller.h	Thu Nov 10 17:19:34 2016 -0800
     3.3 @@ -87,8 +87,8 @@
     3.4   *  To count the number of game controllers in the system for the following:
     3.5   *  int nJoysticks = SDL_NumJoysticks();
     3.6   *  int nGameControllers = 0;
     3.7 - *  for ( int i = 0; i < nJoysticks; i++ ) {
     3.8 - *      if ( SDL_IsGameController(i) ) {
     3.9 + *  for (int i = 0; i < nJoysticks; i++) {
    3.10 + *      if (SDL_IsGameController(i)) {
    3.11   *          nGameControllers++;
    3.12   *      }
    3.13   *  }
    3.14 @@ -105,7 +105,7 @@
    3.15   *  Buttons can be used as a controller axis and vice versa.
    3.16   *
    3.17   *  This string shows an example of a valid mapping for a controller
    3.18 - *  "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7",
    3.19 + *  "03000000341a00003608000000000000,PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7",
    3.20   *
    3.21   */
    3.22  
    3.23 @@ -117,7 +117,7 @@
    3.24   * 
    3.25   * \return number of mappings added, -1 on error
    3.26   */
    3.27 -extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW( SDL_RWops * rw, int freerw );
    3.28 +extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw);
    3.29  
    3.30  /**
    3.31   *  Load a set of mappings from a file, filtered by the current SDL_GetPlatform()
    3.32 @@ -131,28 +131,27 @@
    3.33   *
    3.34   * \return 1 if mapping is added, 0 if updated, -1 on error
    3.35   */
    3.36 -extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping( const char* mappingString );
    3.37 +extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char* mappingString);
    3.38  
    3.39  /**
    3.40   *  Get a mapping string for a GUID
    3.41   *
    3.42   *  \return the mapping string.  Must be freed with SDL_free().  Returns NULL if no mapping is available
    3.43   */
    3.44 -extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID( SDL_JoystickGUID guid );
    3.45 +extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid);
    3.46  
    3.47  /**
    3.48   *  Get a mapping string for an open GameController
    3.49   *
    3.50   *  \return the mapping string.  Must be freed with SDL_free().  Returns NULL if no mapping is available
    3.51   */
    3.52 -extern DECLSPEC char * SDLCALL SDL_GameControllerMapping( SDL_GameController * gamecontroller );
    3.53 +extern DECLSPEC char * SDLCALL SDL_GameControllerMapping(SDL_GameController * gamecontroller);
    3.54  
    3.55  /**
    3.56   *  Is the joystick on this index supported by the game controller interface?
    3.57   */
    3.58  extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index);
    3.59  
    3.60 -
    3.61  /**
    3.62   *  Get the implementation dependent name of a game controller.
    3.63   *  This can be called before any controllers are opened.
    3.64 @@ -182,6 +181,24 @@
    3.65  extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller);
    3.66  
    3.67  /**
    3.68 + *  Get the USB vendor ID of an opened controller, if available.
    3.69 + *  If the vendor ID isn't available this function returns 0.
    3.70 + */
    3.71 +extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController * gamecontroller);
    3.72 +
    3.73 +/**
    3.74 + *  Get the USB product ID of an opened controller, if available.
    3.75 + *  If the product ID isn't available this function returns 0.
    3.76 + */
    3.77 +extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController * gamecontroller);
    3.78 +
    3.79 +/**
    3.80 + *  Get the product version of an opened controller, if available.
    3.81 + *  If the product version isn't available this function returns 0.
    3.82 + */
    3.83 +extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController * gamecontroller);
    3.84 +
    3.85 +/**
    3.86   *  Returns SDL_TRUE if the controller has been opened and currently connected,
    3.87   *  or SDL_FALSE if it has not.
    3.88   */
     4.1 --- a/include/SDL_joystick.h	Thu Nov 10 12:07:34 2016 -0500
     4.2 +++ b/include/SDL_joystick.h	Thu Nov 10 17:19:34 2016 -0800
     4.3 @@ -96,6 +96,33 @@
     4.4  extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index);
     4.5  
     4.6  /**
     4.7 + *  Return the GUID for the joystick at this index
     4.8 + *  This can be called before any joysticks are opened.
     4.9 + */
    4.10 +extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index);
    4.11 +
    4.12 +/**
    4.13 + *  Get the USB vendor ID of a joystick, if available.
    4.14 + *  This can be called before any joysticks are opened.
    4.15 + *  If the vendor ID isn't available this function returns 0.
    4.16 + */
    4.17 +extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceVendor(int device_index);
    4.18 +
    4.19 +/**
    4.20 + *  Get the USB product ID of a joystick, if available.
    4.21 + *  This can be called before any joysticks are opened.
    4.22 + *  If the product ID isn't available this function returns 0.
    4.23 + */
    4.24 +extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProduct(int device_index);
    4.25 +
    4.26 +/**
    4.27 + *  Get the product version of a joystick, if available.
    4.28 + *  This can be called before any joysticks are opened.
    4.29 + *  If the product version isn't available this function returns 0.
    4.30 + */
    4.31 +extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProductVersion(int device_index);
    4.32 +
    4.33 +/**
    4.34   *  Open a joystick for use.
    4.35   *  The index passed as an argument refers to the N'th joystick on the system.
    4.36   *  This index is not the value which will identify this joystick in future
    4.37 @@ -118,23 +145,36 @@
    4.38  extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick * joystick);
    4.39  
    4.40  /**
    4.41 - *  Return the GUID for the joystick at this index
    4.42 - */
    4.43 -extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index);
    4.44 -
    4.45 -/**
    4.46   *  Return the GUID for this opened joystick
    4.47   */
    4.48  extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick * joystick);
    4.49  
    4.50  /**
    4.51 + *  Get the USB vendor ID of an opened joystick, if available.
    4.52 + *  If the vendor ID isn't available this function returns 0.
    4.53 + */
    4.54 +extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetVendor(SDL_Joystick * joystick);
    4.55 +
    4.56 +/**
    4.57 + *  Get the USB product ID of an opened joystick, if available.
    4.58 + *  If the product ID isn't available this function returns 0.
    4.59 + */
    4.60 +extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProduct(SDL_Joystick * joystick);
    4.61 +
    4.62 +/**
    4.63 + *  Get the product version of an opened joystick, if available.
    4.64 + *  If the product version isn't available this function returns 0.
    4.65 + */
    4.66 +extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProductVersion(SDL_Joystick * joystick);
    4.67 +
    4.68 +/**
    4.69   *  Return a string representation for this guid. pszGUID must point to at least 33 bytes
    4.70   *  (32 for the string plus a NULL terminator).
    4.71   */
    4.72  extern DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID);
    4.73  
    4.74  /**
    4.75 - *  convert a string into a joystick formatted guid
    4.76 + *  Convert a string into a joystick guid
    4.77   */
    4.78  extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID);
    4.79  
     5.1 --- a/src/dynapi/SDL_dynapi_overrides.h	Thu Nov 10 12:07:34 2016 -0500
     5.2 +++ b/src/dynapi/SDL_dynapi_overrides.h	Thu Nov 10 17:19:34 2016 -0800
     5.3 @@ -612,3 +612,12 @@
     5.4  #define SDL_CreateRGBSurfaceWithFormat SDL_CreateRGBSurfaceWithFormat_REAL
     5.5  #define SDL_CreateRGBSurfaceWithFormatFrom SDL_CreateRGBSurfaceWithFormatFrom_REAL
     5.6  #define SDL_GetHintBoolean SDL_GetHintBoolean_REAL
     5.7 +#define SDL_JoystickGetDeviceVendor SDL_JoystickGetDeviceVendor_REAL
     5.8 +#define SDL_JoystickGetDeviceProduct SDL_JoystickGetDeviceProduct_REAL
     5.9 +#define SDL_JoystickGetDeviceProductVersion SDL_JoystickGetDeviceProductVersion_REAL
    5.10 +#define SDL_JoystickGetVendor SDL_JoystickGetVendor_REAL
    5.11 +#define SDL_JoystickGetProduct SDL_JoystickGetProduct_REAL
    5.12 +#define SDL_JoystickGetProductVersion SDL_JoystickGetProductVersion_REAL
    5.13 +#define SDL_GameControllerGetVendor SDL_GameControllerGetVendor_REAL
    5.14 +#define SDL_GameControllerGetProduct SDL_GameControllerGetProduct_REAL
    5.15 +#define SDL_GameControllerGetProductVersion SDL_GameControllerGetProductVersion_REAL
     6.1 --- a/src/dynapi/SDL_dynapi_procs.h	Thu Nov 10 12:07:34 2016 -0500
     6.2 +++ b/src/dynapi/SDL_dynapi_procs.h	Thu Nov 10 17:19:34 2016 -0800
     6.3 @@ -644,3 +644,12 @@
     6.4  SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurfaceWithFormat,(Uint32 a, int b, int c, int d, Uint32 e),(a,b,c,d,e),return)
     6.5  SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurfaceWithFormatFrom,(void *a, int b, int c, int d, int e, Uint32 f),(a,b,c,d,e,f),return)
     6.6  SDL_DYNAPI_PROC(SDL_bool,SDL_GetHintBoolean,(const char *a, SDL_bool b),(a,b),return)
     6.7 +SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetDeviceVendor,(int a),(a),return)
     6.8 +SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetDeviceProduct,(int a),(a),return)
     6.9 +SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetDeviceProductVersion,(int a),(a),return)
    6.10 +SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetVendor,(SDL_Joystick *a),(a),return)
    6.11 +SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetProduct,(SDL_Joystick *a),(a),return)
    6.12 +SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetProductVersion,(SDL_Joystick *a),(a),return)
    6.13 +SDL_DYNAPI_PROC(Uint16,SDL_GameControllerGetVendor,(SDL_GameController *a),(a),return)
    6.14 +SDL_DYNAPI_PROC(Uint16,SDL_GameControllerGetProduct,(SDL_GameController *a),(a),return)
    6.15 +SDL_DYNAPI_PROC(Uint16,SDL_GameControllerGetProductVersion,(SDL_GameController *a),(a),return)
     7.1 --- a/src/joystick/SDL_gamecontroller.c	Thu Nov 10 12:07:34 2016 -0500
     7.2 +++ b/src/joystick/SDL_gamecontroller.c	Thu Nov 10 17:19:34 2016 -0800
     7.3 @@ -1107,6 +1107,33 @@
     7.4      return 0;
     7.5  }
     7.6  
     7.7 +const char *
     7.8 +SDL_GameControllerName(SDL_GameController * gamecontroller)
     7.9 +{
    7.10 +    if (!gamecontroller)
    7.11 +        return NULL;
    7.12 +
    7.13 +    return gamecontroller->mapping.name;
    7.14 +}
    7.15 +
    7.16 +Uint16
    7.17 +SDL_GameControllerGetVendor(SDL_GameController * gamecontroller)
    7.18 +{
    7.19 +    return SDL_JoystickGetVendor(SDL_GameControllerGetJoystick(gamecontroller));
    7.20 +}
    7.21 +
    7.22 +Uint16
    7.23 +SDL_GameControllerGetProduct(SDL_GameController * gamecontroller)
    7.24 +{
    7.25 +    return SDL_JoystickGetProduct(SDL_GameControllerGetJoystick(gamecontroller));
    7.26 +}
    7.27 +
    7.28 +Uint16
    7.29 +SDL_GameControllerGetProductVersion(SDL_GameController * gamecontroller)
    7.30 +{
    7.31 +    return SDL_JoystickGetProductVersion(SDL_GameControllerGetJoystick(gamecontroller));
    7.32 +}
    7.33 +
    7.34  /*
    7.35   * Return if the joystick in question is currently attached to the system,
    7.36   *  \return 0 if not plugged in, 1 if still present.
    7.37 @@ -1120,17 +1147,6 @@
    7.38      return SDL_JoystickGetAttached(gamecontroller->joystick);
    7.39  }
    7.40  
    7.41 -
    7.42 -const char *
    7.43 -SDL_GameControllerName(SDL_GameController * gamecontroller)
    7.44 -{
    7.45 -    if (!gamecontroller)
    7.46 -        return NULL;
    7.47 -
    7.48 -    return (gamecontroller->mapping.name);
    7.49 -}
    7.50 -
    7.51 -
    7.52  /*
    7.53   * Get the joystick for this controller
    7.54   */
     8.1 --- a/src/joystick/SDL_gamecontrollerdb.h	Thu Nov 10 12:07:34 2016 -0500
     8.2 +++ b/src/joystick/SDL_gamecontrollerdb.h	Thu Nov 10 17:19:34 2016 -0800
     8.3 @@ -35,33 +35,33 @@
     8.4      "xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
     8.5  #endif
     8.6  #if SDL_JOYSTICK_DINPUT
     8.7 -    "10280900000000000000504944564944,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,",
     8.8 -    "341a3608000000000000504944564944,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
     8.9 -    "e8206058000000000000504944564944,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,",
    8.10 -    "ffff0000000000000000504944564944,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
    8.11 -    "6d0416c2000000000000504944564944,Generic DirectInput Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
    8.12 -	"6d0418c2000000000000504944564944,Logitech F510 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
    8.13 -	"6d0419c2000000000000504944564944,Logitech F710 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */
    8.14 +    "03000000102800000900000000000000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,",
    8.15 +    "03000000341a00003608000000000000,Afterglow PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
    8.16 +    "03000000e82000006058000000000000,Cideko AK08b,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,",
    8.17 +    "03000000ffff00000000000000000000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
    8.18 +    "030000006d04000016c2000000000000,Generic DirectInput Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
    8.19 +    "030000006d04000018c2000000000000,Logitech F510 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
    8.20 +    "030000006d04000019c2000000000000,Logitech F710 Gamepad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */
    8.21      "4d6963726f736f66742050432d6a6f79,OUYA Controller,a:b0,b:b3,dpdown:b9,dpleft:b10,dpright:b11,dpup:b8,guide:b14,leftshoulder:b4,leftstick:b6,lefttrigger:b12,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:b13,rightx:a5,righty:a4,x:b1,y:b2,",
    8.22 -    "88880803000000000000504944564944,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b9,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b0,y:b3,",
    8.23 -    "4c056802000000000000504944564944,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,",
    8.24 -    "25090500000000000000504944564944,PS3 DualShock,a:b2,b:b1,back:b9,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b0,y:b3,",
    8.25 -    "4c05c405000000000000504944564944,PS4 Controller,a:b1,b:b2,back:b8,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,",
    8.26 +    "03000000888800000803000000000000,PS3 Controller,a:b2,b:b1,back:b8,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b9,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:b7,rightx:a3,righty:a4,start:b11,x:b0,y:b3,",
    8.27 +    "030000004c0500006802000000000000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,",
    8.28 +    "03000000250900000500000000000000,PS3 DualShock,a:b2,b:b1,back:b9,dpdown:h0.8,dpleft:h0.4,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b6,leftstick:b10,lefttrigger:b4,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b11,righttrigger:b5,rightx:a2,righty:a3,start:b8,x:b0,y:b3,",
    8.29 +    "030000004c050000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,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,",
    8.30  #endif
    8.31  #if defined(__MACOSX__)
    8.32 -    "10280000000000000900000000000000,8Bitdo SFC30 GamePad Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,",
    8.33 -    "830500000000000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
    8.34 +    "03000000102800000900000000000000,8Bitdo SFC30 GamePad Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,",
    8.35 +    "030000008305000031b0000000000000,Cideko AK08b,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
    8.36      "0500000047532047616d657061640000,GameStop Gamepad,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
    8.37 -    "6d0400000000000016c2000000000000,Logitech F310 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */
    8.38 -    "6d0400000000000018c2000000000000,Logitech F510 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
    8.39 -    "6d040000000000001fc2000000000000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,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,",
    8.40 -    "6d0400000000000019c2000000000000,Logitech Wireless Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* This includes F710 in DInput mode and the "Logitech Cordless RumblePad 2", at the very least. */
    8.41 -    "4c050000000000006802000000000000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,",
    8.42 -    "4c05000000000000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,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,",
    8.43 -    "351200000000000021ab000000000000,SFC30 Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,",
    8.44 -    "11010000000000002014000000000000,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,",
    8.45 -    "11010000000000001714000000000000,SteelSeries Stratus XL,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,",
    8.46 -    "5e040000000000008e02000000000000,X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,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,",
    8.47 +    "030000006d04000016c2000000000000,Logitech F310 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* Guide button doesn't seem to be sent in DInput mode. */
    8.48 +    "030000006d04000018c2000000000000,Logitech F510 Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
    8.49 +    "030000006d0400001fc2000000000000,Logitech F710 Gamepad (XInput),a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,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,",
    8.50 +    "030000006d04000019c2000000000000,Logitech Wireless Gamepad (DInput),a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,", /* This includes F710 in DInput mode and the "Logitech Cordless RumblePad 2", at the very least. */
    8.51 +    "030000004c0500006802000000000000,PS3 Controller,a:b14,b:b13,back:b0,dpdown:b6,dpleft:b7,dpright:b5,dpup:b4,guide:b16,leftshoulder:b10,leftstick:b1,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b11,rightstick:b2,righttrigger:b9,rightx:a2,righty:a3,start:b3,x:b15,y:b12,",
    8.52 +    "030000004c050000c405000000000000,PS4 Controller,a:b1,b:b2,back:b8,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,",
    8.53 +    "030000003512000021ab000000000000,SFC30 Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,",
    8.54 +    "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,",
    8.55 +    "03000000110100001714000000000000,SteelSeries Stratus XL,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,",
    8.56 +    "030000005e0400008e02000000000000,X360 Controller,a:b0,b:b1,back:b9,dpdown:b12,dpleft:b13,dpright:b14,dpup:b11,guide:b10,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,",
    8.57  #endif
    8.58  #if defined(__LINUX__)
    8.59      "05000000102800000900000000010000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,",
    8.60 @@ -96,7 +96,6 @@
    8.61      "03000000321500000009000011010000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,",
    8.62      "050000003215000000090000163a0000,Razer Serval,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a4,rightx:a2,righty:a3,start:b7,x:b2,y:b3,",
    8.63      "03000000de280000fc11000001000000,Steam Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
    8.64 -    "03000000de280000ff11000001000000,Valve Streaming Gamepad,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
    8.65      "xinput,XInput Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
    8.66      "050000005e040000e002000003090000,Xbox One Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b8,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b9,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
    8.67      "030000005e040000d102000001010000,Xbox One Wireless Controller,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
     9.1 --- a/src/joystick/SDL_joystick.c	Thu Nov 10 12:07:34 2016 -0500
     9.2 +++ b/src/joystick/SDL_joystick.c	Thu Nov 10 17:19:34 2016 -0800
     9.3 @@ -816,6 +816,41 @@
     9.4  #endif /* SDL_EVENTS_DISABLED */
     9.5  }
     9.6  
     9.7 +static void GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version)
     9.8 +{
     9.9 +    Uint16 *guid16 = (Uint16 *)guid.data;
    9.10 +
    9.11 +    /* If the GUID fits the form of BUS 0000 VENDOR 0000 PRODUCT 0000, return the data */
    9.12 +    if (/* guid16[0] is device bus type */
    9.13 +        guid16[1] == 0x00 &&
    9.14 +        /* guid16[2] is vendor ID */
    9.15 +        guid16[3] == 0x00 &&
    9.16 +        /* guid16[4] is product ID */
    9.17 +        guid16[5] == 0x00
    9.18 +        /* guid16[6] is product version */
    9.19 +    ) {
    9.20 +        if (vendor) {
    9.21 +            *vendor = guid16[2];
    9.22 +        }
    9.23 +        if (product) {
    9.24 +            *product = guid16[4];
    9.25 +        }
    9.26 +        if (version) {
    9.27 +            *version = guid16[6];
    9.28 +        }
    9.29 +    } else {
    9.30 +        if (vendor) {
    9.31 +            *vendor = 0;
    9.32 +        }
    9.33 +        if (product) {
    9.34 +            *product = 0;
    9.35 +        }
    9.36 +        if (version) {
    9.37 +            *version = 0;
    9.38 +        }
    9.39 +    }
    9.40 +}
    9.41 +
    9.42  /* return the guid for this index */
    9.43  SDL_JoystickGUID SDL_JoystickGetDeviceGUID(int device_index)
    9.44  {
    9.45 @@ -828,6 +863,33 @@
    9.46      return SDL_SYS_JoystickGetDeviceGUID(device_index);
    9.47  }
    9.48  
    9.49 +Uint16 SDL_JoystickGetDeviceVendor(int device_index)
    9.50 +{
    9.51 +    Uint16 vendor;
    9.52 +    SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index);
    9.53 +
    9.54 +    GetJoystickGUIDInfo(guid, &vendor, NULL, NULL);
    9.55 +    return vendor;
    9.56 +}
    9.57 +
    9.58 +Uint16 SDL_JoystickGetDeviceProduct(int device_index)
    9.59 +{
    9.60 +    Uint16 product;
    9.61 +    SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index);
    9.62 +
    9.63 +    GetJoystickGUIDInfo(guid, NULL, &product, NULL);
    9.64 +    return product;
    9.65 +}
    9.66 +
    9.67 +Uint16 SDL_JoystickGetDeviceProductVersion(int device_index)
    9.68 +{
    9.69 +    Uint16 version;
    9.70 +    SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index);
    9.71 +
    9.72 +    GetJoystickGUIDInfo(guid, NULL, NULL, &version);
    9.73 +    return version;
    9.74 +}
    9.75 +
    9.76  /* return the guid for this opened device */
    9.77  SDL_JoystickGUID SDL_JoystickGetGUID(SDL_Joystick * joystick)
    9.78  {
    9.79 @@ -839,6 +901,33 @@
    9.80      return SDL_SYS_JoystickGetGUID(joystick);
    9.81  }
    9.82  
    9.83 +Uint16 SDL_JoystickGetVendor(SDL_Joystick * joystick)
    9.84 +{
    9.85 +    Uint16 vendor;
    9.86 +    SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick);
    9.87 +
    9.88 +    GetJoystickGUIDInfo(guid, &vendor, NULL, NULL);
    9.89 +    return vendor;
    9.90 +}
    9.91 +
    9.92 +Uint16 SDL_JoystickGetProduct(SDL_Joystick * joystick)
    9.93 +{
    9.94 +    Uint16 product;
    9.95 +    SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick);
    9.96 +
    9.97 +    GetJoystickGUIDInfo(guid, NULL, &product, NULL);
    9.98 +    return product;
    9.99 +}
   9.100 +
   9.101 +Uint16 SDL_JoystickGetProductVersion(SDL_Joystick * joystick)
   9.102 +{
   9.103 +    Uint16 version;
   9.104 +    SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick);
   9.105 +
   9.106 +    GetJoystickGUIDInfo(guid, NULL, NULL, &version);
   9.107 +    return version;
   9.108 +}
   9.109 +
   9.110  /* convert the guid to a printable string */
   9.111  void SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID)
   9.112  {
    10.1 --- a/src/joystick/darwin/SDL_sysjoystick.c	Thu Nov 10 12:07:34 2016 -0500
    10.2 +++ b/src/joystick/darwin/SDL_sysjoystick.c	Thu Nov 10 17:19:34 2016 -0800
    10.3 @@ -321,9 +321,14 @@
    10.4  static SDL_bool
    10.5  GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice)
    10.6  {
    10.7 -    Uint32 *guid32 = NULL;
    10.8 +    const Uint16 BUS_USB = 0x03;
    10.9 +    const Uint16 BUS_BLUETOOTH = 0x05;
   10.10 +    Sint32 vendor = 0;
   10.11 +    Sint32 product = 0;
   10.12 +    Sint32 version = 0;
   10.13      CFTypeRef refCF = NULL;
   10.14      CFArrayRef array = NULL;
   10.15 +    Uint16 *guid16 = (Uint16 *)pDevice->guid->data;
   10.16  
   10.17      /* get usage page and usage */
   10.18      refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDPrimaryUsagePageKey));
   10.19 @@ -359,22 +364,32 @@
   10.20  
   10.21      refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDVendorIDKey));
   10.22      if (refCF) {
   10.23 -        CFNumberGetValue(refCF, kCFNumberSInt32Type, &pDevice->guid.data[0]);
   10.24 +        CFNumberGetValue(refCF, kCFNumberSInt32Type, &vendor);
   10.25      }
   10.26  
   10.27      refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDProductIDKey));
   10.28      if (refCF) {
   10.29 -        CFNumberGetValue(refCF, kCFNumberSInt32Type, &pDevice->guid.data[8]);
   10.30 +        CFNumberGetValue(refCF, kCFNumberSInt32Type, &product);
   10.31      }
   10.32  
   10.33 -    /* Check to make sure we have a vendor and product ID
   10.34 -       If we don't, use the same algorithm as the Linux code for Bluetooth devices */
   10.35 -    guid32 = (Uint32*)pDevice->guid.data;
   10.36 -    if (!guid32[0] && !guid32[1]) {
   10.37 -        /* If we don't have a vendor and product ID this is probably a Bluetooth device */
   10.38 -        const Uint16 BUS_BLUETOOTH = 0x05;
   10.39 -        Uint16 *guid16 = (Uint16 *)guid32;
   10.40 -        *guid16++ = BUS_BLUETOOTH;
   10.41 +    refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDVersionNumberKey));
   10.42 +    if (refCF) {
   10.43 +        CFNumberGetValue(refCF, kCFNumberSInt32Type, &version);
   10.44 +    }
   10.45 +
   10.46 +    SDL_memset(pDevice->guid->data, 0, sizeof(pDevice->guid->data));
   10.47 +
   10.48 +    if (vendor && product) {
   10.49 +        *guid16++ = SDL_SwapLE16(BUS_USB);
   10.50 +        *guid16++ = 0;
   10.51 +        *guid16++ = SDL_SwapLE16((Uint16)vendor);
   10.52 +        *guid16++ = 0;
   10.53 +        *guid16++ = SDL_SwapLE16((Uint16)product);
   10.54 +        *guid16++ = 0;
   10.55 +        *guid16++ = SDL_SwapLE16((Uint16)version);
   10.56 +        *guid16++ = 0;
   10.57 +    } else {
   10.58 +        *guid16++ = SDL_SwapLE16(BUS_BLUETOOTH);
   10.59          *guid16++ = 0;
   10.60          SDL_strlcpy((char*)guid16, pDevice->product, sizeof(pDevice->guid.data) - 4);
   10.61      }
    11.1 --- a/src/joystick/darwin/SDL_sysjoystick_c.h	Thu Nov 10 12:07:34 2016 -0500
    11.2 +++ b/src/joystick/darwin/SDL_sysjoystick_c.h	Thu Nov 10 17:19:34 2016 -0800
    11.3 @@ -68,5 +68,6 @@
    11.4  };
    11.5  typedef struct joystick_hwdata recDevice;
    11.6  
    11.7 +#endif /* SDL_JOYSTICK_IOKIT_H */
    11.8  
    11.9 -#endif /* SDL_JOYSTICK_IOKIT_H */
   11.10 +/* vi: set ts=4 sw=4 expandtab: */
    12.1 --- a/src/joystick/linux/SDL_sysjoystick.c	Thu Nov 10 12:07:34 2016 -0500
    12.2 +++ b/src/joystick/linux/SDL_sysjoystick.c	Thu Nov 10 17:19:34 2016 -0800
    12.3 @@ -81,7 +81,7 @@
    12.4  IsJoystick(int fd, char *namebuf, const size_t namebuflen, SDL_JoystickGUID *guid)
    12.5  {
    12.6      struct input_id inpid;
    12.7 -    Uint16 *guid16 = (Uint16 *) ((char *) &guid->data);
    12.8 +    Uint16 *guid16 = (Uint16 *)guid->data;
    12.9  
   12.10  #if !SDL_USE_LIBUDEV
   12.11      /* When udev is enabled we only get joystick devices here, so there's no need to test them */
   12.12 @@ -110,23 +110,23 @@
   12.13      }
   12.14  
   12.15  #ifdef DEBUG_JOYSTICK
   12.16 -    printf("Joystick: %s, bustype = %d, vendor = 0x%x, product = 0x%x, version = %d\n", namebuf, inpid.bustype, inpid.vendor, inpid.product, inpid.version);
   12.17 +    printf("Joystick: %s, bustype = %d, vendor = 0x%.4x, product = 0x%.4x, version = %d\n", namebuf, inpid.bustype, inpid.vendor, inpid.product, inpid.version);
   12.18  #endif
   12.19  
   12.20      SDL_memset(guid->data, 0, sizeof(guid->data));
   12.21  
   12.22      /* We only need 16 bits for each of these; space them out to fill 128. */
   12.23      /* Byteswap so devices get same GUID on little/big endian platforms. */
   12.24 -    *(guid16++) = SDL_SwapLE16(inpid.bustype);
   12.25 -    *(guid16++) = 0;
   12.26 +    *guid16++ = SDL_SwapLE16(inpid.bustype);
   12.27 +    *guid16++ = 0;
   12.28  
   12.29 -    if (inpid.vendor && inpid.product && inpid.version) {
   12.30 -        *(guid16++) = SDL_SwapLE16(inpid.vendor);
   12.31 -        *(guid16++) = 0;
   12.32 -        *(guid16++) = SDL_SwapLE16(inpid.product);
   12.33 -        *(guid16++) = 0;
   12.34 -        *(guid16++) = SDL_SwapLE16(inpid.version);
   12.35 -        *(guid16++) = 0;
   12.36 +    if (inpid.vendor && inpid.product) {
   12.37 +        *guid16++ = SDL_SwapLE16(inpid.vendor);
   12.38 +        *guid16++ = 0;
   12.39 +        *guid16++ = SDL_SwapLE16(inpid.product);
   12.40 +        *guid16++ = 0;
   12.41 +        *guid16++ = SDL_SwapLE16(inpid.version);
   12.42 +        *guid16++ = 0;
   12.43      } else {
   12.44          SDL_strlcpy((char*)guid16, namebuf, sizeof(guid->data) - 4);
   12.45      }
    13.1 --- a/src/joystick/windows/SDL_dinputjoystick.c	Thu Nov 10 12:07:34 2016 -0500
    13.2 +++ b/src/joystick/windows/SDL_dinputjoystick.c	Thu Nov 10 17:19:34 2016 -0800
    13.3 @@ -350,9 +350,12 @@
    13.4  static BOOL CALLBACK
    13.5  EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
    13.6  {
    13.7 +    const Uint16 BUS_USB = 0x03;
    13.8 +    const Uint16 BUS_BLUETOOTH = 0x05;
    13.9      JoyStick_DeviceData *pNewJoystick;
   13.10      JoyStick_DeviceData *pPrevJoystick = NULL;
   13.11      const DWORD devtype = (pdidInstance->dwDevType & 0xFF);
   13.12 +    Uint16 *guid16;
   13.13  
   13.14      if (devtype == DI8DEVTYPE_SUPPLEMENTAL) {
   13.15          return DIENUM_CONTINUE;  /* Ignore touchpads, etc. */
   13.16 @@ -397,7 +400,24 @@
   13.17      SDL_memcpy(&(pNewJoystick->dxdevice), pdidInstance,
   13.18          sizeof(DIDEVICEINSTANCE));
   13.19  
   13.20 -    SDL_memcpy(&pNewJoystick->guid, &pdidInstance->guidProduct, sizeof(pNewJoystick->guid));
   13.21 +    SDL_memset(pNewJoystick->guid.data, 0, sizeof(pNewJoystick->guid.data));
   13.22 +
   13.23 +    guid16 = (Uint16 *)pNewJoystick->guid.data;
   13.24 +    if (SDL_memcmp(&pdidInstance->guidProduct.Data4[2], "VIDPID", 6) == 0) {
   13.25 +        *guid16++ = SDL_SwapLE16(BUS_USB);
   13.26 +        *guid16++ = 0;
   13.27 +        *guid16++ = SDL_SwapLE16((Uint16)LOWORD(pdidInstance->guidProduct.Data1)); /* vendor */
   13.28 +        *guid16++ = 0;
   13.29 +        *guid16++ = SDL_SwapLE16((Uint16)HIWORD(pdidInstance->guidProduct.Data1)); /* product */
   13.30 +        *guid16++ = 0;
   13.31 +        *guid16++ = 0; /* version */
   13.32 +        *guid16++ = 0;
   13.33 +    } else {
   13.34 +        *guid16++ = SDL_SwapLE16(BUS_BLUETOOTH);
   13.35 +        *guid16++ = 0;
   13.36 +        SDL_strlcpy((char*)guid16, pNewJoystick->joystickname, sizeof(pNewJoystick->guid.data) - 4);
   13.37 +    }
   13.38 +
   13.39      SDL_SYS_AddJoystickDevice(pNewJoystick);
   13.40  
   13.41      return DIENUM_CONTINUE; /* get next device, please */