SDL_GUIDToString() follows the SDL_GetStringRule

Also removed the distinction between SDL_GUID and SDL_JoystickGUID
This commit is contained in:
Sam Lantinga 2024-07-19 09:08:17 -07:00
parent 892df4bf4b
commit 61a7a0e579
44 changed files with 182 additions and 260 deletions

View file

@ -1353,12 +1353,7 @@ typedef SDL_GameControllerButton, SDL_GamepadButton;
@@ @@
@@ @@
- SDL_JoystickGetGUIDFromString - SDL_JoystickGetGUIDFromString
+ SDL_GetJoystickGUIDFromString + SDL_GUIDFromString
(...)
@@
@@
- SDL_JoystickGetGUIDString
+ SDL_GetJoystickGUIDString
(...) (...)
@@ @@
@@ @@
@ -3581,3 +3576,8 @@ typedef SDL_Colour, SDL_Color;
- SDL_AndroidSendMessage - SDL_AndroidSendMessage
+ SDL_SendAndroidMessage + SDL_SendAndroidMessage
(...) (...)
@@
typedef SDL_JoystickGUID, SDL_GUID;
@@
- SDL_JoystickGUID
+ SDL_GUID

View file

@ -860,8 +860,7 @@ The following functions have been renamed:
* SDL_JoystickGetButton() => SDL_GetJoystickButton() * SDL_JoystickGetButton() => SDL_GetJoystickButton()
* SDL_JoystickGetFirmwareVersion() => SDL_GetJoystickFirmwareVersion() * SDL_JoystickGetFirmwareVersion() => SDL_GetJoystickFirmwareVersion()
* SDL_JoystickGetGUID() => SDL_GetJoystickGUID() * SDL_JoystickGetGUID() => SDL_GetJoystickGUID()
* SDL_JoystickGetGUIDFromString() => SDL_GetJoystickGUIDFromString() * SDL_JoystickGetGUIDFromString() => SDL_GUIDFromString()
* SDL_JoystickGetGUIDString() => SDL_GetJoystickGUIDString()
* SDL_JoystickGetHat() => SDL_GetJoystickHat() * SDL_JoystickGetHat() => SDL_GetJoystickHat()
* SDL_JoystickGetPlayerIndex() => SDL_GetJoystickPlayerIndex() * SDL_JoystickGetPlayerIndex() => SDL_GetJoystickPlayerIndex()
* SDL_JoystickGetProduct() => SDL_GetJoystickProduct() * SDL_JoystickGetProduct() => SDL_GetJoystickProduct()
@ -902,6 +901,7 @@ The following functions have been removed:
* SDL_JoystickGetDeviceProductVersion() - replaced with SDL_GetJoystickProductVersionForID() * SDL_JoystickGetDeviceProductVersion() - replaced with SDL_GetJoystickProductVersionForID()
* SDL_JoystickGetDeviceType() - replaced with SDL_GetJoystickTypeForID() * SDL_JoystickGetDeviceType() - replaced with SDL_GetJoystickTypeForID()
* SDL_JoystickGetDeviceVendor() - replaced with SDL_GetJoystickVendorForID() * SDL_JoystickGetDeviceVendor() - replaced with SDL_GetJoystickVendorForID()
* SDL_JoystickGetGUIDString() - replaced with SDL_GUIDToString()
* SDL_JoystickHasLED() - replaced with SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN * SDL_JoystickHasLED() - replaced with SDL_PROP_JOYSTICK_CAP_RGB_LED_BOOLEAN
* SDL_JoystickHasRumble() - replaced with SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN * SDL_JoystickHasRumble() - replaced with SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN
* SDL_JoystickHasRumbleTriggers() - replaced with SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN * SDL_JoystickHasRumbleTriggers() - replaced with SDL_PROP_JOYSTICK_CAP_TRIGGER_RUMBLE_BOOLEAN
@ -913,6 +913,9 @@ The following functions have been removed:
The following symbols have been removed: The following symbols have been removed:
* SDL_JOYBALLMOTION * SDL_JOYBALLMOTION
The following structures have been renamed:
* SDL_JoystickGUID => SDL_GUID
## SDL_keyboard.h ## SDL_keyboard.h
Text input is no longer automatically enabled when initializing video, you should call SDL_StartTextInput() when you want to receive text input and call SDL_StopTextInput() when you are done. Starting text input may shown an input method editor (IME) and cause key up/down events to be skipped, so should only be enabled when the application wants text input. Text input is no longer automatically enabled when initializing video, you should call SDL_StartTextInput() when you want to receive text input and call SDL_StopTextInput() when you are done. Starting text input may shown an input method editor (IME) and cause key up/down events to be skipped, so should only be enabled when the application wants text input.

View file

