mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 04:20:27 +00:00
iOS: Support L3/R3 in iOS 12.1, Options buttons in mfi/PS4/XBox One controllers in iOS 13
This commit is contained in:
parent
5c7a5fdba0
commit
9e1fcf4031
@ -65,12 +65,18 @@ static void apple_gamecontroller_joypad_poll_internal(GCController *controller)
|
||||
buttons = &mfi_buttons[slot];
|
||||
|
||||
/* retain the values from the paused controller handler and pass them through */
|
||||
if (@available(iOS 13, *)) {
|
||||
// The menu button can be pressed/unpressed like any other button in iOS 13
|
||||
// so no need to passthrough anything
|
||||
*buttons = 0;
|
||||
} else {
|
||||
// Use the paused controller handler for iOS versions below 13
|
||||
pause = *buttons & (1 << RETRO_DEVICE_ID_JOYPAD_START);
|
||||
select = *buttons & (1 << RETRO_DEVICE_ID_JOYPAD_SELECT);
|
||||
l3 = *buttons & ( 1 << RETRO_DEVICE_ID_JOYPAD_L3 );
|
||||
r3 = *buttons & ( 1 << RETRO_DEVICE_ID_JOYPAD_R3 );
|
||||
*buttons = 0 | pause | select | l3 | r3;
|
||||
|
||||
}
|
||||
memset(mfi_axes[slot], 0, sizeof(mfi_axes[0]));
|
||||
|
||||
if (controller.extendedGamepad)
|
||||
@ -89,6 +95,31 @@ static void apple_gamecontroller_joypad_poll_internal(GCController *controller)
|
||||
*buttons |= gp.rightShoulder.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_R) : 0;
|
||||
*buttons |= gp.leftTrigger.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
|
||||
*buttons |= gp.rightTrigger.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
|
||||
if (@available(iOS 12.1, *)) {
|
||||
*buttons |= gp.leftThumbstickButton.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_L3) : 0;
|
||||
*buttons |= gp.rightThumbstickButton.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_R3) : 0;
|
||||
}
|
||||
if (@available(iOS 13, *)) {
|
||||
// Support "Options" button present in PS4 / XBox One controllers
|
||||
*buttons |= gp.buttonOptions.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
|
||||
|
||||
// Support buttons that aren't supported by older mFi controller via "hotkey" combinations:
|
||||
//
|
||||
// LS + Menu => Select
|
||||
// LT + Menu => L3
|
||||
// RT + Menu => R3
|
||||
if ( gp.buttonMenu.pressed ) {
|
||||
if ( gp.leftShoulder.pressed ) {
|
||||
*buttons |= 1 << RETRO_DEVICE_ID_JOYPAD_SELECT;
|
||||
} else if ( gp.leftTrigger.pressed ) {
|
||||
*buttons |= 1 << RETRO_DEVICE_ID_JOYPAD_L3;
|
||||
} else if ( gp.rightTrigger.pressed ) {
|
||||
*buttons |= 1 << RETRO_DEVICE_ID_JOYPAD_R3;
|
||||
} else {
|
||||
*buttons |= 1 << RETRO_DEVICE_ID_JOYPAD_START;
|
||||
}
|
||||
}
|
||||
}
|
||||
mfi_axes[slot][0] = gp.leftThumbstick.xAxis.value * 32767.0f;
|
||||
mfi_axes[slot][1] = gp.leftThumbstick.yAxis.value * 32767.0f;
|
||||
mfi_axes[slot][2] = gp.rightThumbstick.xAxis.value * 32767.0f;
|
||||
@ -128,6 +159,11 @@ static void apple_gamecontroller_joypad_register(GCGamepad *gamepad)
|
||||
apple_gamecontroller_joypad_poll_internal(updateGamepad.controller);
|
||||
};
|
||||
|
||||
if (@available(iOS 13, *)) {
|
||||
// controllerPausedHandler is deprecated in favor of being able to deal with the menu
|
||||
// button as any other button
|
||||
return;
|
||||
} else {
|
||||
gamepad.controller.controllerPausedHandler = ^(GCController *controller)
|
||||
{
|
||||
uint32_t slot = (uint32_t)controller.playerIndex;
|
||||
@ -173,6 +209,7 @@ static void apple_gamecontroller_joypad_register(GCGamepad *gamepad)
|
||||
});
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
static void apple_gamecontroller_joypad_connect(GCController *controller)
|
||||
|
@ -418,6 +418,7 @@
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
English,
|
||||
en,
|
||||
Base,
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user