Skip to content
Permalink
Browse files

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

  • Loading branch information
slouken committed Mar 2, 2018
1 parent 4f695bc commit 003c0dce9c30f2783466ed83b8244d56f9cf70c3
Showing with 12 additions and 4 deletions.
  1. +10 −2 src/joystick/SDL_gamecontroller.c
  2. +2 −2 src/joystick/SDL_gamecontrollerdb.h
@@ -1263,7 +1263,11 @@ SDL_GameControllerNameForIndex(int device_index)
{
ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index);
if (pSupportedController) {
return pSupportedController->name;
if (SDL_strcmp(pSupportedController->name, "*") == 0) {
return SDL_JoystickNameForIndex(device_index);
} else {
return pSupportedController->name;
}
}
return NULL;
}
@@ -1552,7 +1556,11 @@ SDL_GameControllerName(SDL_GameController * gamecontroller)
if (!gamecontroller)
return NULL;

return gamecontroller->name;
if (SDL_strcmp(gamecontroller->name, "*") == 0) {
return SDL_JoystickName(SDL_GameControllerGetJoystick(gamecontroller));
} else {
return gamecontroller->name;
}
}

Uint16
@@ -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

0 comments on commit 003c0dc

Please sign in to comment.