mirror of https://github.com/encounter/SDL.git
Standardized the format of the SDL joystick GUID and added functions to retrieve the USB VID/PID from a joystick and game controller.
This commit is contained in:
parent
2898ada338
commit
ac74e16cde
|
@ -2691,7 +2691,7 @@ orig_CFLAGS="$CFLAGS"
|
|||
SDL_MAJOR_VERSION=2
|
||||
SDL_MINOR_VERSION=0
|
||||
SDL_MICRO_VERSION=5
|
||||
SDL_INTERFACE_AGE=1
|
||||
SDL_INTERFACE_AGE=0
|
||||
SDL_BINARY_AGE=5
|
||||
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
|
||||
|
||||
|
@ -5977,7 +5977,10 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
|
|||
x86_64-*linux*)
|
||||
LD="${LD-ld} -m elf_x86_64"
|
||||
;;
|
||||
ppc*-*linux*|powerpc*-*linux*)
|
||||
powerpc64le-*linux*)
|
||||
LD="${LD-ld} -m elf64lppc"
|
||||
;;
|
||||
powerpc64-*linux*)
|
||||
LD="${LD-ld} -m elf64ppc"
|
||||
;;
|
||||
s390*-*linux*|s390*-*tpf*)
|
||||
|
|
|
@ -21,7 +21,7 @@ dnl Set various version strings - taken gratefully from the GTk sources
|
|||
SDL_MAJOR_VERSION=2
|
||||
SDL_MINOR_VERSION=0
|
||||
SDL_MICRO_VERSION=5
|
||||
SDL_INTERFACE_AGE=1
|
||||
SDL_INTERFACE_AGE=0
|
||||
SDL_BINARY_AGE=5
|
||||
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
|
||||
|
||||
|
|
|
@ -87,8 +87,8 @@ typedef struct SDL_GameControllerButtonBind
|
|||
* To count the number of game controllers in the system for the following:
|
||||
* int nJoysticks = SDL_NumJoysticks();
|
||||
* int nGameControllers = 0;
|
||||
* for ( int i = 0; i < nJoysticks; i++ ) {
|
||||
* if ( SDL_IsGameController(i) ) {
|
||||
* for (int i = 0; i < nJoysticks; i++) {
|
||||
* if (SDL_IsGameController(i)) {
|
||||
* nGameControllers++;
|
||||
* }
|
||||
* }
|
||||
|
@ -105,7 +105,7 @@ typedef struct SDL_GameControllerButtonBind
|
|||
* Buttons can be used as a controller axis and vice versa.
|
||||
*
|
||||
* This string shows an example of a valid mapping for a controller
|
||||
* "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",
|
||||
* "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",
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -117,7 +117,7 @@ typedef struct SDL_GameControllerButtonBind
|
|||
*
|
||||
* \return number of mappings added, -1 on error
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW( SDL_RWops * rw, int freerw );
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw);
|
||||
|
||||
/**
|
||||
* Load a set of mappings from a file, filtered by the current SDL_GetPlatform()
|
||||
|
@ -131,28 +131,27 @@ extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW( SDL_RWops * rw,
|
|||
*
|
||||
* \return 1 if mapping is added, 0 if updated, -1 on error
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping( const char* mappingString );
|
||||
extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char* mappingString);
|
||||
|
||||
/**
|
||||
* Get a mapping string for a GUID
|
||||
*
|
||||
* \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available
|
||||
*/
|
||||
extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID( SDL_JoystickGUID guid );
|
||||
extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid);
|
||||
|
||||
/**
|
||||
* Get a mapping string for an open GameController
|
||||
*
|
||||
* \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available
|
||||
*/
|
||||
extern DECLSPEC char * SDLCALL SDL_GameControllerMapping( SDL_GameController * gamecontroller );
|
||||
extern DECLSPEC char * SDLCALL SDL_GameControllerMapping(SDL_GameController * gamecontroller);
|
||||
|
||||
/**
|
||||
* Is the joystick on this index supported by the game controller interface?
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index);
|
||||
|
||||
|
||||
/**
|
||||
* Get the implementation dependent name of a game controller.
|
||||
* This can be called before any controllers are opened.
|
||||
|
@ -181,6 +180,24 @@ extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL
|
|||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller);
|
||||
|
||||
/**
|
||||
* Get the USB vendor ID of an opened controller, if available.
|
||||
* If the vendor ID isn't available this function returns 0.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController * gamecontroller);
|
||||
|
||||
/**
|
||||
* Get the USB product ID of an opened controller, if available.
|
||||
* If the product ID isn't available this function returns 0.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController * gamecontroller);
|
||||
|
||||
/**
|
||||
* Get the product version of an opened controller, if available.
|
||||
* If the product version isn't available this function returns 0.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController * gamecontroller);
|
||||
|
||||
/**
|
||||
* Returns SDL_TRUE if the controller has been opened and currently connected,
|
||||
* or SDL_FALSE if it has not.
|
||||
|
|
|
@ -95,6 +95,33 @@ extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
|
|||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index);
|
||||
|
||||
/**
|
||||
* Return the GUID for the joystick at this index
|
||||
* This can be called before any joysticks are opened.
|
||||
*/
|
||||
extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index);
|
||||
|
||||
/**
|
||||
* Get the USB vendor ID of a joystick, if available.
|
||||
* This can be called before any joysticks are opened.
|
||||
* If the vendor ID isn't available this function returns 0.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceVendor(int device_index);
|
||||
|
||||
/**
|
||||
* Get the USB product ID of a joystick, if available.
|
||||
* This can be called before any joysticks are opened.
|
||||
* If the product ID isn't available this function returns 0.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProduct(int device_index);
|
||||
|
||||
/**
|
||||
* Get the product version of a joystick, if available.
|
||||
* This can be called before any joysticks are opened.
|
||||
* If the product version isn't available this function returns 0.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetDeviceProductVersion(int device_index);
|
||||
|
||||
/**
|
||||
* Open a joystick for use.
|
||||
* The index passed as an argument refers to the N'th joystick on the system.
|
||||
|
@ -117,16 +144,29 @@ extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromInstanceID(SDL_JoystickID
|
|||
*/
|
||||
extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick * joystick);
|
||||
|
||||
/**
|
||||
* Return the GUID for the joystick at this index
|
||||
*/
|
||||
extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index);
|
||||
|
||||
/**
|
||||
* Return the GUID for this opened joystick
|
||||
*/
|
||||
extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick * joystick);
|
||||
|
||||
/**
|
||||
* Get the USB vendor ID of an opened joystick, if available.
|
||||
* If the vendor ID isn't available this function returns 0.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetVendor(SDL_Joystick * joystick);
|
||||
|
||||
/**
|
||||
* Get the USB product ID of an opened joystick, if available.
|
||||
* If the product ID isn't available this function returns 0.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProduct(SDL_Joystick * joystick);
|
||||
|
||||
/**
|
||||
* Get the product version of an opened joystick, if available.
|
||||
* If the product version isn't available this function returns 0.
|
||||
*/
|
||||
extern DECLSPEC Uint16 SDLCALL SDL_JoystickGetProductVersion(SDL_Joystick * joystick);
|
||||
|
||||
/**
|
||||
* Return a string representation for this guid. pszGUID must point to at least 33 bytes
|
||||
* (32 for the string plus a NULL terminator).
|
||||
|
@ -134,7 +174,7 @@ extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick * joys
|
|||
extern DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID);
|
||||
|
||||
/**
|
||||
* convert a string into a joystick formatted guid
|
||||
* Convert a string into a joystick guid
|
||||
*/
|
||||
extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID);
|
||||
|
||||
|
|
|
@ -612,3 +612,12 @@
|
|||
#define SDL_CreateRGBSurfaceWithFormat SDL_CreateRGBSurfaceWithFormat_REAL
|
||||
#define SDL_CreateRGBSurfaceWithFormatFrom SDL_CreateRGBSurfaceWithFormatFrom_REAL
|
||||
#define SDL_GetHintBoolean SDL_GetHintBoolean_REAL
|
||||
#define SDL_JoystickGetDeviceVendor SDL_JoystickGetDeviceVendor_REAL
|
||||
#define SDL_JoystickGetDeviceProduct SDL_JoystickGetDeviceProduct_REAL
|
||||
#define SDL_JoystickGetDeviceProductVersion SDL_JoystickGetDeviceProductVersion_REAL
|
||||
#define SDL_JoystickGetVendor SDL_JoystickGetVendor_REAL
|
||||
#define SDL_JoystickGetProduct SDL_JoystickGetProduct_REAL
|
||||
#define SDL_JoystickGetProductVersion SDL_JoystickGetProductVersion_REAL
|
||||
#define SDL_GameControllerGetVendor SDL_GameControllerGetVendor_REAL
|
||||
#define SDL_GameControllerGetProduct SDL_GameControllerGetProduct_REAL
|
||||
#define SDL_GameControllerGetProductVersion SDL_GameControllerGetProductVersion_REAL
|
||||
|
|
|
@ -644,3 +644,12 @@ SDL_DYNAPI_PROC(void,SDL_SetWindowResizable,(SDL_Window *a, SDL_bool b),(a,b),)
|
|||
SDL_DYNAPI_PROC(SDL_Surface*,SDL_CreateRGBSurfaceWithFormat,(Uint32 a, int b, int c, int d, Uint32 e),(a,b,c,d,e),return)
|
||||
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)
|
||||
SDL_DYNAPI_PROC(SDL_bool,SDL_GetHintBoolean,(const char *a, SDL_bool b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetDeviceVendor,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetDeviceProduct,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetDeviceProductVersion,(int a),(a),return)
|
||||
SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetVendor,(SDL_Joystick *a),(a),return)
|
||||
SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetProduct,(SDL_Joystick *a),(a),return)
|
||||
SDL_DYNAPI_PROC(Uint16,SDL_JoystickGetProductVersion,(SDL_Joystick *a),(a),return)
|
||||
SDL_DYNAPI_PROC(Uint16,SDL_GameControllerGetVendor,(SDL_GameController *a),(a),return)
|
||||
SDL_DYNAPI_PROC(Uint16,SDL_GameControllerGetProduct,(SDL_GameController *a),(a),return)
|
||||
SDL_DYNAPI_PROC(Uint16,SDL_GameControllerGetProductVersion,(SDL_GameController *a),(a),return)
|
||||
|
|
|
@ -1107,6 +1107,33 @@ SDL_GameControllerGetButton(SDL_GameController * gamecontroller, SDL_GameControl
|
|||
return 0;
|
||||
}
|
||||
|
||||
const char *
|
||||
SDL_GameControllerName(SDL_GameController * gamecontroller)
|
||||
{
|
||||
if (!gamecontroller)
|
||||
return NULL;
|
||||
|
||||
return gamecontroller->mapping.name;
|
||||
}
|
||||
|
||||
Uint16
|
||||
SDL_GameControllerGetVendor(SDL_GameController * gamecontroller)
|
||||
{
|
||||
return SDL_JoystickGetVendor(SDL_GameControllerGetJoystick(gamecontroller));
|
||||
}
|
||||
|
||||
Uint16
|
||||
SDL_GameControllerGetProduct(SDL_GameController * gamecontroller)
|
||||
{
|
||||
return SDL_JoystickGetProduct(SDL_GameControllerGetJoystick(gamecontroller));
|
||||
}
|
||||
|
||||
Uint16
|
||||
SDL_GameControllerGetProductVersion(SDL_GameController * gamecontroller)
|
||||
{
|
||||
return SDL_JoystickGetProductVersion(SDL_GameControllerGetJoystick(gamecontroller));
|
||||
}
|
||||
|
||||
/*
|
||||
* Return if the joystick in question is currently attached to the system,
|
||||
* \return 0 if not plugged in, 1 if still present.
|
||||
|
@ -1120,17 +1147,6 @@ SDL_GameControllerGetAttached(SDL_GameController * gamecontroller)
|
|||
return SDL_JoystickGetAttached(gamecontroller->joystick);
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
SDL_GameControllerName(SDL_GameController * gamecontroller)
|
||||
{
|
||||
if (!gamecontroller)
|
||||
return NULL;
|
||||
|
||||
return (gamecontroller->mapping.name);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the joystick for this controller
|
||||
*/
|
||||
|
|
|
@ -35,33 +35,33 @@ static const char *s_ControllerMappings [] =
|
|||
"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,",
|
||||
#endif
|
||||
#if SDL_JOYSTICK_DINPUT
|
||||
"10280900000000000000504944564944,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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. */
|
||||
"03000000102800000900000000000000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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. */
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
#endif
|
||||
#if defined(__MACOSX__)
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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. */
|
||||
"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,",
|
||||
"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,",
|
||||
"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. */
|
||||
"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,",
|
||||
"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,",
|
||||
"351200000000000021ab000000000000,SFC30 Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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. */
|
||||
"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,",
|
||||
"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,",
|
||||
"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. */
|
||||
"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,",
|
||||
"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,",
|
||||
"030000003512000021ab000000000000,SFC30 Joystick,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
#endif
|
||||
#if defined(__LINUX__)
|
||||
"05000000102800000900000000010000,8Bitdo SFC30 GamePad,a:b1,b:b0,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b4,y:b3,",
|
||||
|
@ -96,7 +96,6 @@ static const char *s_ControllerMappings [] =
|
|||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
"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,",
|
||||
|
|
|
@ -816,6 +816,41 @@ SDL_JoystickEventState(int state)
|
|||
#endif /* SDL_EVENTS_DISABLED */
|
||||
}
|
||||
|
||||
static void GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version)
|
||||
{
|
||||
Uint16 *guid16 = (Uint16 *)guid.data;
|
||||
|
||||
/* If the GUID fits the form of BUS 0000 VENDOR 0000 PRODUCT 0000, return the data */
|
||||
if (/* guid16[0] is device bus type */
|
||||
guid16[1] == 0x00 &&
|
||||
/* guid16[2] is vendor ID */
|
||||
guid16[3] == 0x00 &&
|
||||
/* guid16[4] is product ID */
|
||||
guid16[5] == 0x00
|
||||
/* guid16[6] is product version */
|
||||
) {
|
||||
if (vendor) {
|
||||
*vendor = guid16[2];
|
||||
}
|
||||
if (product) {
|
||||
*product = guid16[4];
|
||||
}
|
||||
if (version) {
|
||||
*version = guid16[6];
|
||||
}
|
||||
} else {
|
||||
if (vendor) {
|
||||
*vendor = 0;
|
||||
}
|
||||
if (product) {
|
||||
*product = 0;
|
||||
}
|
||||
if (version) {
|
||||
*version = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* return the guid for this index */
|
||||
SDL_JoystickGUID SDL_JoystickGetDeviceGUID(int device_index)
|
||||
{
|
||||
|
@ -828,6 +863,33 @@ SDL_JoystickGUID SDL_JoystickGetDeviceGUID(int device_index)
|
|||
return SDL_SYS_JoystickGetDeviceGUID(device_index);
|
||||
}
|
||||
|
||||
Uint16 SDL_JoystickGetDeviceVendor(int device_index)
|
||||
{
|
||||
Uint16 vendor;
|
||||
SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index);
|
||||
|
||||
GetJoystickGUIDInfo(guid, &vendor, NULL, NULL);
|
||||
return vendor;
|
||||
}
|
||||
|
||||
Uint16 SDL_JoystickGetDeviceProduct(int device_index)
|
||||
{
|
||||
Uint16 product;
|
||||
SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index);
|
||||
|
||||
GetJoystickGUIDInfo(guid, NULL, &product, NULL);
|
||||
return product;
|
||||
}
|
||||
|
||||
Uint16 SDL_JoystickGetDeviceProductVersion(int device_index)
|
||||
{
|
||||
Uint16 version;
|
||||
SDL_JoystickGUID guid = SDL_JoystickGetDeviceGUID(device_index);
|
||||
|
||||
GetJoystickGUIDInfo(guid, NULL, NULL, &version);
|
||||
return version;
|
||||
}
|
||||
|
||||
/* return the guid for this opened device */
|
||||
SDL_JoystickGUID SDL_JoystickGetGUID(SDL_Joystick * joystick)
|
||||
{
|
||||
|
@ -839,6 +901,33 @@ SDL_JoystickGUID SDL_JoystickGetGUID(SDL_Joystick * joystick)
|
|||
return SDL_SYS_JoystickGetGUID(joystick);
|
||||
}
|
||||
|
||||
Uint16 SDL_JoystickGetVendor(SDL_Joystick * joystick)
|
||||
{
|
||||
Uint16 vendor;
|
||||
SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick);
|
||||
|
||||
GetJoystickGUIDInfo(guid, &vendor, NULL, NULL);
|
||||
return vendor;
|
||||
}
|
||||
|
||||
Uint16 SDL_JoystickGetProduct(SDL_Joystick * joystick)
|
||||
{
|
||||
Uint16 product;
|
||||
SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick);
|
||||
|
||||
GetJoystickGUIDInfo(guid, NULL, &product, NULL);
|
||||
return product;
|
||||
}
|
||||
|
||||
Uint16 SDL_JoystickGetProductVersion(SDL_Joystick * joystick)
|
||||
{
|
||||
Uint16 version;
|
||||
SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick);
|
||||
|
||||
GetJoystickGUIDInfo(guid, NULL, NULL, &version);
|
||||
return version;
|
||||
}
|
||||
|
||||
/* convert the guid to a printable string */
|
||||
void SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID)
|
||||
{
|
||||
|
|
|
@ -321,9 +321,14 @@ AddHIDElement(const void *value, void *parameter)
|
|||
static SDL_bool
|
||||
GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice)
|
||||
{
|
||||
Uint32 *guid32 = NULL;
|
||||
const Uint16 BUS_USB = 0x03;
|
||||
const Uint16 BUS_BLUETOOTH = 0x05;
|
||||
Sint32 vendor = 0;
|
||||
Sint32 product = 0;
|
||||
Sint32 version = 0;
|
||||
CFTypeRef refCF = NULL;
|
||||
CFArrayRef array = NULL;
|
||||
Uint16 *guid16 = (Uint16 *)pDevice->guid->data;
|
||||
|
||||
/* get usage page and usage */
|
||||
refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDPrimaryUsagePageKey));
|
||||
|
@ -359,22 +364,32 @@ GetDeviceInfo(IOHIDDeviceRef hidDevice, recDevice *pDevice)
|
|||
|
||||
refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDVendorIDKey));
|
||||
if (refCF) {
|
||||
CFNumberGetValue(refCF, kCFNumberSInt32Type, &pDevice->guid.data[0]);
|
||||
CFNumberGetValue(refCF, kCFNumberSInt32Type, &vendor);
|
||||
}
|
||||
|
||||
refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDProductIDKey));
|
||||
if (refCF) {
|
||||
CFNumberGetValue(refCF, kCFNumberSInt32Type, &pDevice->guid.data[8]);
|
||||
CFNumberGetValue(refCF, kCFNumberSInt32Type, &product);
|
||||
}
|
||||
|
||||
/* Check to make sure we have a vendor and product ID
|
||||
If we don't, use the same algorithm as the Linux code for Bluetooth devices */
|
||||
guid32 = (Uint32*)pDevice->guid.data;
|
||||
if (!guid32[0] && !guid32[1]) {
|
||||
/* If we don't have a vendor and product ID this is probably a Bluetooth device */
|
||||
const Uint16 BUS_BLUETOOTH = 0x05;
|
||||
Uint16 *guid16 = (Uint16 *)guid32;
|
||||
*guid16++ = BUS_BLUETOOTH;
|
||||
refCF = IOHIDDeviceGetProperty(hidDevice, CFSTR(kIOHIDVersionNumberKey));
|
||||
if (refCF) {
|
||||
CFNumberGetValue(refCF, kCFNumberSInt32Type, &version);
|
||||
}
|
||||
|
||||
SDL_memset(pDevice->guid->data, 0, sizeof(pDevice->guid->data));
|
||||
|
||||
if (vendor && product) {
|
||||
*guid16++ = SDL_SwapLE16(BUS_USB);
|
||||
*guid16++ = 0;
|
||||
*guid16++ = SDL_SwapLE16((Uint16)vendor);
|
||||
*guid16++ = 0;
|
||||
*guid16++ = SDL_SwapLE16((Uint16)product);
|
||||
*guid16++ = 0;
|
||||
*guid16++ = SDL_SwapLE16((Uint16)version);
|
||||
*guid16++ = 0;
|
||||
} else {
|
||||
*guid16++ = SDL_SwapLE16(BUS_BLUETOOTH);
|
||||
*guid16++ = 0;
|
||||
SDL_strlcpy((char*)guid16, pDevice->product, sizeof(pDevice->guid.data) - 4);
|
||||
}
|
||||
|
|
|
@ -68,5 +68,6 @@ struct joystick_hwdata
|
|||
};
|
||||
typedef struct joystick_hwdata recDevice;
|
||||
|
||||
|
||||
#endif /* SDL_JOYSTICK_IOKIT_H */
|
||||
|
||||
/* vi: set ts=4 sw=4 expandtab: */
|
||||
|
|
|
@ -81,7 +81,7 @@ static int
|
|||
IsJoystick(int fd, char *namebuf, const size_t namebuflen, SDL_JoystickGUID *guid)
|
||||
{
|
||||
struct input_id inpid;
|
||||
Uint16 *guid16 = (Uint16 *) ((char *) &guid->data);
|
||||
Uint16 *guid16 = (Uint16 *)guid->data;
|
||||
|
||||
#if !SDL_USE_LIBUDEV
|
||||
/* When udev is enabled we only get joystick devices here, so there's no need to test them */
|
||||
|
@ -110,23 +110,23 @@ IsJoystick(int fd, char *namebuf, const size_t namebuflen, SDL_JoystickGUID *gui
|
|||
}
|
||||
|
||||
#ifdef DEBUG_JOYSTICK
|
||||
printf("Joystick: %s, bustype = %d, vendor = 0x%x, product = 0x%x, version = %d\n", namebuf, inpid.bustype, inpid.vendor, inpid.product, inpid.version);
|
||||
printf("Joystick: %s, bustype = %d, vendor = 0x%.4x, product = 0x%.4x, version = %d\n", namebuf, inpid.bustype, inpid.vendor, inpid.product, inpid.version);
|
||||
#endif
|
||||
|
||||
SDL_memset(guid->data, 0, sizeof(guid->data));
|
||||
|
||||
/* We only need 16 bits for each of these; space them out to fill 128. */
|
||||
/* Byteswap so devices get same GUID on little/big endian platforms. */
|
||||
*(guid16++) = SDL_SwapLE16(inpid.bustype);
|
||||
*(guid16++) = 0;
|
||||
*guid16++ = SDL_SwapLE16(inpid.bustype);
|
||||
*guid16++ = 0;
|
||||
|
||||
if (inpid.vendor && inpid.product && inpid.version) {
|
||||
*(guid16++) = SDL_SwapLE16(inpid.vendor);
|
||||
*(guid16++) = 0;
|
||||
*(guid16++) = SDL_SwapLE16(inpid.product);
|
||||
*(guid16++) = 0;
|
||||
*(guid16++) = SDL_SwapLE16(inpid.version);
|
||||
*(guid16++) = 0;
|
||||
if (inpid.vendor && inpid.product) {
|
||||
*guid16++ = SDL_SwapLE16(inpid.vendor);
|
||||
*guid16++ = 0;
|
||||
*guid16++ = SDL_SwapLE16(inpid.product);
|
||||
*guid16++ = 0;
|
||||
*guid16++ = SDL_SwapLE16(inpid.version);
|
||||
*guid16++ = 0;
|
||||
} else {
|
||||
SDL_strlcpy((char*)guid16, namebuf, sizeof(guid->data) - 4);
|
||||
}
|
||||
|
|
|
@ -350,9 +350,12 @@ SDL_DINPUT_JoystickInit(void)
|
|||
static BOOL CALLBACK
|
||||
EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
|
||||
{
|
||||
const Uint16 BUS_USB = 0x03;
|
||||
const Uint16 BUS_BLUETOOTH = 0x05;
|
||||
JoyStick_DeviceData *pNewJoystick;
|
||||
JoyStick_DeviceData *pPrevJoystick = NULL;
|
||||
const DWORD devtype = (pdidInstance->dwDevType & 0xFF);
|
||||
Uint16 *guid16;
|
||||
|
||||
if (devtype == DI8DEVTYPE_SUPPLEMENTAL) {
|
||||
return DIENUM_CONTINUE; /* Ignore touchpads, etc. */
|
||||
|
@ -397,7 +400,24 @@ EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext)
|
|||
SDL_memcpy(&(pNewJoystick->dxdevice), pdidInstance,
|
||||
sizeof(DIDEVICEINSTANCE));
|
||||
|
||||
SDL_memcpy(&pNewJoystick->guid, &pdidInstance->guidProduct, sizeof(pNewJoystick->guid));
|
||||
SDL_memset(pNewJoystick->guid.data, 0, sizeof(pNewJoystick->guid.data));
|
||||
|
||||
guid16 = (Uint16 *)pNewJoystick->guid.data;
|
||||
if (SDL_memcmp(&pdidInstance->guidProduct.Data4[2], "VIDPID", 6) == 0) {
|
||||
*guid16++ = SDL_SwapLE16(BUS_USB);
|
||||
*guid16++ = 0;
|
||||
*guid16++ = SDL_SwapLE16((Uint16)LOWORD(pdidInstance->guidProduct.Data1)); /* vendor */
|
||||
*guid16++ = 0;
|
||||
*guid16++ = SDL_SwapLE16((Uint16)HIWORD(pdidInstance->guidProduct.Data1)); /* product */
|
||||
*guid16++ = 0;
|
||||
*guid16++ = 0; /* version */
|
||||
*guid16++ = 0;
|
||||
} else {
|
||||
*guid16++ = SDL_SwapLE16(BUS_BLUETOOTH);
|
||||
*guid16++ = 0;
|
||||
SDL_strlcpy((char*)guid16, pNewJoystick->joystickname, sizeof(pNewJoystick->guid.data) - 4);
|
||||
}
|
||||
|
||||
SDL_SYS_AddJoystickDevice(pNewJoystick);
|
||||
|
||||
return DIENUM_CONTINUE; /* get next device, please */
|
||||
|
|
Loading…
Reference in New Issue