Skip to content

Commit 5241326

Browse files
warmenhovenLibretroAdmin
authored andcommitted
iOS: default audio sync on again, also more mfi logging
1 parent 1e9db89 commit 5241326

4 files changed

Lines changed: 67 additions & 43 deletions

File tree

config.def.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,12 +1165,7 @@
11651165
#endif
11661166

11671167
/* Will sync audio. (recommended) */
1168-
#ifdef IOS
1169-
/* FIXME: coreaudio will cause the main thread to hang on backgrounding, causing a crash */
1170-
#define DEFAULT_AUDIO_SYNC false
1171-
#else
11721168
#define DEFAULT_AUDIO_SYNC true
1173-
#endif
11741169

11751170
/* Audio rate control. */
11761171
#if !defined(RARCH_CONSOLE)
@@ -1413,14 +1408,7 @@
14131408
#define DEFAULT_FASTFORWARD_FRAMESKIP true
14141409

14151410
/* Enable runloop for variable refresh rate screens. Force x1 speed while handling fast forward too. */
1416-
#ifdef IOS
1417-
/* FIXME: coreaudio will cause the main thread to hang on backgrounding, causing
1418-
* a crash. the fix is to turn off audio synchronization. with that off, we need
1419-
* this on */
1420-
#define DEFAULT_VRR_RUNLOOP_ENABLE true
1421-
#else
14221411
#define DEFAULT_VRR_RUNLOOP_ENABLE false
1423-
#endif
14241412

14251413
/* Run core logic one or more frames ahead then load the state back to reduce perceived input lag. */
14261414
#define DEFAULT_RUN_AHEAD_FRAMES 1

input/drivers_joypad/mfi_joypad.m

Lines changed: 65 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,38 @@ static void apple_gamecontroller_joypad_connect(GCController *controller)
438438

439439
/* Prevent same controller getting set twice */
440440
if ([mfiControllers containsObject:controller])
441+
{
442+
RARCH_DBG("[mfi] got connected notice for controller already connected\n");
441443
return;
444+
}
445+
446+
if (@available(macOS 11, iOS 14, tvOS 14, *))
447+
{
448+
RARCH_DBG("[mfi] new controller connected:\n");
449+
RARCH_DBG("[mfi] name: %s\n", [controller.vendorName UTF8String]);
450+
RARCH_DBG("[mfi] category: %s\n", [controller.productCategory UTF8String]);
451+
RARCH_DBG("[mfi] has battery info: %s\n", controller.battery != nil ? "yes" : "no");
452+
RARCH_DBG("[mfi] has haptics: %s\n", controller.haptics != nil ? "yes" : "no");
453+
RARCH_DBG("[mfi] has light: %s\n", controller.light != nil ? "yes" : "no");
454+
RARCH_DBG("[mfi] has motion: %s\n", controller.motion != nil ? "yes" : "no");
455+
RARCH_DBG("[mfi] has microGamepad: %s\n", controller.microGamepad != nil ? "yes" : "no");
456+
RARCH_DBG("[mfi] has extendedGamepad: %s\n", controller.extendedGamepad != nil ? "yes" : "no");
457+
RARCH_DBG("[mfi] input profile:\n");
458+
for (NSString *elem in controller.physicalInputProfile.elements.allKeys)
459+
{
460+
RARCH_DBG("[mfi] %s\n", [elem UTF8String]);
461+
GCControllerElement *element = controller.physicalInputProfile.elements[elem];
462+
RARCH_DBG("[mfi] analog: %s\n", element.analog ? "yes" : "no");
463+
RARCH_DBG("[mfi] localizedName: %s\n", [element.localizedName UTF8String]);
464+
}
465+
}
442466

443467
if (mfi_controllers[desired_index] != (uint32_t)controller.hash)
444468
{
445469
/* Desired slot is unused, take it */
446470
if (!mfi_controllers[desired_index])
447471
{
472+
RARCH_LOG("[mfi] controller given desired index %d\n", desired_index);
448473
controller.playerIndex = desired_index;
449474
mfi_controllers[desired_index] = (uint32_t)controller.hash;
450475
}
@@ -458,46 +483,58 @@ static void apple_gamecontroller_joypad_connect(GCController *controller)
458483
if (mfi_controllers[i])
459484
continue;
460485

486+
RARCH_LOG("[mfi] controller reassigned from desired %d to %d\n", desired_index, i);
461487
mfi_controllers[i] = (uint32_t)controller.hash;
462488
controller.playerIndex = i;
463489
break;
464490
}
465-
}
466491

467-
[mfiControllers addObject:controller];
492+
if (i == MAX_MFI_CONTROLLERS)
493+
{
494+
/* shouldn't ever get here, this is an Apple limit */
495+
RARCH_ERR("[mfi] too many connected controllers, ignoring\n");
496+
return;
497+
}
498+
}
499+
}
468500

