iOS: default audio sync on again, also more mfi logging

This commit is contained in:
Eric Warmenhoven 2024-05-25 15:52:34 -04:00 committed by LibretroAdmin
parent 1e9db89154
commit 52413260de
4 changed files with 73 additions and 49 deletions

View File

@ -1165,12 +1165,7 @@
#endif
/* Will sync audio. (recommended) */
#ifdef IOS
/* FIXME: coreaudio will cause the main thread to hang on backgrounding, causing a crash */
#define DEFAULT_AUDIO_SYNC false
#else
#define DEFAULT_AUDIO_SYNC true
#endif
/* Audio rate control. */
#if !defined(RARCH_CONSOLE)
@ -1413,14 +1408,7 @@
#define DEFAULT_FASTFORWARD_FRAMESKIP true
/* Enable runloop for variable refresh rate screens. Force x1 speed while handling fast forward too. */
#ifdef IOS
/* FIXME: coreaudio will cause the main thread to hang on backgrounding, causing
* a crash. the fix is to turn off audio synchronization. with that off, we need
* this on */
#define DEFAULT_VRR_RUNLOOP_ENABLE true
#else
#define DEFAULT_VRR_RUNLOOP_ENABLE false
#endif
/* Run core logic one or more frames ahead then load the state back to reduce perceived input lag. */
#define DEFAULT_RUN_AHEAD_FRAMES 1

View File

@ -438,13 +438,38 @@ static void apple_gamecontroller_joypad_connect(GCController *controller)
/* Prevent same controller getting set twice */
if ([mfiControllers containsObject:controller])
{
RARCH_DBG("[mfi] got connected notice for controller already connected\n");
return;
}
if (@available(macOS 11, iOS 14, tvOS 14, *))
{
RARCH_DBG("[mfi] new controller connected:\n");
RARCH_DBG("[mfi] name: %s\n", [controller.vendorName UTF8String]);
RARCH_DBG("[mfi] category: %s\n", [controller.productCategory UTF8String]);
RARCH_DBG("[mfi] has battery info: %s\n", controller.battery != nil ? "yes" : "no");
RARCH_DBG("[mfi] has haptics: %s\n", controller.haptics != nil ? "yes" : "no");
RARCH_DBG("[mfi] has light: %s\n", controller.light != nil ? "yes" : "no");
RARCH_DBG("[mfi] has motion: %s\n", controller.motion != nil ? "yes" : "no");
RARCH_DBG("[mfi] has microGamepad: %s\n", controller.microGamepad != nil ? "yes" : "no");
RARCH_DBG("[mfi] has extendedGamepad: %s\n", controller.extendedGamepad != nil ? "yes" : "no");
RARCH_DBG("[mfi] input profile:\n");
for (NSString *elem in controller.physicalInputProfile.elements.allKeys)
{
RARCH_DBG("[mfi] %s\n", [elem UTF8String]);
GCControllerElement *element = controller.physicalInputProfile.elements[elem];
RARCH_DBG("[mfi] analog: %s\n", element.analog ? "yes" : "no");
RARCH_DBG("[mfi] localizedName: %s\n", [element.localizedName UTF8String]);
}
}
if (mfi_controllers[desired_index] != (uint32_t)controller.hash)
{
/* Desired slot is unused, take it */
if (!mfi_controllers[desired_index])
{
RARCH_LOG("[mfi] controller given desired index %d\n", desired_index);
controller.playerIndex = desired_index;
mfi_controllers[desired_index] = (uint32_t)controller.hash;
}
@ -458,46 +483,58 @@ static void apple_gamecontroller_joypad_connect(GCController *controller)
if (mfi_controllers[i])
continue;
RARCH_LOG("[mfi] controller reassigned from desired %d to %d\n", desired_index, i);
mfi_controllers[i] = (uint32_t)controller.hash;
controller.playerIndex = i;
break;
}
if (i == MAX_MFI_CONTROLLERS)
{
/* shouldn't ever get here, this is an Apple limit */
RARCH_ERR("[mfi] too many connected controllers, ignoring\n");
return;
}
}
[mfiControllers addObject:controller];
/* Move any non-game controllers (like the Siri remote) to the end */
if (mfiControllers.count > 1)
{
int newPlayerIndex = 0;
NSInteger connectedNonGameControllerIndex = NSNotFound;
NSUInteger index = 0;
for (GCController *connectedController in mfiControllers)
{
if ( connectedController.microGamepad != nil
&& connectedController.extendedGamepad == nil )
connectedNonGameControllerIndex = index;
index++;
}
if (connectedNonGameControllerIndex != NSNotFound)
{
GCController *nonGameController = [mfiControllers objectAtIndex:connectedNonGameControllerIndex];
[mfiControllers removeObjectAtIndex:connectedNonGameControllerIndex];
[mfiControllers addObject:nonGameController];
}
for (GCController *gc in mfiControllers)
gc.playerIndex = newPlayerIndex++;
}
if (mfi_controller_is_siri_remote(controller))
return;
apple_gamecontroller_joypad_register(controller);
apple_gamecontroller_joypad_setup_haptics(controller);
mfi_joypad_autodetect_add((unsigned)controller.playerIndex, [controller.vendorName cStringUsingEncoding:NSUTF8StringEncoding]);
}
[mfiControllers addObject:controller];
/* Move any non-game controllers (like the Siri remote) to the end */
if (mfiControllers.count > 1)
{
int newPlayerIndex = 0;
NSInteger connectedNonGameControllerIndex = NSNotFound;
NSUInteger index = 0;
for (GCController *connectedController in mfiControllers)
{
if ( connectedController.microGamepad != nil
&& connectedController.extendedGamepad == nil )
connectedNonGameControllerIndex = index;
index++;
}
if (connectedNonGameControllerIndex != NSNotFound)
{
GCController *nonGameController = [mfiControllers objectAtIndex:connectedNonGameControllerIndex];
[mfiControllers removeObjectAtIndex:connectedNonGameControllerIndex];
[mfiControllers addObject:nonGameController];
}
for (GCController *gc in mfiControllers)
gc.playerIndex = newPlayerIndex++;
}
if (mfi_controller_is_siri_remote(controller))
{
RARCH_WARN("[mfi] ignoring siri remote as a controller\n");
return;
}
RARCH_LOG("[mfi] controller connected, beginning setup and autodetect\n");
apple_gamecontroller_joypad_register(controller);
apple_gamecontroller_joypad_setup_haptics(controller);
mfi_joypad_autodetect_add((unsigned)controller.playerIndex, [controller.vendorName cStringUsingEncoding:NSUTF8StringEncoding]);
}
static void apple_gamecontroller_joypad_disconnect(GCController* controller)

