mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-28 10:40:39 +00:00
iOS/tvOS/macOS: Fix autodetect for mFi controllers: properly call autodetect add on the connect notification, and add call to disconnect on GameController disconnect notification.
This commit is contained in:
parent
78915aedd1
commit
102f27ee80
@ -222,6 +222,11 @@ static void apple_gamecontroller_joypad_register(GCGamepad *gamepad)
|
||||
}
|
||||
}
|
||||
|
||||
static void mfi_joypad_autodetect_add(unsigned autoconf_pad)
|
||||
{
|
||||
input_autoconfigure_connect("mFi Controller", NULL, mfi_joypad.ident, autoconf_pad, 0, 0);
|
||||
}
|
||||
|
||||
static void apple_gamecontroller_joypad_connect(GCController *controller)
|
||||
{
|
||||
signed desired_index = (int32_t)controller.playerIndex;
|
||||
@ -279,6 +284,7 @@ static void apple_gamecontroller_joypad_connect(GCController *controller)
|
||||
}
|
||||
|
||||
apple_gamecontroller_joypad_register(controller.gamepad);
|
||||
mfi_joypad_autodetect_add(controller.playerIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -290,17 +296,15 @@ static void apple_gamecontroller_joypad_disconnect(GCController* controller)
|
||||
return;
|
||||
|
||||
mfi_controllers[pad] = 0;
|
||||
[mfiControllers removeObject:controller];
|
||||
}
|
||||
|
||||
static void mfi_joypad_autodetect_add(unsigned autoconf_pad)
|
||||
{
|
||||
input_autoconfigure_connect("mFi Controller", NULL, mfi_joypad.ident, autoconf_pad, 0, 0);
|
||||
if ( [mfiControllers containsObject:controller] )
|
||||
{
|
||||
[mfiControllers removeObject:controller];
|
||||
input_autoconfigure_disconnect(pad, mfi_joypad.ident);
|
||||
}
|
||||
}
|
||||
|
||||
bool apple_gamecontroller_joypad_init(void *data)
|
||||
{
|
||||
mfi_joypad_autodetect_add(0);
|
||||
static bool inited = false;
|
||||
if (inited)
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user