Added SDL_GetGamepadInstanceID()

main
Sam Lantinga 2023-07-10 19:13:42 -07:00
parent 50277a0355
commit 3cbf16b944
5 changed files with 27 additions and 0 deletions

View File

@ -476,6 +476,20 @@ extern DECLSPEC SDL_Gamepad *SDLCALL SDL_GetGamepadFromInstanceID(SDL_JoystickID
*/
extern DECLSPEC SDL_Gamepad *SDLCALL SDL_GetGamepadFromPlayerIndex(int player_index);
/**
* Get the instance ID of an opened gamepad.
*
* \param gamepad a gamepad identifier previously returned by
* SDL_OpenGamepad()
* \returns the instance ID of the specified gamepad on success or 0 on
* failure; call SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_OpenGamepad
*/
extern DECLSPEC SDL_JoystickID SDLCALL SDL_GetGamepadInstanceID(SDL_Gamepad *gamepad);
/**
* Get the implementation-dependent name for an opened gamepad.
*

View File

@ -869,6 +869,7 @@ SDL3_0.0.0 {
SDL_wcsstr;
SDL_wcstol;
SDL_ClearClipboardData;
SDL_GetGamepadInstanceID;
# extra symbols go here (don't modify this line)
local: *;
};

View File

@ -895,3 +895,4 @@
/* New API symbols are added at the end */
#define SDL_ClearClipboardData SDL_ClearClipboardData_REAL
#define SDL_GetGamepadInstanceID SDL_GetGamepadInstanceID_REAL

View File

@ -940,3 +940,4 @@ SDL_DYNAPI_PROC(long,SDL_wcstol,(const wchar_t *a, wchar_t **b, int c),(a,b,c),r
/* New API symbols are added at the end */
SDL_DYNAPI_PROC(int,SDL_ClearClipboardData,(void),(),return)
SDL_DYNAPI_PROC(SDL_JoystickID,SDL_GetGamepadInstanceID,(SDL_Gamepad *a),(a),return)

View File

@ -2655,6 +2655,16 @@ int SDL_GetGamepadSensorData(SDL_Gamepad *gamepad, SDL_SensorType type, float *d
return SDL_Unsupported();
}
SDL_JoystickID SDL_GetGamepadInstanceID(SDL_Gamepad *gamepad)
{
SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad);
if (joystick == NULL) {
return 0;
}
return SDL_GetJoystickInstanceID(joystick);
}
const char *SDL_GetGamepadName(SDL_Gamepad *gamepad)
{
const char *retval = NULL;