View File

@ -75,7 +75,6 @@
0790F67B2BF282B400AA58C9 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0790F6782BF282B400AA58C9 /* Media.xcassets */; };
0790F67C2BF2925400AA58C9 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0790F6782BF282B400AA58C9 /* Media.xcassets */; };
0795A8C7299A095300D5035D /* CoreHaptics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0795A8C6299A095300D5035D /* CoreHaptics.framework */; };
07EF0FF62BEB114000EDCA9B /* MoltenVK.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 07EF0FF42BEB114000EDCA9B /* MoltenVK.xcframework */; };
07EF0FF92BEB117000EDCA9B /* MoltenVK.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 07EF0FF42BEB114000EDCA9B /* MoltenVK.xcframework */; };
07EF0FFA2BEB117000EDCA9B /* MoltenVK.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 07EF0FF42BEB114000EDCA9B /* MoltenVK.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
07EF0FFC2BEB117400EDCA9B /* MoltenVK.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 07EF0FF42BEB114000EDCA9B /* MoltenVK.xcframework */; };

View File

@ -10,8 +10,8 @@ APPSTORE_BUILD = 1
// the app store version must be major.minor.patch and always incrementing,
// so any follow up/hotfix releases will necessarily have the patch version
// drift a little bit
MARKETING_VERSION = 1.18.2
CURRENT_PROJECT_VERSION = 8
MARKETING_VERSION = 1.18.3
CURRENT_PROJECT_VERSION = 12
OTHER_CFLAGS = $(inherited) -DHAVE_APPLE_STORE
OTHER_CFLAGS = $(inherited) -DkRetroArchAppGroup=@\"group.com.libretro.dist.RetroArchGroup\"