@ -282,7 +282,7 @@ typedef struct SDL_GamepadBinding
* existing gamepad. * existing gamepad.
* *
* The mapping string has the format "GUID,name,mapping", where GUID is the * The mapping string has the format "GUID,name,mapping", where GUID is the
* string value from SDL_GetJoystickGUIDString(), name is the human readable * string value from SDL_GUIDToString(), name is the human readable
* string for the device and mappings are gamepad mappings to joystick ones. * string for the device and mappings are gamepad mappings to joystick ones.
* Under Windows there is a reserved GUID of "xinput" that covers all XInput * Under Windows there is a reserved GUID of "xinput" that covers all XInput
* devices. The mapping format for joystick is: * devices. The mapping format for joystick is:
@ -414,7 +414,7 @@ extern SDL_DECLSPEC const char * const * SDLCALL SDL_GetGamepadMappings(int *cou
* \sa SDL_GetJoystickGUIDForID * \sa SDL_GetJoystickGUIDForID
* \sa SDL_GetJoystickGUID * \sa SDL_GetJoystickGUID
*/ */
extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_JoystickGUID guid); extern SDL_DECLSPEC const char * SDLCALL SDL_GetGamepadMappingForGUID(SDL_GUID guid);
/** /**
* Get the current mapping of a gamepad. * Get the current mapping of a gamepad.
@ -561,7 +561,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetGamepadPlayerIndexForID(SDL_JoystickID in
* \sa SDL_GetGamepadGUIDString * \sa SDL_GetGamepadGUIDString
* \sa SDL_GetGamepads * \sa SDL_GetGamepads
*/ */
extern SDL_DECLSPEC SDL_JoystickGUID SDLCALL SDL_GetGamepadGUIDForID(SDL_JoystickID instance_id); extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetGamepadGUIDForID(SDL_JoystickID instance_id);
/** /**
* Get the USB vendor ID of a gamepad, if available. * Get the USB vendor ID of a gamepad, if available.

View file

@ -66,19 +66,17 @@ typedef struct SDL_GUID {
/** /**
* Get an ASCII string representation for a given SDL_GUID. * Get an ASCII string representation for a given SDL_GUID.
* *
* You should supply at least 33 bytes for pszGUID. * The returned string follows the SDL_GetStringRule, and will be automatically freed later.
* *
* \param guid the SDL_GUID you wish to convert to string. * \param guid the SDL_GUID you wish to convert to string.
* \param pszGUID buffer in which to write the ASCII string. * \returns the string representation of the GUID or NULL on failure; call
* \param cbGUID the size of pszGUID.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information. * SDL_GetError() for more information.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GUIDFromString * \sa SDL_GUIDFromString
*/ */
extern SDL_DECLSPEC int SDLCALL SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID); extern SDL_DECLSPEC const char * SDLCALL SDL_GUIDToString(SDL_GUID guid);
/** /**
* Convert a GUID string into a SDL_GUID structure. * Convert a GUID string into a SDL_GUID structure.

View file

@ -37,8 +37,8 @@
* controller. For XInput controllers this returns the XInput user index. Many * controller. For XInput controllers this returns the XInput user index. Many
* joysticks will not be able to supply this information. * joysticks will not be able to supply this information.
* *
* The term SDL_JoystickGUID is a stable 128-bit identifier for a joystick * SDL_GUID is used as a stable 128-bit identifier for a joystick
* device that does not change over time, it identifies class of the device (a * device that does not change over time. It identifies class of the device (a
* X360 wired controller for example). This identifier is platform dependent. * X360 wired controller for example). This identifier is platform dependent.
* *
* In order to use these functions, SDL_Init() must have been called with the * In order to use these functions, SDL_Init() must have been called with the
@ -85,15 +85,6 @@ extern SDL_Mutex *SDL_joystick_lock;
*/ */
typedef struct SDL_Joystick SDL_Joystick; typedef struct SDL_Joystick SDL_Joystick;
/**
* A structure that encodes the stable unique id for a joystick device.
*
* This is just a standard SDL_GUID by a different name.
*
* \since This datatype is available since SDL 3.0.0.
*/
typedef SDL_GUID SDL_JoystickGUID;
/** /**
* This is a unique ID for a joystick for the time it is connected to the * This is a unique ID for a joystick for the time it is connected to the
* system, and is never reused for the lifetime of the application. * system, and is never reused for the lifetime of the application.
@ -286,9 +277,9 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetJoystickPlayerIndexForID(SDL_JoystickID i
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetJoystickGUID * \sa SDL_GetJoystickGUID
* \sa SDL_GetJoystickGUIDString * \sa SDL_GUIDToString
*/ */
extern SDL_DECLSPEC SDL_JoystickGUID SDLCALL SDL_GetJoystickGUIDForID(SDL_JoystickID instance_id); extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetJoystickGUIDForID(SDL_JoystickID instance_id);
/** /**
* Get the USB vendor ID of a joystick, if available. * Get the USB vendor ID of a joystick, if available.
@ -737,9 +728,9 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetJoystickPlayerIndex(SDL_Joystick *joystic
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetJoystickGUIDForID * \sa SDL_GetJoystickGUIDForID
* \sa SDL_GetJoystickGUIDString * \sa SDL_GUIDToString
*/ */
extern SDL_DECLSPEC SDL_JoystickGUID SDLCALL SDL_GetJoystickGUID(SDL_Joystick *joystick); extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GetJoystickGUID(SDL_Joystick *joystick);
/** /**
* Get the USB vendor ID of an opened joystick, if available. * Get the USB vendor ID of an opened joystick, if available.
@ -824,44 +815,25 @@ extern SDL_DECLSPEC const char * SDLCALL SDL_GetJoystickSerial(SDL_Joystick *joy
extern SDL_DECLSPEC SDL_JoystickType SDLCALL SDL_GetJoystickType(SDL_Joystick *joystick); extern SDL_DECLSPEC SDL_JoystickType SDLCALL SDL_GetJoystickType(SDL_Joystick *joystick);
/** /**
* Get an ASCII string representation for a given SDL_JoystickGUID. * Convert a GUID string into a SDL_GUID structure.
*
* You should supply at least 33 bytes for pszGUID.
*
* \param guid the SDL_JoystickGUID you wish to convert to string.
* \param pszGUID buffer in which to write the ASCII string.
* \param cbGUID the size of pszGUID.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetJoystickGUIDForID
* \sa SDL_GetJoystickGUID
* \sa SDL_GetJoystickGUIDFromString
*/
extern SDL_DECLSPEC int SDLCALL SDL_GetJoystickGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID);
/**
* Convert a GUID string into a SDL_JoystickGUID structure.
* *
* Performs no error checking. If this function is given a string containing * Performs no error checking. If this function is given a string containing
* an invalid GUID, the function will silently succeed, but the GUID generated * an invalid GUID, the function will silently succeed, but the GUID generated
* will not be useful. * will not be useful.
* *
* \param pchGUID string containing an ASCII representation of a GUID. * \param pchGUID string containing an ASCII representation of a GUID.
* \returns a SDL_JoystickGUID structure. * \returns a SDL_GUID structure.
* *
* \since This function is available since SDL 3.0.0. * \since This function is available since SDL 3.0.0.
* *
* \sa SDL_GetJoystickGUIDString * \sa SDL_GUIDToString
*/ */
extern SDL_DECLSPEC SDL_JoystickGUID SDLCALL SDL_GetJoystickGUIDFromString(const char *pchGUID); extern SDL_DECLSPEC SDL_GUID SDLCALL SDL_GUIDFromString(const char *pchGUID);
/** /**
* Get the device information encoded in a SDL_JoystickGUID structure. * Get the device information encoded in a SDL_GUID structure.
* *
* \param guid the SDL_JoystickGUID you wish to get info about. * \param guid the SDL_GUID you wish to get info about.
* \param vendor a pointer filled in with the device VID, or 0 if not * \param vendor a pointer filled in with the device VID, or 0 if not
* available. * available.
* \param product a pointer filled in with the device PID, or 0 if not * \param product a pointer filled in with the device PID, or 0 if not
@ -875,7 +847,7 @@ extern SDL_DECLSPEC SDL_JoystickGUID SDLCALL SDL_GetJoystickGUIDFromString(const
* *
* \sa SDL_GetJoystickGUIDForID * \sa SDL_GetJoystickGUIDForID
*/ */
extern SDL_DECLSPEC void SDLCALL SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version, Uint16 *crc16); extern SDL_DECLSPEC void SDLCALL SDL_GetJoystickGUIDInfo(SDL_GUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version, Uint16 *crc16);
/** /**
* Get the status of a specified joystick. * Get the status of a specified joystick.

View file

@ -309,6 +309,7 @@
#define SDL_JoystickDetachVirtual SDL_DetachVirtualJoystick #define SDL_JoystickDetachVirtual SDL_DetachVirtualJoystick
#define SDL_JoystickFromInstanceID SDL_GetJoystickFromID #define SDL_JoystickFromInstanceID SDL_GetJoystickFromID
#define SDL_JoystickFromPlayerIndex SDL_GetJoystickFromPlayerIndex #define SDL_JoystickFromPlayerIndex SDL_GetJoystickFromPlayerIndex
#define SDL_JoystickGUID SDL_GUID
#define SDL_JoystickGetAttached SDL_JoystickConnected #define SDL_JoystickGetAttached SDL_JoystickConnected
#define SDL_JoystickGetAxis SDL_GetJoystickAxis #define SDL_JoystickGetAxis SDL_GetJoystickAxis
#define SDL_JoystickGetAxisInitialState SDL_GetJoystickAxisInitialState #define SDL_JoystickGetAxisInitialState SDL_GetJoystickAxisInitialState
@ -316,8 +317,7 @@
#define SDL_JoystickGetButton SDL_GetJoystickButton #define SDL_JoystickGetButton SDL_GetJoystickButton
#define SDL_JoystickGetFirmwareVersion SDL_GetJoystickFirmwareVersion #define SDL_JoystickGetFirmwareVersion SDL_GetJoystickFirmwareVersion
#define SDL_JoystickGetGUID SDL_GetJoystickGUID #define SDL_JoystickGetGUID SDL_GetJoystickGUID
#define SDL_JoystickGetGUIDFromString SDL_GetJoystickGUIDFromString #define SDL_JoystickGetGUIDFromString SDL_GUIDFromString
#define SDL_JoystickGetGUIDString SDL_GetJoystickGUIDString
#define SDL_JoystickGetHat SDL_GetJoystickHat #define SDL_JoystickGetHat SDL_GetJoystickHat
#define SDL_JoystickGetPlayerIndex SDL_GetJoystickPlayerIndex #define SDL_JoystickGetPlayerIndex SDL_GetJoystickPlayerIndex
#define SDL_JoystickGetProduct SDL_GetJoystickProduct #define SDL_JoystickGetProduct SDL_GetJoystickProduct
@ -925,6 +925,7 @@
#define SDL_JoystickDetachVirtual SDL_JoystickDetachVirtual_renamed_SDL_DetachVirtualJoystick #define SDL_JoystickDetachVirtual SDL_JoystickDetachVirtual_renamed_SDL_DetachVirtualJoystick
#define SDL_JoystickFromInstanceID SDL_JoystickFromInstanceID_renamed_SDL_GetJoystickFromID #define SDL_JoystickFromInstanceID SDL_JoystickFromInstanceID_renamed_SDL_GetJoystickFromID
#define SDL_JoystickFromPlayerIndex SDL_JoystickFromPlayerIndex_renamed_SDL_GetJoystickFromPlayerIndex #define SDL_JoystickFromPlayerIndex SDL_JoystickFromPlayerIndex_renamed_SDL_GetJoystickFromPlayerIndex
#define SDL_JoystickGUID SDL_JoystickGUID_renamed_SDL_GUID
#define SDL_JoystickGetAttached SDL_JoystickGetAttached_renamed_SDL_JoystickConnected #define SDL_JoystickGetAttached SDL_JoystickGetAttached_renamed_SDL_JoystickConnected
#define SDL_JoystickGetAxis SDL_JoystickGetAxis_renamed_SDL_GetJoystickAxis #define SDL_JoystickGetAxis SDL_JoystickGetAxis_renamed_SDL_GetJoystickAxis
#define SDL_JoystickGetAxisInitialState SDL_JoystickGetAxisInitialState_renamed_SDL_GetJoystickAxisInitialState #define SDL_JoystickGetAxisInitialState SDL_JoystickGetAxisInitialState_renamed_SDL_GetJoystickAxisInitialState
@ -932,8 +933,7 @@
#define SDL_JoystickGetButton SDL_JoystickGetButton_renamed_SDL_GetJoystickButton #define SDL_JoystickGetButton SDL_JoystickGetButton_renamed_SDL_GetJoystickButton
#define SDL_JoystickGetFirmwareVersion SDL_JoystickGetFirmwareVersion_renamed_SDL_GetJoystickFirmwareVersion #define SDL_JoystickGetFirmwareVersion SDL_JoystickGetFirmwareVersion_renamed_SDL_GetJoystickFirmwareVersion
#define SDL_JoystickGetGUID SDL_JoystickGetGUID_renamed_SDL_GetJoystickGUID #define SDL_JoystickGetGUID SDL_JoystickGetGUID_renamed_SDL_GetJoystickGUID
#define SDL_JoystickGetGUIDFromString SDL_JoystickGetGUIDFromString_renamed_SDL_GetJoystickGUIDFromString #define SDL_JoystickGetGUIDFromString SDL_JoystickGetGUIDFromString_renamed_SDL_GUIDFromString
#define SDL_JoystickGetGUIDString SDL_JoystickGetGUIDString_renamed_SDL_GetJoystickGUIDString
#define SDL_JoystickGetHat SDL_JoystickGetHat_renamed_SDL_GetJoystickHat #define SDL_JoystickGetHat SDL_JoystickGetHat_renamed_SDL_GetJoystickHat
#define SDL_JoystickGetPlayerIndex SDL_JoystickGetPlayerIndex_renamed_SDL_GetJoystickPlayerIndex #define SDL_JoystickGetPlayerIndex SDL_JoystickGetPlayerIndex_renamed_SDL_GetJoystickPlayerIndex
#define SDL_JoystickGetProduct SDL_JoystickGetProduct_renamed_SDL_GetJoystickProduct #define SDL_JoystickGetProduct SDL_JoystickGetProduct_renamed_SDL_GetJoystickProduct

View file

@ -21,28 +21,21 @@
#include "SDL_internal.h" #include "SDL_internal.h"
/* convert the guid to a printable string */ /* convert the guid to a printable string */
int SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID) const char *SDL_GUIDToString(SDL_GUID guid)
{ {
static const char k_rgchHexToASCII[] = "0123456789abcdef"; static const char k_rgchHexToASCII[] = "0123456789abcdef";
int i; int i;
char string[sizeof(guid) * 2 + 1];
if (!pszGUID) { for (i = 0; i < sizeof(guid.data); ++i) {
return SDL_InvalidParamError("pszGUID");
}
if (cbGUID <= 0) {
return SDL_InvalidParamError("cbGUID");
}
for (i = 0; i < sizeof(guid.data) && i < (cbGUID - 1) / 2; i++) {
/* each input byte writes 2 ascii chars, and might write a null byte. */
/* If we don't have room for next input byte, stop */
unsigned char c = guid.data[i]; unsigned char c = guid.data[i];
*pszGUID++ = k_rgchHexToASCII[c >> 4]; string[i * 2 + 0] = k_rgchHexToASCII[c >> 4];
*pszGUID++ = k_rgchHexToASCII[c & 0x0F]; string[i * 2 + 1] = k_rgchHexToASCII[c & 0x0F];
} }
*pszGUID = '\0'; string[sizeof(string) -1] = '\0';
return 0;
return SDL_CreateTemporaryString(string);
} }
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------

View file

