src/joystick/iphoneos/SDL_sysjoystick.m
changeset 13318 2b9626c9304a
parent 12939 68977584a5d9
child 13319 580cc3860ac3
     1.1 --- a/src/joystick/iphoneos/SDL_sysjoystick.m	Thu Dec 05 17:27:06 2019 -0500
     1.2 +++ b/src/joystick/iphoneos/SDL_sysjoystick.m	Fri Dec 06 13:48:10 2019 -0800
     1.3 @@ -129,6 +129,9 @@
     1.4  
     1.5      if (controller.extendedGamepad) {
     1.6          GCExtendedGamepad *gamepad = controller.extendedGamepad;
     1.7 +        BOOL is_xbox = [controller.vendorName containsString: @"Xbox"];
     1.8 +        BOOL is_ps4 = [controller.vendorName containsString: @"DUALSHOCK"];
     1.9 +        BOOL is_MFi = (!is_xbox && !is_ps4);
    1.10          int nbuttons = 0;
    1.11  
    1.12          /* These buttons are part of the original MFi spec */
    1.13 @@ -155,20 +158,24 @@
    1.14              device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_BACK);
    1.15              ++nbuttons;
    1.16          }
    1.17 -        if ([gamepad respondsToSelector:@selector(buttonMenu)] && gamepad.buttonMenu) {
    1.18 -            device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_START);
    1.19 -            ++nbuttons;
    1.20 -        } else {
    1.21 -            device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_START);
    1.22 -            ++nbuttons;
    1.23 +        BOOL has_direct_menu = [gamepad respondsToSelector:@selector(buttonMenu)] && gamepad.buttonMenu;
    1.24 +#if TARGET_OS_TV
    1.25 +        /* On tvOS MFi controller menu button brings you to the home screen */
    1.26 +        if (is_MFi) {
    1.27 +            has_direct_menu = FALSE;
    1.28 +        }
    1.29 +#endif
    1.30 +        device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_START);
    1.31 +        ++nbuttons;
    1.32 +        if (!has_direct_menu) {
    1.33              device->uses_pause_handler = SDL_TRUE;
    1.34          }
    1.35  #pragma clang diagnostic pop
    1.36  
    1.37 -        if ([controller.vendorName containsString: @"Xbox"]) {
    1.38 +        if (is_xbox) {
    1.39              vendor = VENDOR_MICROSOFT;
    1.40              product = 0x02E0; /* Assume Xbox One S BLE Controller unless/until GCController flows VID/PID */
    1.41 -        } else if ([controller.vendorName containsString: @"DUALSHOCK"]) {
    1.42 +        } else if (is_ps4) {
    1.43              vendor = VENDOR_SONY;
    1.44              product = 0x09CC; /* Assume DS4 Slim unless/until GCController flows VID/PID */
    1.45          } else {