Added generic xinput fallback for XBox compatible controllers on Linux

This commit is contained in:
Sam Lantinga 2015-05-13 22:37:26 -07:00
parent 06fe127036
commit 1cbf83b0c0
2 changed files with 18 additions and 11 deletions

View file

@ -259,22 +259,29 @@ ControllerMapping_t *SDL_PrivateGetControllerMappingForGUID(SDL_JoystickGUID *gu
*/
ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index)
{
SDL_JoystickGUID jGUID = SDL_JoystickGetDeviceGUID(device_index);
ControllerMapping_t *mapping;
mapping = SDL_PrivateGetControllerMappingForGUID(&jGUID);
#if SDL_JOYSTICK_XINPUT
if (SDL_SYS_IsXInputGamepad_DeviceIndex(device_index) && s_pXInputMapping) {
return s_pXInputMapping;
if (!mapping && SDL_SYS_IsXInputGamepad_DeviceIndex(device_index)) {
mapping = s_pXInputMapping;
}
else
#endif
#if defined(SDL_JOYSTICK_EMSCRIPTEN)
if (s_pEmscriptenMapping) {
return s_pEmscriptenMapping;
if (!mapping && s_pEmscriptenMapping) {
mapping = s_pEmscriptenMapping;
}
else
#endif
{
SDL_JoystickGUID jGUID = SDL_JoystickGetDeviceGUID(device_index);
return SDL_PrivateGetControllerMappingForGUID(&jGUID);
if (!mapping) {
const char *name = SDL_JoystickNameForIndex(device_index);
if (name) {
if (SDL_strstr(name, "Xbox") || SDL_strstr(name, "X-Box")) {
mapping = s_pXInputMapping;
}
}
}
return mapping;
}
static const char* map_StringForControllerAxis[] = {