@ -298,9 +298,7 @@ SDL3_0.0.0 {
SDL_GetJoystickFromPlayerIndex; SDL_GetJoystickFromPlayerIndex;
SDL_GetJoystickGUID; SDL_GetJoystickGUID;
SDL_GetJoystickGUIDForID; SDL_GetJoystickGUIDForID;
SDL_GetJoystickGUIDFromString;
SDL_GetJoystickGUIDInfo; SDL_GetJoystickGUIDInfo;
SDL_GetJoystickGUIDString;
SDL_GetJoystickHat; SDL_GetJoystickHat;
SDL_GetJoystickID; SDL_GetJoystickID;
SDL_GetJoystickName; SDL_GetJoystickName;

View file

@ -323,9 +323,7 @@
#define SDL_GetJoystickFromPlayerIndex SDL_GetJoystickFromPlayerIndex_REAL #define SDL_GetJoystickFromPlayerIndex SDL_GetJoystickFromPlayerIndex_REAL
#define SDL_GetJoystickGUID SDL_GetJoystickGUID_REAL #define SDL_GetJoystickGUID SDL_GetJoystickGUID_REAL
#define SDL_GetJoystickGUIDForID SDL_GetJoystickGUIDForID_REAL #define SDL_GetJoystickGUIDForID SDL_GetJoystickGUIDForID_REAL
#define SDL_GetJoystickGUIDFromString SDL_GetJoystickGUIDFromString_REAL
#define SDL_GetJoystickGUIDInfo SDL_GetJoystickGUIDInfo_REAL #define SDL_GetJoystickGUIDInfo SDL_GetJoystickGUIDInfo_REAL
#define SDL_GetJoystickGUIDString SDL_GetJoystickGUIDString_REAL
#define SDL_GetJoystickHat SDL_GetJoystickHat_REAL #define SDL_GetJoystickHat SDL_GetJoystickHat_REAL
#define SDL_GetJoystickID SDL_GetJoystickID_REAL #define SDL_GetJoystickID SDL_GetJoystickID_REAL
#define SDL_GetJoystickName SDL_GetJoystickName_REAL #define SDL_GetJoystickName SDL_GetJoystickName_REAL

View file

@ -188,7 +188,7 @@ SDL_DYNAPI_PROC(int,SDL_GL_SetSwapInterval,(int a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GL_SwapWindow,(SDL_Window *a),(a),return) SDL_DYNAPI_PROC(int,SDL_GL_SwapWindow,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_GL_UnloadLibrary,(void),(),) SDL_DYNAPI_PROC(void,SDL_GL_UnloadLibrary,(void),(),)
SDL_DYNAPI_PROC(SDL_GUID,SDL_GUIDFromString,(const char *a),(a),return) SDL_DYNAPI_PROC(SDL_GUID,SDL_GUIDFromString,(const char *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GUIDToString,(SDL_GUID a, char *b, int c),(a,b,c),return) SDL_DYNAPI_PROC(const char *,SDL_GUIDToString,(SDL_GUID a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GamepadConnected,(SDL_Gamepad *a),(a),return) SDL_DYNAPI_PROC(SDL_bool,SDL_GamepadConnected,(SDL_Gamepad *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GamepadEventsEnabled,(void),(),return) SDL_DYNAPI_PROC(SDL_bool,SDL_GamepadEventsEnabled,(void),(),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GamepadHasAxis,(SDL_Gamepad *a, SDL_GamepadAxis b),(a,b),return) SDL_DYNAPI_PROC(SDL_bool,SDL_GamepadHasAxis,(SDL_Gamepad *a, SDL_GamepadAxis b),(a,b),return)
@ -285,11 +285,11 @@ SDL_DYNAPI_PROC(SDL_JoystickConnectionState,SDL_GetGamepadConnectionState,(SDL_G
SDL_DYNAPI_PROC(Uint16,SDL_GetGamepadFirmwareVersion,(SDL_Gamepad *a),(a),return) SDL_DYNAPI_PROC(Uint16,SDL_GetGamepadFirmwareVersion,(SDL_Gamepad *a),(a),return)
SDL_DYNAPI_PROC(SDL_Gamepad*,SDL_GetGamepadFromID,(SDL_JoystickID a),(a),return) SDL_DYNAPI_PROC(SDL_Gamepad*,SDL_GetGamepadFromID,(SDL_JoystickID a),(a),return)
SDL_DYNAPI_PROC(SDL_Gamepad*,SDL_GetGamepadFromPlayerIndex,(int a),(a),return) SDL_DYNAPI_PROC(SDL_Gamepad*,SDL_GetGamepadFromPlayerIndex,(int a),(a),return)
SDL_DYNAPI_PROC(SDL_JoystickGUID,SDL_GetGamepadGUIDForID,(SDL_JoystickID a),(a),return) SDL_DYNAPI_PROC(SDL_GUID,SDL_GetGamepadGUIDForID,(SDL_JoystickID a),(a),return)
SDL_DYNAPI_PROC(SDL_JoystickID,SDL_GetGamepadID,(SDL_Gamepad *a),(a),return) SDL_DYNAPI_PROC(SDL_JoystickID,SDL_GetGamepadID,(SDL_Gamepad *a),(a),return)
SDL_DYNAPI_PROC(SDL_Joystick*,SDL_GetGamepadJoystick,(SDL_Gamepad *a),(a),return) SDL_DYNAPI_PROC(SDL_Joystick*,SDL_GetGamepadJoystick,(SDL_Gamepad *a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetGamepadMapping,(SDL_Gamepad *a),(a),return) SDL_DYNAPI_PROC(const char*,SDL_GetGamepadMapping,(SDL_Gamepad *a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetGamepadMappingForGUID,(SDL_JoystickGUID a),(a),return) SDL_DYNAPI_PROC(const char*,SDL_GetGamepadMappingForGUID,(SDL_GUID a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetGamepadMappingForID,(SDL_JoystickID a),(a),return) SDL_DYNAPI_PROC(const char*,SDL_GetGamepadMappingForID,(SDL_JoystickID a),(a),return)
SDL_DYNAPI_PROC(const char * const *,SDL_GetGamepadMappings,(int *a),(a),return) SDL_DYNAPI_PROC(const char * const *,SDL_GetGamepadMappings,(int *a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetGamepadName,(SDL_Gamepad *a),(a),return) SDL_DYNAPI_PROC(const char*,SDL_GetGamepadName,(SDL_Gamepad *a),(a),return)
@ -341,11 +341,9 @@ SDL_DYNAPI_PROC(SDL_JoystickConnectionState,SDL_GetJoystickConnectionState,(SDL_
SDL_DYNAPI_PROC(Uint16,SDL_GetJoystickFirmwareVersion,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(Uint16,SDL_GetJoystickFirmwareVersion,(SDL_Joystick *a),(a),return)
SDL_DYNAPI_PROC(SDL_Joystick*,SDL_GetJoystickFromID,(SDL_JoystickID a),(a),return) SDL_DYNAPI_PROC(SDL_Joystick*,SDL_GetJoystickFromID,(SDL_JoystickID a),(a),return)
SDL_DYNAPI_PROC(SDL_Joystick*,SDL_GetJoystickFromPlayerIndex,(int a),(a),return) SDL_DYNAPI_PROC(SDL_Joystick*,SDL_GetJoystickFromPlayerIndex,(int a),(a),return)
SDL_DYNAPI_PROC(SDL_JoystickGUID,SDL_GetJoystickGUID,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(SDL_GUID,SDL_GetJoystickGUID,(SDL_Joystick *a),(a),return)
SDL_DYNAPI_PROC(SDL_JoystickGUID,SDL_GetJoystickGUIDForID,(SDL_JoystickID a),(a),return) SDL_DYNAPI_PROC(SDL_GUID,SDL_GetJoystickGUIDForID,(SDL_JoystickID a),(a),return)
SDL_DYNAPI_PROC(SDL_JoystickGUID,SDL_GetJoystickGUIDFromString,(const char *a),(a),return) SDL_DYNAPI_PROC(void,SDL_GetJoystickGUIDInfo,(SDL_GUID a, Uint16 *b, Uint16 *c, Uint16 *d, Uint16 *e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(void,SDL_GetJoystickGUIDInfo,(SDL_JoystickGUID a, Uint16 *b, Uint16 *c, Uint16 *d, Uint16 *e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(int,SDL_GetJoystickGUIDString,(SDL_JoystickGUID a, char *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(Uint8,SDL_GetJoystickHat,(SDL_Joystick *a, int b),(a,b),return) SDL_DYNAPI_PROC(Uint8,SDL_GetJoystickHat,(SDL_Joystick *a, int b),(a,b),return)
SDL_DYNAPI_PROC(SDL_JoystickID,SDL_GetJoystickID,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(SDL_JoystickID,SDL_GetJoystickID,(SDL_Joystick *a),(a),return)
SDL_DYNAPI_PROC(const char*,SDL_GetJoystickName,(SDL_Joystick *a),(a),return) SDL_DYNAPI_PROC(const char*,SDL_GetJoystickName,(SDL_Joystick *a),(a),return)

View file

@ -79,7 +79,7 @@ typedef enum
typedef struct GamepadMapping_t typedef struct GamepadMapping_t
{ {
SDL_JoystickGUID guid _guarded; SDL_GUID guid _guarded;
char *name _guarded; char *name _guarded;
char *mapping _guarded; char *mapping _guarded;
SDL_GamepadMappingPriority priority _guarded; SDL_GamepadMappingPriority priority _guarded;
@ -99,7 +99,7 @@ typedef struct
#undef _guarded #undef _guarded
static SDL_JoystickGUID s_zeroGUID; static SDL_GUID s_zeroGUID;
static GamepadMapping_t *s_pSupportedGamepads SDL_GUARDED_BY(SDL_joystick_lock) = NULL; static GamepadMapping_t *s_pSupportedGamepads SDL_GUARDED_BY(SDL_joystick_lock) = NULL;
static GamepadMapping_t *s_pDefaultMapping SDL_GUARDED_BY(SDL_joystick_lock) = NULL; static GamepadMapping_t *s_pDefaultMapping SDL_GUARDED_BY(SDL_joystick_lock) = NULL;
static GamepadMapping_t *s_pXInputMapping SDL_GUARDED_BY(SDL_joystick_lock) = NULL; static GamepadMapping_t *s_pXInputMapping SDL_GUARDED_BY(SDL_joystick_lock) = NULL;
@ -150,7 +150,7 @@ static SDL_vidpid_list SDL_ignored_gamepads = {
SDL_FALSE SDL_FALSE
}; };
static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, const char *mappingString, SDL_bool *existing, SDL_GamepadMappingPriority priority); static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_GUID jGUID, const char *mappingString, SDL_bool *existing, SDL_GamepadMappingPriority priority);
static void SDL_PrivateLoadButtonMapping(SDL_Gamepad *gamepad, GamepadMapping_t *pGamepadMapping); static void SDL_PrivateLoadButtonMapping(SDL_Gamepad *gamepad, GamepadMapping_t *pGamepadMapping);
static GamepadMapping_t *SDL_PrivateGetGamepadMapping(SDL_JoystickID instance_id, SDL_bool create_mapping); static GamepadMapping_t *SDL_PrivateGetGamepadMapping(SDL_JoystickID instance_id, SDL_bool create_mapping);
static int SDL_SendGamepadAxis(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_GamepadAxis axis, Sint16 value); static int SDL_SendGamepadAxis(Uint64 timestamp, SDL_Gamepad *gamepad, SDL_GamepadAxis axis, Sint16 value);
@ -588,7 +588,7 @@ static void PopMappingChangeTracking(void)
/* /*
* Helper function to guess at a mapping based on the elements reported for this gamepad * Helper function to guess at a mapping based on the elements reported for this gamepad
*/ */
static GamepadMapping_t *SDL_CreateMappingForAndroidGamepad(SDL_JoystickGUID guid) static GamepadMapping_t *SDL_CreateMappingForAndroidGamepad(SDL_GUID guid)
{ {
const int face_button_mask = ((1 << SDL_GAMEPAD_BUTTON_SOUTH) | const int face_button_mask = ((1 << SDL_GAMEPAD_BUTTON_SOUTH) |
(1 << SDL_GAMEPAD_BUTTON_EAST) | (1 << SDL_GAMEPAD_BUTTON_EAST) |
@ -690,7 +690,7 @@ static GamepadMapping_t *SDL_CreateMappingForAndroidGamepad(SDL_JoystickGUID gui
/* /*
* Helper function to guess at a mapping for HIDAPI gamepads * Helper function to guess at a mapping for HIDAPI gamepads
*/ */
static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_JoystickGUID guid) static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid)
{ {
SDL_bool existing; SDL_bool existing;
char mapping_string[1024]; char mapping_string[1024];
@ -835,7 +835,7 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_JoystickGUID guid
/* /*
* Helper function to guess at a mapping for RAWINPUT gamepads * Helper function to guess at a mapping for RAWINPUT gamepads
*/ */
static GamepadMapping_t *SDL_CreateMappingForRAWINPUTGamepad(SDL_JoystickGUID guid) static GamepadMapping_t *SDL_CreateMappingForRAWINPUTGamepad(SDL_GUID guid)
{ {
SDL_bool existing; SDL_bool existing;
char mapping_string[1024]; char mapping_string[1024];
@ -849,7 +849,7 @@ static GamepadMapping_t *SDL_CreateMappingForRAWINPUTGamepad(SDL_JoystickGUID gu
/* /*
* Helper function to guess at a mapping for WGI gamepads * Helper function to guess at a mapping for WGI gamepads
*/ */
static GamepadMapping_t *SDL_CreateMappingForWGIGamepad(SDL_JoystickGUID guid) static GamepadMapping_t *SDL_CreateMappingForWGIGamepad(SDL_GUID guid)
{ {
SDL_bool existing; SDL_bool existing;
char mapping_string[1024]; char mapping_string[1024];
@ -867,7 +867,7 @@ static GamepadMapping_t *SDL_CreateMappingForWGIGamepad(SDL_JoystickGUID guid)
/* /*
* Helper function to scan the mappings database for a gamepad with the specified GUID * Helper function to scan the mappings database for a gamepad with the specified GUID
*/ */
static GamepadMapping_t *SDL_PrivateMatchGamepadMappingForGUID(SDL_JoystickGUID guid, SDL_bool match_version) static GamepadMapping_t *SDL_PrivateMatchGamepadMappingForGUID(SDL_GUID guid, SDL_bool match_version)
{ {
GamepadMapping_t *mapping, *best_match = NULL; GamepadMapping_t *mapping, *best_match = NULL;
Uint16 crc = 0; Uint16 crc = 0;
@ -884,7 +884,7 @@ static GamepadMapping_t *SDL_PrivateMatchGamepadMappingForGUID(SDL_JoystickGUID
} }
for (mapping = s_pSupportedGamepads; mapping; mapping = mapping->next) { for (mapping = s_pSupportedGamepads; mapping; mapping = mapping->next) {
SDL_JoystickGUID mapping_guid; SDL_GUID mapping_guid;
if (SDL_memcmp(&mapping->guid, &s_zeroGUID, sizeof(mapping->guid)) == 0) { if (SDL_memcmp(&mapping->guid, &s_zeroGUID, sizeof(mapping->guid)) == 0) {
continue; continue;
@ -919,7 +919,7 @@ static GamepadMapping_t *SDL_PrivateMatchGamepadMappingForGUID(SDL_JoystickGUID
/* /*
* Helper function to scan the mappings database for a gamepad with the specified GUID * Helper function to scan the mappings database for a gamepad with the specified GUID
*/ */
static GamepadMapping_t *SDL_PrivateGetGamepadMappingForGUID(SDL_JoystickGUID guid, SDL_bool adding_mapping) static GamepadMapping_t *SDL_PrivateGetGamepadMappingForGUID(SDL_GUID guid, SDL_bool adding_mapping)
{ {
GamepadMapping_t *mapping; GamepadMapping_t *mapping;
@ -1528,7 +1528,7 @@ static char *SDL_PrivateGetGamepadMappingFromMappingString(const char *pMapping)
/* /*
* Helper function to add a mapping for a guid * Helper function to add a mapping for a guid
*/ */
static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, const char *mappingString, SDL_bool *existing, SDL_GamepadMappingPriority priority) static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_GUID jGUID, const char *mappingString, SDL_bool *existing, SDL_GamepadMappingPriority priority)
{ {
char *pchName; char *pchName;
char *pchMapping; char *pchMapping;
@ -1656,7 +1656,7 @@ static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, co
/* /*
* Helper function to determine pre-calculated offset to certain joystick mappings * Helper function to determine pre-calculated offset to certain joystick mappings
*/ */
static GamepadMapping_t *SDL_PrivateGetGamepadMappingForNameAndGUID(const char *name, SDL_JoystickGUID guid) static GamepadMapping_t *SDL_PrivateGetGamepadMappingForNameAndGUID(const char *name, SDL_GUID guid)
{ {
GamepadMapping_t *mapping; GamepadMapping_t *mapping;
@ -1713,7 +1713,7 @@ static void SDL_PrivateAppendToMappingString(char *mapping_string,
} }
static GamepadMapping_t *SDL_PrivateGenerateAutomaticGamepadMapping(const char *name, static GamepadMapping_t *SDL_PrivateGenerateAutomaticGamepadMapping(const char *name,
SDL_JoystickGUID guid, SDL_GUID guid,
SDL_GamepadMapping *raw_map) SDL_GamepadMapping *raw_map)
{ {
SDL_bool existing; SDL_bool existing;
@ -1772,7 +1772,7 @@ static GamepadMapping_t *SDL_PrivateGenerateAutomaticGamepadMapping(const char *
static GamepadMapping_t *SDL_PrivateGetGamepadMapping(SDL_JoystickID instance_id, SDL_bool create_mapping) static GamepadMapping_t *SDL_PrivateGetGamepadMapping(SDL_JoystickID instance_id, SDL_bool create_mapping)
{ {
const char *name; const char *name;
SDL_JoystickGUID guid; SDL_GUID guid;
GamepadMapping_t *mapping; GamepadMapping_t *mapping;
SDL_AssertJoysticksLocked(); SDL_AssertJoysticksLocked();
@ -1926,7 +1926,7 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa
{ {
char *remapped = NULL; char *remapped = NULL;
char *pchGUID; char *pchGUID;
SDL_JoystickGUID jGUID; SDL_GUID jGUID;
SDL_bool is_default_mapping = SDL_FALSE; SDL_bool is_default_mapping = SDL_FALSE;
SDL_bool is_xinput_mapping = SDL_FALSE; SDL_bool is_xinput_mapping = SDL_FALSE;
SDL_bool existing = SDL_FALSE; SDL_bool existing = SDL_FALSE;
@ -2028,7 +2028,7 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa
} else if (!SDL_strcasecmp(pchGUID, "xinput")) { } else if (!SDL_strcasecmp(pchGUID, "xinput")) {
is_xinput_mapping = SDL_TRUE; is_xinput_mapping = SDL_TRUE;
} }
jGUID = SDL_GetJoystickGUIDFromString(pchGUID); jGUID = SDL_GUIDFromString(pchGUID);
SDL_free(pchGUID); SDL_free(pchGUID);
pGamepadMapping = SDL_PrivateAddMappingForGUID(jGUID, mappingString, &existing, priority); pGamepadMapping = SDL_PrivateAddMappingForGUID(jGUID, mappingString, &existing, priority);
@ -2072,17 +2072,17 @@ int SDL_AddGamepadMapping(const char *mapping)
/* /*
* Create a mapping string for a mapping * Create a mapping string for a mapping
*/ */
static char *CreateMappingString(GamepadMapping_t *mapping, SDL_JoystickGUID guid) static char *CreateMappingString(GamepadMapping_t *mapping, SDL_GUID guid)
{ {
char *pMappingString, *pPlatformString; char *pMappingString, *pPlatformString;
char pchGUID[33]; const char *pchGUID;
size_t needed; size_t needed;
SDL_bool need_platform = SDL_FALSE; SDL_bool need_platform = SDL_FALSE;
const char *platform = NULL; const char *platform = NULL;
SDL_AssertJoysticksLocked(); SDL_AssertJoysticksLocked();
SDL_GetJoystickGUIDString(guid, pchGUID, sizeof(pchGUID)); pchGUID = SDL_GUIDToString(guid);
/* allocate enough memory for GUID + ',' + name + ',' + mapping + \0 */ /* allocate enough memory for GUID + ',' + name + ',' + mapping + \0 */
needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1; needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1;
@ -2203,7 +2203,7 @@ const char * const *SDL_GetGamepadMappings(int *count)
/* /*
* Get the mapping string for this GUID * Get the mapping string for this GUID
*/ */
const char *SDL_GetGamepadMappingForGUID(SDL_JoystickGUID guid) const char *SDL_GetGamepadMappingForGUID(SDL_GUID guid)
{ {
char *retval; char *retval;
@ -2245,7 +2245,7 @@ const char *SDL_GetGamepadMapping(SDL_Gamepad *gamepad)
*/ */
int SDL_SetGamepadMapping(SDL_JoystickID instance_id, const char *mapping) int SDL_SetGamepadMapping(SDL_JoystickID instance_id, const char *mapping)
{ {
SDL_JoystickGUID guid = SDL_GetJoystickGUIDForID(instance_id); SDL_GUID guid = SDL_GetJoystickGUIDForID(instance_id);
int retval = -1; int retval = -1;
if (SDL_memcmp(&guid, &s_zeroGUID, sizeof(guid)) == 0) { if (SDL_memcmp(&guid, &s_zeroGUID, sizeof(guid)) == 0) {
@ -2447,7 +2447,7 @@ int SDL_GetGamepadPlayerIndexForID(SDL_JoystickID instance_id)
return SDL_GetJoystickPlayerIndexForID(instance_id); return SDL_GetJoystickPlayerIndexForID(instance_id);
} }
SDL_JoystickGUID SDL_GetGamepadGUIDForID(SDL_JoystickID instance_id) SDL_GUID SDL_GetGamepadGUIDForID(SDL_JoystickID instance_id)
{ {
return SDL_GetJoystickGUIDForID(instance_id); return SDL_GetJoystickGUIDForID(instance_id);
} }
@ -2524,9 +2524,9 @@ const char *SDL_GetGamepadMappingForID(SDL_JoystickID instance_id)
{ {
GamepadMapping_t *mapping = SDL_PrivateGetGamepadMapping(instance_id, SDL_TRUE); GamepadMapping_t *mapping = SDL_PrivateGetGamepadMapping(instance_id, SDL_TRUE);
if (mapping) { if (mapping) {
char pchGUID[33]; const char *pchGUID;
const SDL_JoystickGUID guid = SDL_GetJoystickGUIDForID(instance_id); const SDL_GUID guid = SDL_GetJoystickGUIDForID(instance_id);
SDL_GetJoystickGUIDString(guid, pchGUID, sizeof(pchGUID)); pchGUID = SDL_GUIDToString(guid);
SDL_asprintf(&retval, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping); SDL_asprintf(&retval, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping);
} }
} }
@ -2538,7 +2538,7 @@ const char *SDL_GetGamepadMappingForID(SDL_JoystickID instance_id)
/* /*
* Return 1 if the joystick with this name and GUID is a supported gamepad * Return 1 if the joystick with this name and GUID is a supported gamepad
*/ */
SDL_bool SDL_IsGamepadNameAndGUID(const char *name, SDL_JoystickGUID guid) SDL_bool SDL_IsGamepadNameAndGUID(const char *name, SDL_GUID guid)
{ {
SDL_bool retval; SDL_bool retval;
@ -2588,7 +2588,7 @@ SDL_bool SDL_IsGamepad(SDL_JoystickID instance_id)
/* /*
* Return 1 if the gamepad should be ignored by SDL * Return 1 if the gamepad should be ignored by SDL
*/ */
SDL_bool SDL_ShouldIgnoreGamepad(const char *name, SDL_JoystickGUID guid) SDL_bool SDL_ShouldIgnoreGamepad(const char *name, SDL_GUID guid)
{ {
Uint16 vendor; Uint16 vendor;
Uint16 product; Uint16 product;

View file

@ -36,10 +36,10 @@ extern void SDL_PrivateGamepadAdded(SDL_JoystickID instance_id);
extern void SDL_PrivateGamepadRemoved(SDL_JoystickID instance_id); extern void SDL_PrivateGamepadRemoved(SDL_JoystickID instance_id);
/* Function to return whether a joystick name and GUID is a gamepad */ /* Function to return whether a joystick name and GUID is a gamepad */
extern SDL_bool SDL_IsGamepadNameAndGUID(const char *name, SDL_JoystickGUID guid); extern SDL_bool SDL_IsGamepadNameAndGUID(const char *name, SDL_GUID guid);
/* Function to return whether a gamepad should be ignored */ /* Function to return whether a gamepad should be ignored */
extern SDL_bool SDL_ShouldIgnoreGamepad(const char *name, SDL_JoystickGUID guid); extern SDL_bool SDL_ShouldIgnoreGamepad(const char *name, SDL_GUID guid);
/* Handle delayed guide button on a gamepad */ /* Handle delayed guide button on a gamepad */
extern void SDL_GamepadHandleDelayedGuideButton(SDL_Joystick *joystick); extern void SDL_GamepadHandleDelayedGuideButton(SDL_Joystick *joystick);

View file

@ -848,7 +848,7 @@ static SDL_bool SDL_JoystickAxesCenteredAtZero(SDL_Joystick *joystick)
static SDL_bool IsROGAlly(SDL_Joystick *joystick) static SDL_bool IsROGAlly(SDL_Joystick *joystick)
{ {
Uint16 vendor, product; Uint16 vendor, product;
SDL_JoystickGUID guid = SDL_GetJoystickGUID(joystick); SDL_GUID guid = SDL_GetJoystickGUID(joystick);
/* The ROG Ally controller spoofs an Xbox 360 controller */ /* The ROG Ally controller spoofs an Xbox 360 controller */
SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, NULL); SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL, NULL);
@ -917,7 +917,7 @@ static SDL_bool ShouldAttemptSensorFusion(SDL_Joystick *joystick, SDL_bool *inve
if (hint) { if (hint) {
SDL_vidpid_list gamepads; SDL_vidpid_list gamepads;
SDL_JoystickGUID guid; SDL_GUID guid;
Uint16 vendor, product; Uint16 vendor, product;
SDL_bool enabled; SDL_bool enabled;
SDL_zero(gamepads); SDL_zero(gamepads);
@ -2491,7 +2491,7 @@ SDL_bool SDL_JoystickEventsEnabled(void)
return enabled; return enabled;
} }
void SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version, Uint16 *crc16) void SDL_GetJoystickGUIDInfo(SDL_GUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version, Uint16 *crc16)
{ {
Uint16 *guid16 = (Uint16 *)guid.data; Uint16 *guid16 = (Uint16 *)guid.data;
Uint16 bus = SDL_Swap16LE(guid16[0]); Uint16 bus = SDL_Swap16LE(guid16[0]);
@ -2708,9 +2708,9 @@ char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_n
return name; return name;
} }
SDL_JoystickGUID SDL_CreateJoystickGUID(Uint16 bus, Uint16 vendor, Uint16 product, Uint16 version, const char *vendor_name, const char *product_name, Uint8 driver_signature, Uint8 driver_data) SDL_GUID SDL_CreateJoystickGUID(Uint16 bus, Uint16 vendor, Uint16 product, Uint16 version, const char *vendor_name, const char *product_name, Uint8 driver_signature, Uint8 driver_data)
{ {
SDL_JoystickGUID guid; SDL_GUID guid;
Uint16 *guid16 = (Uint16 *)guid.data; Uint16 *guid16 = (Uint16 *)guid.data;
Uint16 crc = 0; Uint16 crc = 0;
@ -2752,33 +2752,33 @@ SDL_JoystickGUID SDL_CreateJoystickGUID(Uint16 bus, Uint16 vendor, Uint16 produc
return guid; return guid;
} }
SDL_JoystickGUID SDL_CreateJoystickGUIDForName(const char *name) SDL_GUID SDL_CreateJoystickGUIDForName(const char *name)
{ {
return SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_UNKNOWN, 0, 0, 0, NULL, name, 0, 0); return SDL_CreateJoystickGUID(SDL_HARDWARE_BUS_UNKNOWN, 0, 0, 0, NULL, name, 0, 0);
} }
void SDL_SetJoystickGUIDVendor(SDL_JoystickGUID *guid, Uint16 vendor) void SDL_SetJoystickGUIDVendor(SDL_GUID *guid, Uint16 vendor)
{ {
Uint16 *guid16 = (Uint16 *)guid->data; Uint16 *guid16 = (Uint16 *)guid->data;
guid16[2] = SDL_Swap16LE(vendor); guid16[2] = SDL_Swap16LE(vendor);
} }
void SDL_SetJoystickGUIDProduct(SDL_JoystickGUID *guid, Uint16 product) void SDL_SetJoystickGUIDProduct(SDL_GUID *guid, Uint16 product)
{ {
Uint16 *guid16 = (Uint16 *)guid->data; Uint16 *guid16 = (Uint16 *)guid->data;
guid16[4] = SDL_Swap16LE(product); guid16[4] = SDL_Swap16LE(product);
} }
void SDL_SetJoystickGUIDVersion(SDL_JoystickGUID *guid, Uint16 version) void SDL_SetJoystickGUIDVersion(SDL_GUID *guid, Uint16 version)
{ {
Uint16 *guid16 = (Uint16 *)guid->data; Uint16 *guid16 = (Uint16 *)guid->data;
guid16[6] = SDL_Swap16LE(version); guid16[6] = SDL_Swap16LE(version);
} }
void SDL_SetJoystickGUIDCRC(SDL_JoystickGUID *guid, Uint16 crc) void SDL_SetJoystickGUIDCRC(SDL_GUID *guid, Uint16 crc)
{ {
Uint16 *guid16 = (Uint16 *)guid->data; Uint16 *guid16 = (Uint16 *)guid->data;
@ -2869,7 +2869,7 @@ SDL_GamepadType SDL_GetGamepadTypeFromVIDPID(Uint16 vendor, Uint16 product, cons
return type; return type;
} }
SDL_GamepadType SDL_GetGamepadTypeFromGUID(SDL_JoystickGUID guid, const char *name) SDL_GamepadType SDL_GetGamepadTypeFromGUID(SDL_GUID guid, const char *name)
{ {
SDL_GamepadType type; SDL_GamepadType type;
Uint16 vendor, product; Uint16 vendor, product;
@ -2890,7 +2890,7 @@ SDL_GamepadType SDL_GetGamepadTypeFromGUID(SDL_JoystickGUID guid, const char *na
return type; return type;
} }
SDL_bool SDL_JoystickGUIDUsesVersion(SDL_JoystickGUID guid) SDL_bool SDL_JoystickGUIDUsesVersion(SDL_GUID guid)
{ {
Uint16 vendor, product; Uint16 vendor, product;
@ -3110,32 +3110,32 @@ SDL_bool SDL_IsJoystickSteamDeck(Uint16 vendor_id, Uint16 product_id)
return eType == k_eControllerType_SteamControllerNeptune; return eType == k_eControllerType_SteamControllerNeptune;
} }
SDL_bool SDL_IsJoystickXInput(SDL_JoystickGUID guid) SDL_bool SDL_IsJoystickXInput(SDL_GUID guid)
{ {
return (guid.data[14] == 'x') ? SDL_TRUE : SDL_FALSE; return (guid.data[14] == 'x') ? SDL_TRUE : SDL_FALSE;
} }
SDL_bool SDL_IsJoystickWGI(SDL_JoystickGUID guid) SDL_bool SDL_IsJoystickWGI(SDL_GUID guid)
{ {
return (guid.data[14] == 'w') ? SDL_TRUE : SDL_FALSE; return (guid.data[14] == 'w') ? SDL_TRUE : SDL_FALSE;
} }
SDL_bool SDL_IsJoystickHIDAPI(SDL_JoystickGUID guid) SDL_bool SDL_IsJoystickHIDAPI(SDL_GUID guid)
{ {
return (guid.data[14] == 'h') ? SDL_TRUE : SDL_FALSE; return (guid.data[14] == 'h') ? SDL_TRUE : SDL_FALSE;
} }
SDL_bool SDL_IsJoystickMFI(SDL_JoystickGUID guid) SDL_bool SDL_IsJoystickMFI(SDL_GUID guid)
{ {
return (guid.data[14] == 'm') ? SDL_TRUE : SDL_FALSE; return (guid.data[14] == 'm') ? SDL_TRUE : SDL_FALSE;
} }
SDL_bool SDL_IsJoystickRAWINPUT(SDL_JoystickGUID guid) SDL_bool SDL_IsJoystickRAWINPUT(SDL_GUID guid)
{ {
return (guid.data[14] == 'r') ? SDL_TRUE : SDL_FALSE; return (guid.data[14] == 'r') ? SDL_TRUE : SDL_FALSE;
} }
SDL_bool SDL_IsJoystickVIRTUAL(SDL_JoystickGUID guid) SDL_bool SDL_IsJoystickVIRTUAL(SDL_GUID guid)
{ {
return (guid.data[14] == 'v') ? SDL_TRUE : SDL_FALSE; return (guid.data[14] == 'v') ? SDL_TRUE : SDL_FALSE;
} }
@ -3160,7 +3160,7 @@ static SDL_bool SDL_IsJoystickThrottle(Uint16 vendor_id, Uint16 product_id)
return SDL_VIDPIDInList(vendor_id, product_id, &throttle_devices); return SDL_VIDPIDInList(vendor_id, product_id, &throttle_devices);
} }
static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_JoystickGUID guid) static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_GUID guid)
{ {
Uint16 vendor; Uint16 vendor;
Uint16 product; Uint16 product;
@ -3230,7 +3230,7 @@ static SDL_JoystickType SDL_GetJoystickGUIDType(SDL_JoystickGUID guid)
return SDL_JOYSTICK_TYPE_UNKNOWN; return SDL_JOYSTICK_TYPE_UNKNOWN;
} }
SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_JoystickGUID guid) SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_GUID guid)
{ {
Uint16 vendor; Uint16 vendor;
Uint16 product; Uint16 product;
@ -3255,11 +3255,11 @@ SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_JoystickGUID guid)
} }
/* return the guid for this index */ /* return the guid for this index */
SDL_JoystickGUID SDL_GetJoystickGUIDForID(SDL_JoystickID instance_id) SDL_GUID SDL_GetJoystickGUIDForID(SDL_JoystickID instance_id)
{ {
SDL_JoystickDriver *driver; SDL_JoystickDriver *driver;
int device_index; int device_index;
SDL_JoystickGUID guid; SDL_GUID guid;
SDL_LockJoysticks(); SDL_LockJoysticks();
if (SDL_GetDriverAndJoystickIndex(instance_id, &driver, &device_index)) { if (SDL_GetDriverAndJoystickIndex(instance_id, &driver, &device_index)) {
@ -3282,7 +3282,7 @@ Uint16 SDL_GetJoystickVendorForID(SDL_JoystickID instance_id)
if (info) { if (info) {
vendor = info->vendor_id; vendor = info->vendor_id;
} else { } else {
SDL_JoystickGUID guid = SDL_GetJoystickGUIDForID(instance_id); SDL_GUID guid = SDL_GetJoystickGUIDForID(instance_id);
SDL_GetJoystickGUIDInfo(guid, &vendor, NULL, NULL, NULL); SDL_GetJoystickGUIDInfo(guid, &vendor, NULL, NULL, NULL);
} }
@ -3301,7 +3301,7 @@ Uint16 SDL_GetJoystickProductForID(SDL_JoystickID instance_id)
if (info) { if (info) {
product = info->product_id; product = info->product_id;
} else { } else {
SDL_JoystickGUID guid = SDL_GetJoystickGUIDForID(instance_id); SDL_GUID guid = SDL_GetJoystickGUIDForID(instance_id);
SDL_GetJoystickGUIDInfo(guid, NULL, &product, NULL, NULL); SDL_GetJoystickGUIDInfo(guid, NULL, &product, NULL, NULL);
} }
@ -3313,7 +3313,7 @@ Uint16 SDL_GetJoystickProductForID(SDL_JoystickID instance_id)
Uint16 SDL_GetJoystickProductVersionForID(SDL_JoystickID instance_id) Uint16 SDL_GetJoystickProductVersionForID(SDL_JoystickID instance_id)
{ {
Uint16 version; Uint16 version;
SDL_JoystickGUID guid = SDL_GetJoystickGUIDForID(instance_id); SDL_GUID guid = SDL_GetJoystickGUIDForID(instance_id);
SDL_GetJoystickGUIDInfo(guid, NULL, NULL, &version, NULL); SDL_GetJoystickGUIDInfo(guid, NULL, NULL, &version, NULL);
return version; return version;
@ -3322,7 +3322,7 @@ Uint16 SDL_GetJoystickProductVersionForID(SDL_JoystickID instance_id)
SDL_JoystickType SDL_GetJoystickTypeForID(SDL_JoystickID instance_id) SDL_JoystickType SDL_GetJoystickTypeForID(SDL_JoystickID instance_id)
{ {
SDL_JoystickType type; SDL_JoystickType type;
SDL_JoystickGUID guid = SDL_GetJoystickGUIDForID(instance_id); SDL_GUID guid = SDL_GetJoystickGUIDForID(instance_id);
type = SDL_GetJoystickGUIDType(guid); type = SDL_GetJoystickGUIDType(guid);
if (type == SDL_JOYSTICK_TYPE_UNKNOWN) { if (type == SDL_JOYSTICK_TYPE_UNKNOWN) {
@ -3333,13 +3333,13 @@ SDL_JoystickType SDL_GetJoystickTypeForID(SDL_JoystickID instance_id)
return type; return type;
} }
SDL_JoystickGUID SDL_GetJoystickGUID(SDL_Joystick *joystick) SDL_GUID SDL_GetJoystickGUID(SDL_Joystick *joystick)
{ {
SDL_JoystickGUID retval; SDL_GUID retval;
SDL_LockJoysticks(); SDL_LockJoysticks();
{ {
static SDL_JoystickGUID emptyGUID; static SDL_GUID emptyGUID;
CHECK_JOYSTICK_MAGIC(joystick, emptyGUID); CHECK_JOYSTICK_MAGIC(joystick, emptyGUID);
@ -3363,7 +3363,7 @@ Uint16 SDL_GetJoystickVendor(SDL_Joystick *joystick)
if (info) { if (info) {
vendor = info->vendor_id; vendor = info->vendor_id;
} else { } else {
SDL_JoystickGUID guid = SDL_GetJoystickGUID(joystick); SDL_GUID guid = SDL_GetJoystickGUID(joystick);
SDL_GetJoystickGUIDInfo(guid, &vendor, NULL, NULL, NULL); SDL_GetJoystickGUIDInfo(guid, &vendor, NULL, NULL, NULL);
} }
@ -3386,7 +3386,7 @@ Uint16 SDL_GetJoystickProduct(SDL_Joystick *joystick)
if (info) { if (info) {
product = info->product_id; product = info->product_id;
} else { } else {
SDL_JoystickGUID guid = SDL_GetJoystickGUID(joystick); SDL_GUID guid = SDL_GetJoystickGUID(joystick);
SDL_GetJoystickGUIDInfo(guid, NULL, &product, NULL, NULL); SDL_GetJoystickGUIDInfo(guid, NULL, &product, NULL, NULL);
} }
@ -3399,7 +3399,7 @@ Uint16 SDL_GetJoystickProduct(SDL_Joystick *joystick)
Uint16 SDL_GetJoystickProductVersion(SDL_Joystick *joystick) Uint16 SDL_GetJoystickProductVersion(SDL_Joystick *joystick)
{ {
Uint16 version; Uint16 version;
SDL_JoystickGUID guid = SDL_GetJoystickGUID(joystick); SDL_GUID guid = SDL_GetJoystickGUID(joystick);
SDL_GetJoystickGUIDInfo(guid, NULL, NULL, &version, NULL); SDL_GetJoystickGUIDInfo(guid, NULL, NULL, &version, NULL);
return version; return version;
@ -3438,7 +3438,7 @@ const char *SDL_GetJoystickSerial(SDL_Joystick *joystick)
SDL_JoystickType SDL_GetJoystickType(SDL_Joystick *joystick) SDL_JoystickType SDL_GetJoystickType(SDL_Joystick *joystick)
{ {
SDL_JoystickType type; SDL_JoystickType type;
SDL_JoystickGUID guid = SDL_GetJoystickGUID(joystick); SDL_GUID guid = SDL_GetJoystickGUID(joystick);
type = SDL_GetJoystickGUIDType(guid); type = SDL_GetJoystickGUIDType(guid);
if (type == SDL_JOYSTICK_TYPE_UNKNOWN) { if (type == SDL_JOYSTICK_TYPE_UNKNOWN) {
@ -3455,18 +3455,6 @@ SDL_JoystickType SDL_GetJoystickType(SDL_Joystick *joystick)
return type; return type;
} }
/* convert the guid to a printable string */
int SDL_GetJoystickGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID)
{
return SDL_GUIDToString(guid, pszGUID, cbGUID);
}
/* convert the string version of a joystick guid to the struct */
SDL_JoystickGUID SDL_GetJoystickGUIDFromString(const char *pchGUID)
{
return SDL_GUIDFromString(pchGUID);
}
void SDL_SendJoystickPowerInfo(SDL_Joystick *joystick, SDL_PowerState state, int percent) void SDL_SendJoystickPowerInfo(SDL_Joystick *joystick, SDL_PowerState state, int percent)
{ {
SDL_AssertJoysticksLocked(); SDL_AssertJoysticksLocked();

View file

@ -62,29 +62,29 @@ extern SDL_bool SDL_JoystickHandledByAnotherDriver(struct SDL_JoystickDriver *dr
extern char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_name, const char *product_name); extern char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_name, const char *product_name);
/* Function to create a GUID for a joystick based on the VID/PID and name */ /* Function to create a GUID for a joystick based on the VID/PID and name */
extern SDL_JoystickGUID SDL_CreateJoystickGUID(Uint16 bus, Uint16 vendor, Uint16 product, Uint16 version, const char *vendor_name, const char *product_name, Uint8 driver_signature, Uint8 driver_data); extern SDL_GUID SDL_CreateJoystickGUID(Uint16 bus, Uint16 vendor, Uint16 product, Uint16 version, const char *vendor_name, const char *product_name, Uint8 driver_signature, Uint8 driver_data);
/* Function to create a GUID for a joystick based on the name, with no VID/PID information */ /* Function to create a GUID for a joystick based on the name, with no VID/PID information */
extern SDL_JoystickGUID SDL_CreateJoystickGUIDForName(const char *name); extern SDL_GUID SDL_CreateJoystickGUIDForName(const char *name);
/* Function to set the vendor field of a joystick GUID */ /* Function to set the vendor field of a joystick GUID */
extern void SDL_SetJoystickGUIDVendor(SDL_JoystickGUID *guid, Uint16 vendor); extern void SDL_SetJoystickGUIDVendor(SDL_GUID *guid, Uint16 vendor);
/* Function to set the product field of a joystick GUID */ /* Function to set the product field of a joystick GUID */
extern void SDL_SetJoystickGUIDProduct(SDL_JoystickGUID *guid, Uint16 product); extern void SDL_SetJoystickGUIDProduct(SDL_GUID *guid, Uint16 product);
/* Function to set the version field of a joystick GUID */ /* Function to set the version field of a joystick GUID */
extern void SDL_SetJoystickGUIDVersion(SDL_JoystickGUID *guid, Uint16 version); extern void SDL_SetJoystickGUIDVersion(SDL_GUID *guid, Uint16 version);
/* Function to set the CRC field of a joystick GUID */ /* Function to set the CRC field of a joystick GUID */
extern void SDL_SetJoystickGUIDCRC(SDL_JoystickGUID *guid, Uint16 crc); extern void SDL_SetJoystickGUIDCRC(SDL_GUID *guid, Uint16 crc);
/* Function to return the type of a controller */ /* Function to return the type of a controller */
extern SDL_GamepadType SDL_GetGamepadTypeFromVIDPID(Uint16 vendor, Uint16 product, const char *name, SDL_bool forUI); extern SDL_GamepadType SDL_GetGamepadTypeFromVIDPID(Uint16 vendor, Uint16 product, const char *name, SDL_bool forUI);
extern SDL_GamepadType SDL_GetGamepadTypeFromGUID(SDL_JoystickGUID guid, const char *name); extern SDL_GamepadType SDL_GetGamepadTypeFromGUID(SDL_GUID guid, const char *name);
/* Function to return whether a joystick GUID uses the version field */ /* Function to return whether a joystick GUID uses the version field */
extern SDL_bool SDL_JoystickGUIDUsesVersion(SDL_JoystickGUID guid); extern SDL_bool SDL_JoystickGUIDUsesVersion(SDL_GUID guid);
/* Function to return whether a joystick is an Xbox One controller */ /* Function to return whether a joystick is an Xbox One controller */
extern SDL_bool SDL_IsJoystickXboxOne(Uint16 vendor_id, Uint16 product_id); extern SDL_bool SDL_IsJoystickXboxOne(Uint16 vendor_id, Uint16 product_id);
@ -133,25 +133,25 @@ extern SDL_bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_i
extern SDL_bool SDL_IsJoystickSteamDeck(Uint16 vendor_id, Uint16 product_id); extern SDL_bool SDL_IsJoystickSteamDeck(Uint16 vendor_id, Uint16 product_id);
/* Function to return whether a joystick guid comes from the XInput driver */ /* Function to return whether a joystick guid comes from the XInput driver */
extern SDL_bool SDL_IsJoystickXInput(SDL_JoystickGUID guid); extern SDL_bool SDL_IsJoystickXInput(SDL_GUID guid);
/* Function to return whether a joystick guid comes from the WGI driver */ /* Function to return whether a joystick guid comes from the WGI driver */
extern SDL_bool SDL_IsJoystickWGI(SDL_JoystickGUID guid); extern SDL_bool SDL_IsJoystickWGI(SDL_GUID guid);
/* Function to return whether a joystick guid comes from the HIDAPI driver */ /* Function to return whether a joystick guid comes from the HIDAPI driver */
extern SDL_bool SDL_IsJoystickHIDAPI(SDL_JoystickGUID guid); extern SDL_bool SDL_IsJoystickHIDAPI(SDL_GUID guid);
/* Function to return whether a joystick guid comes from the MFI driver */ /* Function to return whether a joystick guid comes from the MFI driver */
extern SDL_bool SDL_IsJoystickMFI(SDL_JoystickGUID guid); extern SDL_bool SDL_IsJoystickMFI(SDL_GUID guid);
/* Function to return whether a joystick guid comes from the RAWINPUT driver */ /* Function to return whether a joystick guid comes from the RAWINPUT driver */
extern SDL_bool SDL_IsJoystickRAWINPUT(SDL_JoystickGUID guid); extern SDL_bool SDL_IsJoystickRAWINPUT(SDL_GUID guid);
/* Function to return whether a joystick guid comes from the Virtual driver */ /* Function to return whether a joystick guid comes from the Virtual driver */
extern SDL_bool SDL_IsJoystickVIRTUAL(SDL_JoystickGUID guid); extern SDL_bool SDL_IsJoystickVIRTUAL(SDL_GUID guid);
/* Function to return whether a joystick should be ignored */ /* Function to return whether a joystick should be ignored */
extern SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_JoystickGUID guid); extern SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_GUID guid);
/* Internal event queueing functions */ /* Internal event queueing functions */
extern void SDL_PrivateJoystickAddTouchpad(SDL_Joystick *joystick, int nfingers); extern void SDL_PrivateJoystickAddTouchpad(SDL_Joystick *joystick, int nfingers);

View file

@ -80,7 +80,7 @@ struct SDL_Joystick
char *name _guarded; /* Joystick name - system dependent */ char *name _guarded; /* Joystick name - system dependent */
char *path _guarded; /* Joystick path - system dependent */ char *path _guarded; /* Joystick path - system dependent */
char *serial _guarded; /* Joystick serial */ char *serial _guarded; /* Joystick serial */
SDL_JoystickGUID guid _guarded; /* Joystick guid */ SDL_GUID guid _guarded; /* Joystick guid */
Uint16 firmware_version _guarded; /* Firmware version, if available */ Uint16 firmware_version _guarded; /* Firmware version, if available */
Uint64 steam_handle _guarded; /* Steam controller API handle */ Uint64 steam_handle _guarded; /* Steam controller API handle */
@ -187,7 +187,7 @@ typedef struct SDL_JoystickDriver
void (*SetDevicePlayerIndex)(int device_index, int player_index); void (*SetDevicePlayerIndex)(int device_index, int player_index);
/* Function to return the stable GUID for a plugged in device */ /* Function to return the stable GUID for a plugged in device */
SDL_JoystickGUID (*GetDeviceGUID)(int device_index); SDL_GUID (*GetDeviceGUID)(int device_index);
/* Function to get the current instance id of the joystick located at device_index */ /* Function to get the current instance id of the joystick located at device_index */
SDL_JoystickID (*GetDeviceInstanceID)(int device_index); SDL_JoystickID (*GetDeviceInstanceID)(int device_index);

View file

@ -304,7 +304,7 @@ int Android_OnHat(int device_id, int hat_id, int x, int y)
int Android_AddJoystick(int device_id, const char *name, const char *desc, int vendor_id, int product_id, int button_mask, int naxes, int axis_mask, int nhats, SDL_bool can_rumble) int Android_AddJoystick(int device_id, const char *name, const char *desc, int vendor_id, int product_id, int button_mask, int naxes, int axis_mask, int nhats, SDL_bool can_rumble)
{ {
SDL_joylist_item *item; SDL_joylist_item *item;
SDL_JoystickGUID guid; SDL_GUID guid;
int i; int i;
int result = -1; int result = -1;
@ -551,7 +551,7 @@ static void ANDROID_JoystickSetDevicePlayerIndex(int device_index, int player_in
{ {
} }
static SDL_JoystickGUID ANDROID_JoystickGetDeviceGUID(int device_index) static SDL_GUID ANDROID_JoystickGetDeviceGUID(int device_index)
{ {
return GetJoystickByDevIndex(device_index)->guid; return GetJoystickByDevIndex(device_index)->guid;
} }

View file

@ -41,7 +41,7 @@ typedef struct SDL_joylist_item
int device_instance; int device_instance;
int device_id; /* Android's device id */ int device_id; /* Android's device id */
char *name; /* "SideWinder 3D Pro" or whatever */ char *name; /* "SideWinder 3D Pro" or whatever */
SDL_JoystickGUID guid; SDL_GUID guid;
SDL_Joystick *joystick; SDL_Joystick *joystick;
int nbuttons, naxes, nhats; int nbuttons, naxes, nhats;
int dpad_state; int dpad_state;

View file

@ -922,10 +922,10 @@ static void IOS_JoystickSetDevicePlayerIndex(int device_index, int player_index)
#endif #endif
} }
static SDL_JoystickGUID IOS_JoystickGetDeviceGUID(int device_index) static SDL_GUID IOS_JoystickGetDeviceGUID(int device_index)
{ {
SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index); SDL_JoystickDeviceItem *device = GetDeviceForIndex(device_index);
SDL_JoystickGUID guid; SDL_GUID guid;
if (device) { if (device) {
guid = device->guid; guid = device->guid;
} else { } else {

View file

@ -40,7 +40,7 @@ typedef struct joystick_hwdata
char *name; char *name;
SDL_Joystick *joystick; SDL_Joystick *joystick;
SDL_JoystickID instance_id; SDL_JoystickID instance_id;
SDL_JoystickGUID guid; SDL_GUID guid;
int naxes; int naxes;
int nbuttons; int nbuttons;

View file

@ -173,7 +173,7 @@ typedef struct SDL_joylist_item
SDL_JoystickID device_instance; SDL_JoystickID device_instance;
char *path; /* "/dev/uhid0" or whatever */ char *path; /* "/dev/uhid0" or whatever */
char *name; /* "SideWinder 3D Pro" or whatever */ char *name; /* "SideWinder 3D Pro" or whatever */
SDL_JoystickGUID guid; SDL_GUID guid;
dev_t devnum; dev_t devnum;
struct SDL_joylist_item *next; struct SDL_joylist_item *next;
} SDL_joylist_item; } SDL_joylist_item;
@ -393,7 +393,7 @@ static int MaybeAddDevice(const char *path)
{ {
struct stat sb; struct stat sb;
char *name = NULL; char *name = NULL;
SDL_JoystickGUID guid; SDL_GUID guid;
SDL_joylist_item *item; SDL_joylist_item *item;
struct joystick_hwdata *hw; struct joystick_hwdata *hw;
@ -556,7 +556,7 @@ static void BSD_JoystickSetDevicePlayerIndex(int device_index, int player_index)
{ {
} }
static SDL_JoystickGUID BSD_JoystickGetDeviceGUID(int device_index) static SDL_GUID BSD_JoystickGetDeviceGUID(int device_index)
{ {
return GetJoystickByDevIndex(device_index)->guid; return GetJoystickByDevIndex(device_index)->guid;
} }

View file

@ -743,10 +743,10 @@ static void DARWIN_JoystickSetDevicePlayerIndex(int device_index, int player_ind
{ {
} }
static SDL_JoystickGUID DARWIN_JoystickGetDeviceGUID(int device_index) static SDL_GUID DARWIN_JoystickGetDeviceGUID(int device_index)
{ {
recDevice *device = GetDeviceForIndex(device_index); recDevice *device = GetDeviceForIndex(device_index);
SDL_JoystickGUID guid; SDL_GUID guid;
if (device) { if (device) {
guid = device->guid; guid = device->guid;
} else { } else {

View file

@ -70,7 +70,7 @@ struct joystick_hwdata
SDL_bool runLoopAttached; /* is 'deviceRef' attached to a CFRunLoop? */ SDL_bool runLoopAttached; /* is 'deviceRef' attached to a CFRunLoop? */
int instance_id; int instance_id;
SDL_JoystickGUID guid; SDL_GUID guid;
int steam_virtual_gamepad_slot; int steam_virtual_gamepad_slot;
struct joystick_hwdata *pNext; /* next device */ struct joystick_hwdata *pNext; /* next device */

View file

@ -70,9 +70,9 @@ static void DUMMY_JoystickSetDevicePlayerIndex(int device_index, int player_inde
{ {
} }
static SDL_JoystickGUID DUMMY_JoystickGetDeviceGUID(int device_index) static SDL_GUID DUMMY_JoystickGetDeviceGUID(int device_index)
{ {
SDL_JoystickGUID guid; SDL_GUID guid;
SDL_zero(guid); SDL_zero(guid);
return guid; return guid;
} }

View file

@ -378,7 +378,7 @@ static void EMSCRIPTEN_JoystickClose(SDL_Joystick *joystick)
} }
} }
static SDL_JoystickGUID EMSCRIPTEN_JoystickGetDeviceGUID(int device_index) static SDL_GUID EMSCRIPTEN_JoystickGetDeviceGUID(int device_index)
{ {
/* the GUID is just the name for now */ /* the GUID is just the name for now */
const char *name = EMSCRIPTEN_JoystickGetDeviceName(device_index); const char *name = EMSCRIPTEN_JoystickGetDeviceName(device_index);

View file

@ -35,7 +35,7 @@ typedef struct GAMEINPUT_InternalDevice
IGameInputDevice *device; IGameInputDevice *device;
char path[(APP_LOCAL_DEVICE_ID_SIZE * 2) + 1]; char path[(APP_LOCAL_DEVICE_ID_SIZE * 2) + 1];
char *name; char *name;
SDL_JoystickGUID guid; /* generated by SDL */ SDL_GUID guid; /* generated by SDL */
SDL_JoystickID device_instance; /* generated by SDL */ SDL_JoystickID device_instance; /* generated by SDL */
const GameInputDeviceInfo *info; const GameInputDeviceInfo *info;
SDL_bool isAdded; SDL_bool isAdded;
@ -331,7 +331,7 @@ static void GAMEINPUT_JoystickSetDevicePlayerIndex(int device_index, int player_
{ {
} }
static SDL_JoystickGUID GAMEINPUT_JoystickGetDeviceGUID(int device_index) static SDL_GUID GAMEINPUT_JoystickGetDeviceGUID(int device_index)
{ {
return GAMEINPUT_InternalFindByIndex(device_index)->guid; return GAMEINPUT_InternalFindByIndex(device_index)->guid;
} }

View file

@ -255,7 +255,7 @@ extern "C"
SDL_joyname[0] = NULL; SDL_joyname[0] = NULL;
} }
static SDL_JoystickGUID HAIKU_JoystickGetDeviceGUID(int device_index) static SDL_GUID HAIKU_JoystickGetDeviceGUID(int device_index)
{ {
/* the GUID is just the name for now */ /* the GUID is just the name for now */
const char *name = HAIKU_JoystickGetDeviceName(device_index); const char *name = HAIKU_JoystickGetDeviceName(device_index);

View file

@ -1324,7 +1324,7 @@ SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 vers
return result; return result;
} }
SDL_JoystickType HIDAPI_GetJoystickTypeFromGUID(SDL_JoystickGUID guid) SDL_JoystickType HIDAPI_GetJoystickTypeFromGUID(SDL_GUID guid)
{ {
SDL_HIDAPI_Device *device; SDL_HIDAPI_Device *device;
SDL_JoystickType type = SDL_JOYSTICK_TYPE_UNKNOWN; SDL_JoystickType type = SDL_JOYSTICK_TYPE_UNKNOWN;
@ -1341,7 +1341,7 @@ SDL_JoystickType HIDAPI_GetJoystickTypeFromGUID(SDL_JoystickGUID guid)
return type; return type;
} }
SDL_GamepadType HIDAPI_GetGamepadTypeFromGUID(SDL_JoystickGUID guid) SDL_GamepadType HIDAPI_GetGamepadTypeFromGUID(SDL_GUID guid)
{ {
SDL_HIDAPI_Device *device; SDL_HIDAPI_Device *device;
SDL_GamepadType type = SDL_GAMEPAD_TYPE_STANDARD; SDL_GamepadType type = SDL_GAMEPAD_TYPE_STANDARD;
@ -1455,10 +1455,10 @@ static void HIDAPI_JoystickSetDevicePlayerIndex(int device_index, int player_ind
} }
} }
static SDL_JoystickGUID HIDAPI_JoystickGetDeviceGUID(int device_index) static SDL_GUID HIDAPI_JoystickGetDeviceGUID(int device_index)
{ {
SDL_HIDAPI_Device *device; SDL_HIDAPI_Device *device;
SDL_JoystickGUID guid; SDL_GUID guid;
device = HIDAPI_GetDeviceByIndex(device_index, NULL); device = HIDAPI_GetDeviceByIndex(device_index, NULL);
if (device) { if (device) {

View file

@ -74,7 +74,7 @@ typedef struct SDL_HIDAPI_Device
Uint16 product_id; Uint16 product_id;
Uint16 version; Uint16 version;
char *serial; char *serial;
SDL_JoystickGUID guid; SDL_GUID guid;
int interface_number; /* Available on Windows and Linux */ int interface_number; /* Available on Windows and Linux */
int interface_class; int interface_class;
int interface_subclass; int interface_subclass;
@ -158,10 +158,10 @@ extern SDL_bool HIDAPI_IsDeviceTypePresent(SDL_GamepadType type);
extern SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name); extern SDL_bool HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name);
/* Return the type of a joystick if it's present and supported */ /* Return the type of a joystick if it's present and supported */
extern SDL_JoystickType HIDAPI_GetJoystickTypeFromGUID(SDL_JoystickGUID guid); extern SDL_JoystickType HIDAPI_GetJoystickTypeFromGUID(SDL_GUID guid);
/* Return the type of a game controller if it's present and supported */ /* Return the type of a game controller if it's present and supported */
extern SDL_GamepadType HIDAPI_GetGamepadTypeFromGUID(SDL_JoystickGUID guid); extern SDL_GamepadType HIDAPI_GetGamepadTypeFromGUID(SDL_GUID guid);
extern void HIDAPI_UpdateDevices(void); extern void HIDAPI_UpdateDevices(void);
extern void HIDAPI_SetDeviceName(SDL_HIDAPI_Device *device, const char *name); extern void HIDAPI_SetDeviceName(SDL_HIDAPI_Device *device, const char *name);

View file

@ -153,7 +153,7 @@ typedef struct SDL_joylist_item
SDL_JoystickID device_instance; SDL_JoystickID device_instance;
char *path; /* "/dev/input/event2" or whatever */ char *path; /* "/dev/input/event2" or whatever */
char *name; /* "SideWinder 3D Pro" or whatever */ char *name; /* "SideWinder 3D Pro" or whatever */
SDL_JoystickGUID guid; SDL_GUID guid;
dev_t devnum; dev_t devnum;
int steam_virtual_gamepad_slot; int steam_virtual_gamepad_slot;
struct joystick_hwdata *hwdata; struct joystick_hwdata *hwdata;
@ -276,7 +276,7 @@ static int GuessIsSensor(int fd)
return 0; return 0;
} }
static int IsJoystick(const char *path, int *fd, char **name_return, Uint16 *vendor_return, Uint16 *product_return, SDL_JoystickGUID *guid) static int IsJoystick(const char *path, int *fd, char **name_return, Uint16 *vendor_return, Uint16 *product_return, SDL_GUID *guid)
{ {
struct input_id inpid; struct input_id inpid;
char *name; char *name;
@ -440,7 +440,7 @@ static void MaybeAddDevice(const char *path)
int fd = -1; int fd = -1;
char *name = NULL; char *name = NULL;
Uint16 vendor, product; Uint16 vendor, product;
SDL_JoystickGUID guid; SDL_GUID guid;
SDL_joylist_item *item; SDL_joylist_item *item;
SDL_sensorlist_item *item_sensor; SDL_sensorlist_item *item_sensor;
@ -663,7 +663,7 @@ static void HandlePendingRemovals(void)
} }
} }
static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_JoystickGUID guid, SDL_JoystickID *device_instance) static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_GUID guid, SDL_JoystickID *device_instance)
{ {
SDL_joylist_item *item; SDL_joylist_item *item;
@ -1186,7 +1186,7 @@ static void LINUX_JoystickSetDevicePlayerIndex(int device_index, int player_inde
{ {
} }
static SDL_JoystickGUID LINUX_JoystickGetDeviceGUID(int device_index) static SDL_GUID LINUX_JoystickGetDeviceGUID(int device_index)
{ {
return GetJoystickByDevIndex(device_index)->guid; return GetJoystickByDevIndex(device_index)->guid;
} }

View file

@ -35,7 +35,7 @@ struct joystick_hwdata
int fd_sensor; int fd_sensor;
struct SDL_joylist_item *item; struct SDL_joylist_item *item;
struct SDL_sensorlist_item *item_sensor; struct SDL_sensorlist_item *item_sensor;
SDL_JoystickGUID guid; SDL_GUID guid;
char *fname; /* Used in haptic subsystem */ char *fname; /* Used in haptic subsystem */
SDL_bool ff_rumble; SDL_bool ff_rumble;

View file

@ -76,9 +76,9 @@ static int N3DS_JoystickGetCount(void)
return 1; return 1;
} }
static SDL_JoystickGUID N3DS_JoystickGetDeviceGUID(int device_index) static SDL_GUID N3DS_JoystickGetDeviceGUID(int device_index)
{ {
SDL_JoystickGUID guid = SDL_CreateJoystickGUIDForName("Nintendo 3DS"); SDL_GUID guid = SDL_CreateJoystickGUIDForName("Nintendo 3DS");
return guid; return guid;
} }

View file

@ -182,7 +182,7 @@ static void PS2_JoystickSetDevicePlayerIndex(int device_index, int player_index)
} }
/* Function to return the stable GUID for a plugged in device */ /* Function to return the stable GUID for a plugged in device */
static SDL_JoystickGUID PS2_JoystickGetDeviceGUID(int device_index) static SDL_GUID PS2_JoystickGetDeviceGUID(int device_index)
{ {
/* the GUID is just the name for now */ /* the GUID is just the name for now */
const char *name = PS2_JoystickGetDeviceName(device_index); const char *name = PS2_JoystickGetDeviceName(device_index);

View file

@ -137,7 +137,7 @@ static void PSP_JoystickSetDevicePlayerIndex(int device_index, int player_index)
{ {
} }
static SDL_JoystickGUID PSP_JoystickGetDeviceGUID(int device_index) static SDL_GUID PSP_JoystickGetDeviceGUID(int device_index)
{ {
/* the GUID is just the name for now */ /* the GUID is just the name for now */
const char *name = PSP_JoystickGetDeviceName(device_index); const char *name = PSP_JoystickGetDeviceName(device_index);

View file

@ -24,7 +24,7 @@
#include "SDL_internal.h" #include "SDL_internal.h"
typedef SDL_bool (*SteamControllerConnectedCallback_t)(const char *name, SDL_JoystickGUID guid, SDL_JoystickID *device_instance); typedef SDL_bool (*SteamControllerConnectedCallback_t)(const char *name, SDL_GUID guid, SDL_JoystickID *device_instance);
typedef void (*SteamControllerDisconnectedCallback_t)(SDL_JoystickID device_instance); typedef void (*SteamControllerDisconnectedCallback_t)(SDL_JoystickID device_instance);
void SDL_InitSteamControllers(SteamControllerConnectedCallback_t connectedCallback, void SDL_InitSteamControllers(SteamControllerConnectedCallback_t connectedCallback,

View file

@ -534,11 +534,11 @@ static void VIRTUAL_JoystickSetDevicePlayerIndex(int device_index, int player_in
} }
} }
static SDL_JoystickGUID VIRTUAL_JoystickGetDeviceGUID(int device_index) static SDL_GUID VIRTUAL_JoystickGetDeviceGUID(int device_index)
{ {
joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index);
if (!hwdata) { if (!hwdata) {
SDL_JoystickGUID guid; SDL_GUID guid;
SDL_zero(guid); SDL_zero(guid);
return guid; return guid;
} }

View file

@ -50,7 +50,7 @@ typedef struct joystick_hwdata
SDL_bool attached; SDL_bool attached;
char *name; char *name;
SDL_JoystickType type; SDL_JoystickType type;
SDL_JoystickGUID guid; SDL_GUID guid;
SDL_VirtualJoystickDesc desc; SDL_VirtualJoystickDesc desc;
Uint32 changes; Uint32 changes;
Sint16 *axes; Sint16 *axes;

View file

@ -318,7 +318,7 @@ static void VITA_JoystickQuit(void)
{ {
} }
static SDL_JoystickGUID VITA_JoystickGetDeviceGUID(int device_index) static SDL_GUID VITA_JoystickGetDeviceGUID(int device_index)
{ {
/* the GUID is just the name for now */ /* the GUID is just the name for now */
const char *name = VITA_JoystickGetDeviceName(device_index); const char *name = VITA_JoystickGetDeviceName(device_index);

View file

@ -111,7 +111,7 @@ typedef struct SDL_RAWINPUT_Device
Uint16 vendor_id; Uint16 vendor_id;
Uint16 product_id; Uint16 product_id;
Uint16 version; Uint16 version;
SDL_JoystickGUID guid; SDL_GUID guid;
SDL_bool is_xinput; SDL_bool is_xinput;
SDL_bool is_xboxone; SDL_bool is_xboxone;
int steam_virtual_gamepad_slot; int steam_virtual_gamepad_slot;
@ -1215,7 +1215,7 @@ static void RAWINPUT_JoystickSetDevicePlayerIndex(int device_index, int player_i
{ {
} }
static SDL_JoystickGUID RAWINPUT_JoystickGetDeviceGUID(int device_index) static SDL_GUID RAWINPUT_JoystickGetDeviceGUID(int device_index)
{ {
return RAWINPUT_GetDeviceByIndex(device_index)->guid; return RAWINPUT_GetDeviceByIndex(device_index)->guid;
} }

View file

@ -56,7 +56,7 @@ typedef struct WindowsGamingInputControllerState
SDL_JoystickID instance_id; SDL_JoystickID instance_id;
__x_ABI_CWindows_CGaming_CInput_CIRawGameController *controller; __x_ABI_CWindows_CGaming_CInput_CIRawGameController *controller;
char *name; char *name;
SDL_JoystickGUID guid; SDL_GUID guid;
SDL_JoystickType type; SDL_JoystickType type;
int steam_virtual_gamepad_slot; int steam_virtual_gamepad_slot;
} WindowsGamingInputControllerState; } WindowsGamingInputControllerState;
@ -400,7 +400,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde
hr = __x_ABI_CWindows_CGaming_CInput_CIRawGameController_QueryInterface(e, &IID___x_ABI_CWindows_CGaming_CInput_CIRawGameController, (void **)&controller); hr = __x_ABI_CWindows_CGaming_CInput_CIRawGameController_QueryInterface(e, &IID___x_ABI_CWindows_CGaming_CInput_CIRawGameController, (void **)&controller);
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
char *name = NULL; char *name = NULL;
SDL_JoystickGUID guid = { 0 }; SDL_GUID guid = { 0 };
Uint16 bus = SDL_HARDWARE_BUS_USB; Uint16 bus = SDL_HARDWARE_BUS_USB;
Uint16 vendor = 0; Uint16 vendor = 0;
Uint16 product = 0; Uint16 product = 0;
@ -703,7 +703,7 @@ static void WGI_JoystickSetDevicePlayerIndex(int device_index, int player_index)
{ {
} }
static SDL_JoystickGUID WGI_JoystickGetDeviceGUID(int device_index) static SDL_GUID WGI_JoystickGetDeviceGUID(int device_index)
{ {
return wgi.controllers[device_index].guid; return wgi.controllers[device_index].guid;
} }

View file

@ -522,7 +522,7 @@ static void WINDOWS_JoystickSetDevicePlayerIndex(int device_index, int player_in
} }
/* return the stable device guid for this device index */ /* return the stable device guid for this device index */
static SDL_JoystickGUID WINDOWS_JoystickGetDeviceGUID(int device_index) static SDL_GUID WINDOWS_JoystickGetDeviceGUID(int device_index)
{ {
JoyStick_DeviceData *device = SYS_Joystick; JoyStick_DeviceData *device = SYS_Joystick;
int index; int index;

View file

@ -33,7 +33,7 @@ extern "C" {
typedef struct JoyStick_DeviceData typedef struct JoyStick_DeviceData
{ {
SDL_JoystickGUID guid; SDL_GUID guid;
char *joystickname; char *joystickname;
Uint8 send_add_event; Uint8 send_add_event;
SDL_JoystickID nInstanceID; SDL_JoystickID nInstanceID;
@ -70,7 +70,7 @@ typedef struct input_t
/* The private structure used to keep track of a joystick */ /* The private structure used to keep track of a joystick */
struct joystick_hwdata struct joystick_hwdata
{ {
SDL_JoystickGUID guid; SDL_GUID guid;
#ifdef SDL_JOYSTICK_DINPUT #ifdef SDL_JOYSTICK_DINPUT
LPDIRECTINPUTDEVICE8 InputDevice; LPDIRECTINPUTDEVICE8 InputDevice;

View file

@ -106,40 +106,14 @@ TestGuidToString(void *arg)
SDLTest_AssertPass("Call to SDL_GUIDToString"); SDLTest_AssertPass("Call to SDL_GUIDToString");
for (i = 0; i < NUM_TEST_GUIDS; ++i) { for (i = 0; i < NUM_TEST_GUIDS; ++i) {
const int guid_str_offset = 4; const char *guid_str;
char guid_str_buf[64];
char *guid_str = guid_str_buf + guid_str_offset;
SDL_GUID guid; SDL_GUID guid;
int size;
upper_lower_to_bytestring(guid.data, upper_lower_to_bytestring(guid.data,
test_guids[i].upper, test_guids[i].lower); test_guids[i].upper, test_guids[i].lower);
/* Serialise to limited-length buffers */ guid_str = SDL_GUIDToString(guid);
for (size = 0; size <= 36; ++size) { SDLTest_AssertCheck(SDL_strcmp(guid_str, test_guids[i].str) == 0, "Checking whether strings match, expected %s, got %s\n", test_guids[i].str, guid_str);
const Uint8 fill_char = (Uint8)(size + 0xa0);
Uint32 expected_prefix;
Uint32 actual_prefix;
int written_size;
SDL_memset(guid_str_buf, fill_char, sizeof(guid_str_buf));
SDL_GUIDToString(guid, guid_str, size);
/* Check bytes before guid_str_buf */
expected_prefix = fill_char | (fill_char << 8) | (fill_char << 16) | (((Uint32)fill_char) << 24);
SDL_memcpy(&actual_prefix, guid_str_buf, 4);
SDLTest_AssertCheck(expected_prefix == actual_prefix, "String buffer memory before output untouched, expected: %" SDL_PRIu32 ", got: %" SDL_PRIu32 ", at size=%d", expected_prefix, actual_prefix, size);
/* Check that we did not overwrite too much */
written_size = 0;
while ((guid_str[written_size] & 0xff) != fill_char && written_size < 256) {
++written_size;
}
SDLTest_AssertCheck(written_size <= size, "Output length is within expected bounds, with length %d: wrote %d of %d permitted bytes", size, written_size, size);
if (size >= 33) {
SDLTest_AssertCheck(SDL_strcmp(guid_str, test_guids[i].str) == 0, "GUID string equality, from string: %s", test_guids[i].str);
}
}
} }
return TEST_COMPLETED; return TEST_COMPLETED;

View file

@ -918,9 +918,9 @@ static void AddController(SDL_JoystickID id, SDL_bool verbose)
if (verbose && !SDL_IsGamepad(id)) { if (verbose && !SDL_IsGamepad(id)) {
const char *name = SDL_GetJoystickName(joystick); const char *name = SDL_GetJoystickName(joystick);
const char *path = SDL_GetJoystickPath(joystick); const char *path = SDL_GetJoystickPath(joystick);
char guid[33]; const char *guid;
SDL_Log("Opened joystick %s%s%s\n", name, path ? ", " : "", path ? path : ""); SDL_Log("Opened joystick %s%s%s\n", name, path ? ", " : "", path ? path : "");
SDL_GetJoystickGUIDString(SDL_GetJoystickGUID(joystick), guid, sizeof(guid)); guid = SDL_GUIDToString(SDL_GetJoystickGUID(joystick));
SDL_Log("No gamepad mapping for %s\n", guid); SDL_Log("No gamepad mapping for %s\n", guid);
} }
} else { } else {

View file

@ -222,7 +222,7 @@ static void dump_state(void)
for (i = 0; i < pens_nr; ++i) { for (i = 0; i < pens_nr; ++i) {
SDL_PenID penid = pens[i]; SDL_PenID penid = pens[i];
SDL_GUID guid = SDL_GetPenGUID(penid); SDL_GUID guid = SDL_GetPenGUID(penid);
char guid_str[33]; const char *guid_str;
float axes[SDL_PEN_NUM_AXES]; float axes[SDL_PEN_NUM_AXES];
float x, y; float x, y;
int k; int k;
@ -232,7 +232,7 @@ static void dump_state(void)
char *type; char *type;
char *buttons_str; char *buttons_str;
SDL_GUIDToString(guid, guid_str, 33); guid_str = SDL_GUIDToString(guid);
switch (SDL_GetPenType(penid)) { switch (SDL_GetPenType(penid)) {
case SDL_PEN_TYPE_ERASER: case SDL_PEN_TYPE_ERASER: