diff --git a/Source/iOS/App/Common/Emulation/EmulationCoordinator.h b/Source/iOS/App/Common/Emulation/EmulationCoordinator.h index e25a9ad36f..9532f0656e 100644 --- a/Source/iOS/App/Common/Emulation/EmulationCoordinator.h +++ b/Source/iOS/App/Common/Emulation/EmulationCoordinator.h @@ -6,11 +6,11 @@ @class EmulationBootParameter; @class UIView; +NS_ASSUME_NONNULL_BEGIN + NSString* const DOLEmulationDidStartNotification = @"DOLEmulationDidStartNotification"; NSString* const DOLEmulationDidEndNotification = @"DOLEmulationDidEndNotification"; -NS_ASSUME_NONNULL_BEGIN - @interface EmulationCoordinator : NSObject + (EmulationCoordinator*)shared; diff --git a/Source/iOS/App/Common/Jit/JitManager+AltServer.m b/Source/iOS/App/Common/Jit/JitManager+AltServer.m index d256cbd484..b855395c36 100644 --- a/Source/iOS/App/Common/Jit/JitManager+AltServer.m +++ b/Source/iOS/App/Common/Jit/JitManager+AltServer.m @@ -7,9 +7,21 @@ @import AltKit; -@interface JitManager (AltServer) +@interface JitManager (AltServerPrivate) +@property (nonatomic) BOOL isAltServerAutoConnecting; +@end + +@implementation JitManager (AltServerPrivate) + +// Hack: Private property + +- (BOOL)isAltServerAutoConnecting { + return [objc_getAssociatedObject(self, @selector(isAltServerAutoConnecting)) boolValue]; +} -@property (nonatomic) bool isAltServerAutoConnecting; +- (void)setIsAltServerAutoConnecting:(BOOL)result { + objc_setAssociatedObject(self, @selector(isAltServerAutoConnecting), [NSNumber numberWithBool:result], OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} @end @@ -17,11 +29,11 @@ @implementation JitManager (AltServer) - (bool)checkAppInstalledByAltServer { NSString* deviceId = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"ALTDeviceID"]; - + if (!deviceId) { return false; } - + // If ALTDeviceID isn't our dummy value, then we can use AltServer to enable JIT. return ![deviceId isEqualToString:@"NotSet"]; } @@ -39,35 +51,25 @@ - (void)acquireJitByAltServer { return; } - self.isAltServerAutoConnecting = true; + self.isAltServerAutoConnecting = YES; // TODO: Localization [[ALTServerManager sharedManager] autoconnectWithCompletionHandler:^(ALTServerConnection *connection, NSError *error) { if (error != nil) { self.acquisitionError = [NSString stringWithFormat:@"Failed to connect to AltServer: %@", [error localizedDescription]]; - self.isAltServerAutoConnecting = false; + self.isAltServerAutoConnecting = NO; } else { [connection enableUnsignedCodeExecutionWithCompletionHandler:^(bool success, NSError* error) { if (!success) { self.acquisitionError = [NSString stringWithFormat:@"AltServer failed to enable JIT: %@", [error localizedDescription]]; } - + [connection disconnect]; - - self.isAltServerAutoConnecting = false; + + self.isAltServerAutoConnecting = NO; }]; } }]; } -// Hack: Private property - -- (bool)isAltServerAutoConnecting { - return [objc_getAssociatedObject(self, @selector(isAltServerAutoConnecting)) boolValue]; -} - -- (void)setIsAltServerAutoConnecting:(bool)result { - objc_setAssociatedObject(self, @selector(isAltServerAutoConnecting), [NSNumber numberWithBool:result], OBJC_ASSOCIATION_RETAIN_NONATOMIC); -} - @end diff --git a/Source/iOS/App/Common/UI/SoftwareList/GameFileCacheManager.h b/Source/iOS/App/Common/UI/SoftwareList/GameFileCacheManager.h index 4b40b77a0f..791d46f4b3 100644 --- a/Source/iOS/App/Common/UI/SoftwareList/GameFileCacheManager.h +++ b/Source/iOS/App/Common/UI/SoftwareList/GameFileCacheManager.h @@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN + (GameFileCacheManager*)sharedManager; - (void)rescan; -- (void)rescanAndFetchMetadataWithCompletionHandler:(nullable void (^)())completion_handler; +- (void)rescanAndFetchMetadataWithCompletionHandler:(nullable void (^)(void))completion_handler; - (NSArray*)getGames; diff --git a/Source/iOS/App/DolphiniOS/UI/Emulation/TouchController/TCDeviceMotion.swift b/Source/iOS/App/DolphiniOS/UI/Emulation/TouchController/TCDeviceMotion.swift index f43f35a120..ca40787671 100644 --- a/Source/iOS/App/DolphiniOS/UI/Emulation/TouchController/TCDeviceMotion.swift +++ b/Source/iOS/App/DolphiniOS/UI/Emulation/TouchController/TCDeviceMotion.swift @@ -129,6 +129,12 @@ import Foundation // UIApplicationDidChangeStatusBarOrientationNotification is deprecated... @objc func statusBarOrientationChanged() { - self.orientation = UIApplication.shared.statusBarOrientation + self.orientation = UIApplication.shared.foregroundActiveScene?.interfaceOrientation ?? .portrait + } +} + +private extension UIApplication { + var foregroundActiveScene: UIWindowScene? { + return connectedScenes.filter { $0.activationState == .foregroundActive }.compactMap { $0 as? UIWindowScene }.first } } diff --git a/Source/iOS/App/DolphiniOS/UI/Emulation/TouchController/TCJoystick.swift b/Source/iOS/App/DolphiniOS/UI/Emulation/TouchController/TCJoystick.swift index d01bdf4ba0..6af6224992 100644 --- a/Source/iOS/App/DolphiniOS/UI/Emulation/TouchController/TCJoystick.swift +++ b/Source/iOS/App/DolphiniOS/UI/Emulation/TouchController/TCJoystick.swift @@ -77,7 +77,7 @@ class TCJoystick: UIView let yDiff = point.y - joystickCenter.y // Calculate distance - var distance = sqrt(pow(xDiff, 2) + pow(yDiff, 2)) + let distance = sqrt(pow(xDiff, 2) + pow(yDiff, 2)) let maxDistance = self.frame.width / 3 if (distance > maxDistance)