Use the real controller name for game controllers on iOS and Apple TV
authorSam Lantinga <slouken@libsdl.org>
Fri, 02 Mar 2018 10:56:21 -0800
changeset 11916e85247c4a60b
parent 11915 b8c894792946
child 11917 5ce3f8bf8381
Use the real controller name for game controllers on iOS and Apple TV
src/joystick/SDL_gamecontroller.c
src/joystick/SDL_gamecontrollerdb.h
     1.1 --- a/src/joystick/SDL_gamecontroller.c	Thu Mar 01 09:32:53 2018 -0800
     1.2 +++ b/src/joystick/SDL_gamecontroller.c	Fri Mar 02 10:56:21 2018 -0800
     1.3 @@ -1263,7 +1263,11 @@
     1.4  {
     1.5      ControllerMapping_t *pSupportedController = SDL_PrivateGetControllerMapping(device_index);
     1.6      if (pSupportedController) {
     1.7 -        return pSupportedController->name;
     1.8 +        if (SDL_strcmp(pSupportedController->name, "*") == 0) {
     1.9 +            return SDL_JoystickNameForIndex(device_index);
    1.10 +        } else {
    1.11 +            return pSupportedController->name;
    1.12 +        }
    1.13      }
    1.14      return NULL;
    1.15  }
    1.16 @@ -1552,7 +1556,11 @@
    1.17      if (!gamecontroller)
    1.18          return NULL;
    1.19  
    1.20 -    return gamecontroller->name;
    1.21 +    if (SDL_strcmp(gamecontroller->name, "*") == 0) {
    1.22 +        return SDL_JoystickName(SDL_GameControllerGetJoystick(gamecontroller));
    1.23 +    } else {
    1.24 +        return gamecontroller->name;
    1.25 +    }
    1.26  }
    1.27  
    1.28  Uint16
     2.1 --- a/src/joystick/SDL_gamecontrollerdb.h	Thu Mar 01 09:32:53 2018 -0800
     2.2 +++ b/src/joystick/SDL_gamecontrollerdb.h	Fri Mar 02 10:56:21 2018 -0800
     2.3 @@ -218,8 +218,8 @@
     2.4      "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,",
     2.5  #endif
     2.6  #if defined(SDL_JOYSTICK_MFI)
     2.7 -    "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,",
     2.8 -    "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,",
     2.9 +    "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,",
    2.10 +    "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,",
    2.11      "4d466947616d65706164030000000000,Remote,a:b0,b:b2,leftx:a0,lefty:a1,",
    2.12      "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,",
    2.13  #endif