Fixed picking up the correct mapping for virtual controllers on Android

Fixes https://github.com/libsdl-org/SDL/issues/5662
This commit is contained in:
Sam Lantinga 2022-05-18 23:48:15 -07:00
parent f7b774a7e0
commit 47f1cb550d
3 changed files with 14 additions and 16 deletions

View file

@ -696,19 +696,20 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickG
return s_pXInputMapping;
}
#endif
if (!mapping) {
if (SDL_IsJoystickHIDAPI(guid)) {
mapping = SDL_CreateMappingForHIDAPIController(guid);
} else if (SDL_IsJoystickRAWINPUT(guid)) {
mapping = SDL_CreateMappingForRAWINPUTController(guid);
} else if (SDL_IsJoystickWGI(guid)) {
mapping = SDL_CreateMappingForWGIController(guid);
} else if (SDL_IsJoystickVirtual(guid)) {
/* We'll pick up a robust mapping in VIRTUAL_JoystickGetGamepadMapping */
#ifdef __ANDROID__
if (!mapping && !SDL_IsJoystickHIDAPI(guid)) {
mapping = SDL_CreateMappingForAndroidController(guid);
}
} else {
mapping = SDL_CreateMappingForAndroidController(guid);
#endif
if (!mapping && SDL_IsJoystickHIDAPI(guid)) {
mapping = SDL_CreateMappingForHIDAPIController(guid);
}
if (!mapping && SDL_IsJoystickRAWINPUT(guid)) {
mapping = SDL_CreateMappingForRAWINPUTController(guid);
}
if (!mapping && SDL_IsJoystickWGI(guid)) {
mapping = SDL_CreateMappingForWGIController(guid);
}
}
}
return mapping;