소스 검색

fix SDL SetGamepadMappings

pull/5548/head
あるる / きのもと 結衣 2 주 전
부모
커밋
d4c89b9626
1개의 변경된 파일19개의 추가작업 그리고 1개의 파일을 삭제
  1. +19
    -1
      src/platforms/rcore_desktop_sdl.c

+ 19
- 1
src/platforms/rcore_desktop_sdl.c 파일 보기

@ -1287,7 +1287,25 @@ void OpenURL(const char *url)
// Set internal gamepad 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

불러오는 중...
취소
저장