Procházet zdrojové kódy

fix SDL SetGamepadMappings (#5548)

pull/5551/head
Yui Kinomoto / きのもと 結衣 před 1 týdnem
odevzdal GitHub
rodič
revize
4e7c38ac43
V databázi nebyl nalezen žádný známý klíč pro tento podpis ID GPG klíče: B5690EEEBB952194
1 změnil soubory, kde provedl 19 přidání a 1 odebrání
  1. +19
    -1
      src/platforms/rcore_desktop_sdl.c

+ 19
- 1
src/platforms/rcore_desktop_sdl.c Zobrazit soubor

@ -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

Načítá se…
Zrušit
Uložit