diff --git a/CMakeLists.txt b/CMakeLists.txt index ec2f905e2e..52dd7f4d09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -629,7 +629,10 @@ elseif(IOS) ios/iCade/iCadeReaderView.h ios/iCade/iCadeReaderView.m ios/iCade/iCadeState.h) - set(nativeExtraLibs ${nativeExtraLibs} "-framework Foundation -framework AudioToolbox -framework CoreGraphics -framework QuartzCore -framework OpenGLES -framework UIKit -framework GLKit -framework OpenAL -weak_framework GameController") + set(nativeExtraLibs ${nativeExtraLibs} "-framework Foundation -framework AudioToolbox -framework CoreGraphics -framework QuartzCore -framework OpenGLES -framework UIKit -framework GLKit -framework OpenAL") + if(EXISTS "${CMAKE_IOS_SDK_ROOT}/System/Library/Frameworks/GameController.framework") + set(nativeExtraLibs ${nativeExtraLibs} "-weak_framework GameController") + endif() set(TargetBin PPSSPP) elseif(USING_QT_UI) # Currently unused diff --git a/ios/ViewController.h b/ios/ViewController.h index 4e428a71cc..eda8722ec2 100644 --- a/ios/ViewController.h +++ b/ios/ViewController.h @@ -2,8 +2,9 @@ #import #import +#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1 #import - +#endif #import "iCade/iCadeReaderView.h" @interface ViewController : GLKViewController diff --git a/ios/ViewController.mm b/ios/ViewController.mm index baf02c49dc..f01cd64b98 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -48,7 +48,9 @@ ViewController* sharedViewController; @property (nonatomic,retain) NSMutableArray* touches; @property (nonatomic,retain) AudioEngine* audioEngine; @property (nonatomic,retain) iCadeReaderView *iCadeView; +#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1 @property (nonatomic,retain) GCController *gameController __attribute__((weak_import)); +#endif @end @@ -98,11 +100,13 @@ ViewController* sharedViewController; iCadeToKeyMap[iCadeButtonF] = NKCODE_BUTTON_2; // Cross iCadeToKeyMap[iCadeButtonG] = NKCODE_BUTTON_1; // Triangle iCadeToKeyMap[iCadeButtonH] = NKCODE_BUTTON_3; // Circle - + +#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1 if ([GCController class]) { // Checking the availability of a GameController framework [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controllerDidConnect:) name:GCControllerDidConnectNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(controllerDidDisconnect:) name:GCControllerDidDisconnectNotification object:nil]; } +#endif } return self; } @@ -174,7 +178,13 @@ ViewController* sharedViewController; { [self viewDidUnload]; - if ([GCController class]) self.gameController = nil; +#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1 + if ([GCController class]) { + [[NSNotificationCenter defaultCenter] removeObserver:self name:GCControllerDidConnectNotification object:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:GCControllerDidDisconnectNotification object:nil]; + self.gameController = nil; + } +#endif self.iCadeView = nil; self.audioEngine = nil; self.touches = nil; @@ -430,8 +440,11 @@ void DisableFZ(){}; } +#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1 - (void)controllerDidConnect:(NSNotification *)note { + if (![[GCController controllers] containsObject:self.gameController]) self.gameController = nil; + if (self.gameController != nil) return; // already have a connected controller [self setupController:(GCController *)note.object]; @@ -566,5 +579,6 @@ void DisableFZ(){}; [self controllerButtonPressed:(value > 0.5) keyCode:NKCODE_BUTTON_12]; }; } +#endif @end