Skip to content

Commit

Permalink
Fixed the game controller menu button on tvOS 13.2 (thanks Romain Tis…
Browse files Browse the repository at this point in the history
…serand)
  • Loading branch information
slouken committed Dec 6, 2019
1 parent 597f11e commit 7a51ad6
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/joystick/iphoneos/SDL_sysjoystick.m
Expand Up @@ -129,6 +129,9 @@ @interface GCMicroGamepad (SDL)

if (controller.extendedGamepad) {
GCExtendedGamepad *gamepad = controller.extendedGamepad;
BOOL is_xbox = [controller.vendorName containsString: @"Xbox"];
BOOL is_ps4 = [controller.vendorName containsString: @"DUALSHOCK"];
BOOL is_MFi = (!is_xbox && !is_ps4);
int nbuttons = 0;

/* These buttons are part of the original MFi spec */
Expand All @@ -155,20 +158,24 @@ @interface GCMicroGamepad (SDL)
device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_BACK);
++nbuttons;
}
if ([gamepad respondsToSelector:@selector(buttonMenu)] && gamepad.buttonMenu) {
device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_START);
++nbuttons;
} else {
device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_START);
++nbuttons;
BOOL has_direct_menu = [gamepad respondsToSelector:@selector(buttonMenu)] && gamepad.buttonMenu;
#if TARGET_OS_TV
/* On tvOS MFi controller menu button brings you to the home screen */
if (is_MFi) {
has_direct_menu = FALSE;
}
#endif
device->button_mask |= (1 << SDL_CONTROLLER_BUTTON_START);
++nbuttons;
if (!has_direct_menu) {
device->uses_pause_handler = SDL_TRUE;
}
#pragma clang diagnostic pop

if ([controller.vendorName containsString: @"Xbox"]) {
if (is_xbox) {
vendor = VENDOR_MICROSOFT;
product = 0x02E0; /* Assume Xbox One S BLE Controller unless/until GCController flows VID/PID */
} else if ([controller.vendorName containsString: @"DUALSHOCK"]) {
} else if (is_ps4) {
vendor = VENDOR_SONY;
product = 0x09CC; /* Assume DS4 Slim unless/until GCController flows VID/PID */
} else {
Expand Down

0 comments on commit 7a51ad6

Please sign in to comment.