469-
/* Move any non-game controllers (like the Siri remote) to the end */
470-
if (mfiControllers.count > 1)
471-
{
472-
int newPlayerIndex = 0;
473-
NSInteger connectedNonGameControllerIndex = NSNotFound;
474-
NSUInteger index = 0;
501+
[mfiControllers addObject:controller];
475502

476-
for (GCController *connectedController in mfiControllers)
477-
{
478-
if ( connectedController.microGamepad != nil
479-
&& connectedController.extendedGamepad == nil )
480-
connectedNonGameControllerIndex = index;
481-
index++;
482-
}
503+
/* Move any non-game controllers (like the Siri remote) to the end */
504+
if (mfiControllers.count > 1)
505+
{
506+
int newPlayerIndex = 0;
507+
NSInteger connectedNonGameControllerIndex = NSNotFound;
508+
NSUInteger index = 0;
483509

484-
if (connectedNonGameControllerIndex != NSNotFound)
485-
{
486-
GCController *nonGameController = [mfiControllers objectAtIndex:connectedNonGameControllerIndex];
487-
[mfiControllers removeObjectAtIndex:connectedNonGameControllerIndex];
488-
[mfiControllers addObject:nonGameController];
489-
}
490-
for (GCController *gc in mfiControllers)
491-
gc.playerIndex = newPlayerIndex++;
510+
for (GCController *connectedController in mfiControllers)
511+
{
512+
if ( connectedController.microGamepad != nil
513+
&& connectedController.extendedGamepad == nil )
514+
connectedNonGameControllerIndex = index;
515+
index++;
492516
}
493517

494-
if (mfi_controller_is_siri_remote(controller))
495-
return;
518+
if (connectedNonGameControllerIndex != NSNotFound)
519+
{
520+
GCController *nonGameController = [mfiControllers objectAtIndex:connectedNonGameControllerIndex];
521+
[mfiControllers removeObjectAtIndex:connectedNonGameControllerIndex];
522+
[mfiControllers addObject:nonGameController];
523+
}
524+
for (GCController *gc in mfiControllers)
525+
gc.playerIndex = newPlayerIndex++;
526+
}
496527

497-
apple_gamecontroller_joypad_register(controller);
498-
apple_gamecontroller_joypad_setup_haptics(controller);
499-
mfi_joypad_autodetect_add((unsigned)controller.playerIndex, [controller.vendorName cStringUsingEncoding:NSUTF8StringEncoding]);
528+
if (mfi_controller_is_siri_remote(controller))
529+
{
530+
RARCH_WARN("[mfi] ignoring siri remote as a controller\n");
531+
return;
500532
}
533+
534+
RARCH_LOG("[mfi] controller connected, beginning setup and autodetect\n");
535+
apple_gamecontroller_joypad_register(controller);
536+
apple_gamecontroller_joypad_setup_haptics(controller);
537+
mfi_joypad_autodetect_add((unsigned)controller.playerIndex, [controller.vendorName cStringUsingEncoding:NSUTF8StringEncoding]);
501538
}
502539

503540
static void apple_gamecontroller_joypad_disconnect(GCController* controller)

pkg/apple/RetroArch_Metal.xcodeproj/project.pbxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
0790F67B2BF282B400AA58C9 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0790F6782BF282B400AA58C9 /* Media.xcassets */; };
7676
0790F67C2BF2925400AA58C9 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0790F6782BF282B400AA58C9 /* Media.xcassets */; };
7777
0795A8C7299A095300D5035D /* CoreHaptics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0795A8C6299A095300D5035D /* CoreHaptics.framework */; };
78-
07EF0FF62BEB114000EDCA9B /* MoltenVK.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 07EF0FF42BEB114000EDCA9B /* MoltenVK.xcframework */; };
7978
07EF0FF92BEB117000EDCA9B /* MoltenVK.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 07EF0FF42BEB114000EDCA9B /* MoltenVK.xcframework */; };
8079
07EF0FFA2BEB117000EDCA9B /* MoltenVK.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 07EF0FF42BEB114000EDCA9B /* MoltenVK.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
8180
07EF0FFC2BEB117400EDCA9B /* MoltenVK.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 07EF0FF42BEB114000EDCA9B /* MoltenVK.xcframework */; };

pkg/apple/iOS/AppStore.xcconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ APPSTORE_BUILD = 1
1010
// the app store version must be major.minor.patch and always incrementing,
1111
// so any follow up/hotfix releases will necessarily have the patch version
1212
// drift a little bit
13-
MARKETING_VERSION = 1.18.2
14-
CURRENT_PROJECT_VERSION = 8
13+
MARKETING_VERSION = 1.18.3
14+
CURRENT_PROJECT_VERSION = 12
1515

1616
OTHER_CFLAGS = $(inherited) -DHAVE_APPLE_STORE
1717
OTHER_CFLAGS = $(inherited) -DkRetroArchAppGroup=@\"group.com.libretro.dist.RetroArchGroup\"

0 commit comments

Comments
 (0)