Improve sensor detection for Linux gamepad

This commit is contained in:
meyraud705 2023-05-13 18:25:45 +02:00 committed by Sam Lantinga
parent 000277060c
commit 9cfac88054
4 changed files with 55 additions and 15 deletions

View file

@ -48,3 +48,16 @@ int SDL_powerof2(int x)
return value;
}
SDL_bool SDL_endswith(const char *string, const char *suffix)
{
size_t string_length = string ? SDL_strlen(string) : 0;
size_t suffix_length = suffix ? SDL_strlen(suffix) : 0;
if (suffix_length > 0 && suffix_length <= string_length) {
if (SDL_memcmp(string + string_length - suffix_length, suffix, suffix_length) == 0) {
return SDL_TRUE;
}
}
return SDL_FALSE;
}