mirror of
https://github.com/libretro/RetroArch.git
synced 2024-10-08 15:13:24 +00:00
prevent crash on controller connect.
disable system button gestures on iOS 14. remove deprecation warnings.
This commit is contained in:
parent
9f17cb7a86
commit
be8dd0dba1
@ -61,6 +61,9 @@ static void apple_gamecontroller_joypad_poll_internal(GCController *controller)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
slot = (uint32_t)controller.playerIndex;
|
slot = (uint32_t)controller.playerIndex;
|
||||||
|
// if we have not assigned a slot to this controller yet, ignore it.
|
||||||
|
if (slot >= MAX_USERS)
|
||||||
|
return;
|
||||||
buttons = &mfi_buttons[slot];
|
buttons = &mfi_buttons[slot];
|
||||||
|
|
||||||
/* retain the values from the paused controller handler and pass them through */
|
/* retain the values from the paused controller handler and pass them through */
|
||||||
@ -136,6 +139,9 @@ static void apple_gamecontroller_joypad_poll_internal(GCController *controller)
|
|||||||
mfi_axes[slot][3] = gp.rightThumbstick.yAxis.value * 32767.0f;
|
mfi_axes[slot][3] = gp.rightThumbstick.yAxis.value * 32767.0f;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
// GCGamepad is deprecated
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wdeprecated"
|
||||||
else if (controller.gamepad)
|
else if (controller.gamepad)
|
||||||
{
|
{
|
||||||
GCGamepad *gp = (GCGamepad *)controller.gamepad;
|
GCGamepad *gp = (GCGamepad *)controller.gamepad;
|
||||||
@ -151,6 +157,7 @@ static void apple_gamecontroller_joypad_poll_internal(GCController *controller)
|
|||||||
*buttons |= gp.leftShoulder.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_L) : 0;
|
*buttons |= gp.leftShoulder.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_L) : 0;
|
||||||
*buttons |= gp.rightShoulder.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_R) : 0;
|
*buttons |= gp.rightShoulder.pressed ? (1 << RETRO_DEVICE_ID_JOYPAD_R) : 0;
|
||||||
}
|
}
|
||||||
|
#pragma clang diagnostic pop
|
||||||
}
|
}
|
||||||
|
|
||||||
static void apple_gamecontroller_joypad_poll(void)
|
static void apple_gamecontroller_joypad_poll(void)
|
||||||
@ -162,8 +169,22 @@ static void apple_gamecontroller_joypad_poll(void)
|
|||||||
apple_gamecontroller_joypad_poll_internal(controller);
|
apple_gamecontroller_joypad_poll_internal(controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GCGamepad is deprecated
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wdeprecated"
|
||||||
static void apple_gamecontroller_joypad_register(GCGamepad *gamepad)
|
static void apple_gamecontroller_joypad_register(GCGamepad *gamepad)
|
||||||
{
|
{
|
||||||
|
#ifdef __IPHONE_14_0
|
||||||
|
// dont let tvOS or iOS do anything with **our** buttons!!
|
||||||
|
// iOS will start a screen recording if you hold or dbl click the OPTIONS button, we dont want that.
|
||||||
|
if (@available(iOS 14.0, tvOS 14.0, *)) {
|
||||||
|
GCExtendedGamepad *gp = (GCExtendedGamepad *)gamepad.controller.extendedGamepad;
|
||||||
|
gp.buttonOptions.preferredSystemGestureState = GCSystemGestureStateDisabled;
|
||||||
|
gp.buttonMenu.preferredSystemGestureState = GCSystemGestureStateDisabled;
|
||||||
|
gp.buttonHome.preferredSystemGestureState = GCSystemGestureStateDisabled;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
gamepad.valueChangedHandler = ^(GCGamepad *updateGamepad, GCControllerElement *element)
|
gamepad.valueChangedHandler = ^(GCGamepad *updateGamepad, GCControllerElement *element)
|
||||||
{
|
{
|
||||||
apple_gamecontroller_joypad_poll_internal(updateGamepad.controller);
|
apple_gamecontroller_joypad_poll_internal(updateGamepad.controller);
|
||||||
@ -233,6 +254,7 @@ static void apple_gamecontroller_joypad_register(GCGamepad *gamepad)
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
|
||||||
static void mfi_joypad_autodetect_add(unsigned autoconf_pad)
|
static void mfi_joypad_autodetect_add(unsigned autoconf_pad)
|
||||||
{
|
{
|
||||||
@ -273,6 +295,9 @@ static void apple_gamecontroller_joypad_connect(GCController *controller)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GCGamepad is deprecated
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wdeprecated"
|
||||||
[mfiControllers addObject:controller];
|
[mfiControllers addObject:controller];
|
||||||
// move any non-game controllers (like the siri remote) to the end
|
// move any non-game controllers (like the siri remote) to the end
|
||||||
if (mfiControllers.count > 1)
|
if (mfiControllers.count > 1)
|
||||||
@ -302,6 +327,7 @@ static void apple_gamecontroller_joypad_connect(GCController *controller)
|
|||||||
apple_gamecontroller_joypad_register(controller.gamepad);
|
apple_gamecontroller_joypad_register(controller.gamepad);
|
||||||
mfi_joypad_autodetect_add((unsigned)controller.playerIndex);
|
mfi_joypad_autodetect_add((unsigned)controller.playerIndex);
|
||||||
}
|
}
|
||||||
|
#pragma clang diagnostic pop
|
||||||
}
|
}
|
||||||
|
|
||||||
static void apple_gamecontroller_joypad_disconnect(GCController* controller)
|
static void apple_gamecontroller_joypad_disconnect(GCController* controller)
|
||||||
|
Loading…
Reference in New Issue
Block a user