mirror of
https://github.com/raysan5/raylib.git
synced 2026-02-15 02:09:17 -05:00
fix SDL SetGamepadMappings (#5548)
This commit is contained in:
committed by
GitHub
parent
85de580527
commit
4e7c38ac43
@ -1287,7 +1287,25 @@ void OpenURL(const char *url)
|
|||||||
// Set internal gamepad mappings
|
// Set internal gamepad mappings
|
||||||
int SetGamepadMappings(const char *mappings)
|
int SetGamepadMappings(const char *mappings)
|
||||||
{
|
{
|
||||||
return SDL_GameControllerAddMapping(mappings);
|
const int mappingsLength = strlen(mappings);
|
||||||
|
char *buffer = (char *)RL_CALLOC(mappingsLength + 1, sizeof(char));
|
||||||
|
memcpy(buffer, mappings, mappingsLength);
|
||||||
|
char *p = strtok(buffer, "\n");
|
||||||
|
bool succeed = true;
|
||||||
|
|
||||||
|
while (p != NULL)
|
||||||
|
{
|
||||||
|
if (SDL_GameControllerAddMapping(p) == -1)
|
||||||
|
{
|
||||||
|
succeed = false;
|
||||||
|
}
|
||||||
|
p = strtok(NULL, "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
RL_FREE(buffer);
|
||||||
|
|
||||||
|
// To make return value is consistent with the GLFW version.
|
||||||
|
return (succeed)? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set gamepad vibration
|
// Set gamepad vibration
|
||||||
|
|||||||
Reference in New Issue
Block a user