Use the real controller name for game controllers on iOS and Apple TV

This commit is contained in:
Sam Lantinga 2018-03-02 10:56:21 -08:00
parent 4f695bc5e5
commit 003c0dce9c
2 changed files with 12 additions and 4 deletions

View File

@ -1263,8 +1263,12 @@ SDL_GameControllerNameForIndex(int device_index)
{
ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index);
if (pSupportedController) {
if (SDL_strcmp(pSupportedController->name, "*") == 0) {
return SDL_JoystickNameForIndex(device_index);
} else {
return pSupportedController->name;
}
}
return NULL;
}
@ -1552,8 +1556,12 @@ SDL_GameControllerName(SDL_GameController * gamecontroller)
if (!gamecontroller)
return NULL;
if (SDL_strcmp(gamecontroller->name, "*") == 0) {
return SDL_JoystickName(SDL_GameControllerGetJoystick(gamecontroller));
} else {
return gamecontroller->name;
}
}
Uint16
SDL_GameControllerGetVendor(SDL_GameController * gamecontroller)

View File

@ -218,8 +218,8 @@ static const char *s_ControllerMappings [] =
"34356136633366613530316338376136,Xbox Wireless Controller,a:b0,b:b1,back:b9,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b3,leftstick:b15,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b18,rightstick:b16,righttrigger:a5,rightx:a3,righty:a4,x:b17,y:b2,",
#endif
#if defined(SDL_JOYSTICK_MFI)
"4d466947616d65706164010000000000,MFi Extended Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,",
"4d466947616d65706164020000000000,MFi Gamepad,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b6,x:b2,y:b3,",
"4d466947616d65706164010000000000,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a5,rightx:a3,righty:a4,start:b6,x:b2,y:b3,",
"4d466947616d65706164020000000000,*,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,rightshoulder:b5,start:b6,x:b2,y:b3,",
"4d466947616d65706164030000000000,Remote,a:b0,b:b2,leftx:a0,lefty:a1,",
"05000000de2800000511000001000000,Steam Controller,a:b0,b:b1,back:b6,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,righttrigger:a3,start:b7,x:b2,y:b3,",
#endif