Skip to content

Commit

Permalink
Add GetGamepadGUID for PLATFORM_DESKTOP_SDL
Browse files Browse the repository at this point in the history
  • Loading branch information
asdqwe committed Jan 27, 2025
1 parent 3f52463 commit b4667ef
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/platforms/rcore_desktop_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
#define MAX_CLIPBOARD_BUFFER_LENGTH 1024 // Size of the clipboard buffer used on GetClipboardText()
#endif

#ifndef MAX_JOYSTICKGUID_BUFFER_LENGTH
#define MAX_JOYSTICKGUID_BUFFER_LENGTH 64 // Size of the joystick GUID buffer used on GetGamepadGUID(), must be at least 33 bytes
#endif

#if ((defined(SDL_MAJOR_VERSION) && (SDL_MAJOR_VERSION == 3)) && (defined(SDL_MINOR_VERSION) && (SDL_MINOR_VERSION >= 1)))
#ifndef PLATFORM_DESKTOP_SDL3
#define PLATFORM_DESKTOP_SDL3
Expand Down Expand Up @@ -1239,8 +1243,13 @@ int SetGamepadMappings(const char *mappings)
// Get gamepad GUID
const char *GetGamepadGUID(int gamepad)
{
TRACELOG(LOG_WARNING, "GetGamepadGUID() not implemented on target platform");
return "";
static char buffer[MAX_JOYSTICKGUID_BUFFER_LENGTH] = { 0 };

SDL_JoystickGUID joystickGUID = SDL_JoystickGetGUID(SDL_GameControllerGetJoystick(platform.gamepad[0]));

SDL_JoystickGetGUIDString(joystickGUID, buffer, MAX_JOYSTICKGUID_BUFFER_LENGTH -1);

return buffer;
}

// Set gamepad vibration
Expand Down

0 comments on commit b4667ef

Please sign in to comment.