diff --git a/apple/common/apple_gamecontroller.m b/apple/common/apple_gamecontroller.m index cee1ebfe28..2b11c895f1 100644 --- a/apple/common/apple_gamecontroller.m +++ b/apple/common/apple_gamecontroller.m @@ -14,6 +14,7 @@ */ #include +#include "RetroArch_Apple.h" #ifdef IOS #include #endif @@ -26,19 +27,13 @@ #include "apple_input.h" #ifdef IOS -bool apple_rarch_is_ios7_or_higher(void) -{ - NSArray *versionCompatibility = [[UIDevice currentDevice].systemVersion - componentsSeparatedByString:@(".")]; - bool ret = [[versionCompatibility objectAtIndex:0] intValue] >= 7; - return ret; -} + #endif static void apple_gamecontroller_poll(GCController* controller) { #ifdef IOS - if (!apple_rarch_is_ios7_or_higher()) + if (!(IOS_IS_VERSION_7_OR_HIGHER())) return; #endif if (!controller || controller.playerIndex == MAX_PLAYERS) @@ -88,7 +83,7 @@ static void apple_gamecontroller_poll(GCController* controller) void apple_gamecontroller_poll_all(void) { #ifdef IOS - if (!apple_rarch_is_ios7_or_higher()) + if (!(IOS_IS_VERSION_7_OR_HIGHER())) return; #endif NSArray* controllers = [GCController controllers]; @@ -100,7 +95,7 @@ void apple_gamecontroller_poll_all(void) void apple_gamecontroller_connect(GCController* controller) { #ifdef IOS - if (!apple_rarch_is_ios7_or_higher()) + if (!(IOS_IS_VERSION_7_OR_HIGHER())) return; #endif int32_t slot = apple_joypad_connect_gcapi(); @@ -121,7 +116,7 @@ void apple_gamecontroller_connect(GCController* controller) void apple_gamecontroller_disconnect(GCController* controller) { #ifdef IOS - if (!apple_rarch_is_ios7_or_higher()) + if (!(IOS_IS_VERSION_7_OR_HIGHER())) return; #endif if (controller.playerIndex == GCControllerPlayerIndexUnset) @@ -133,7 +128,7 @@ void apple_gamecontroller_disconnect(GCController* controller) void apple_gamecontroller_init(void) { #ifdef IOS - if (!apple_rarch_is_ios7_or_higher()) + if (!(IOS_IS_VERSION_7_OR_HIGHER())) return; #endif diff --git a/apple/iOS/browser.m b/apple/iOS/browser.m index a93820bace..f8c09da6dd 100644 --- a/apple/iOS/browser.m +++ b/apple/iOS/browser.m @@ -311,8 +311,8 @@ static void file_action(enum file_action action, NSString* source, NSString* tar self.selectedItem = [self itemForIndexPath:indexPath]; bool is_zip = [[self.selectedItem.path pathExtension] isEqualToString:@"zip"]; - NSString* button4_name = (get_ios_version_major() >= 7) ? @"AirDrop" : @"Delete"; - NSString* button5_name = (get_ios_version_major() >= 7) ? @"Delete" : nil; + NSString* button4_name = (IOS_IS_VERSION_7_OR_HIGHER()) ? @"AirDrop" : @"Delete"; + NSString* button5_name = (IOS_IS_VERSION_7_OR_HIGHER()) ? @"Delete" : nil; UIActionSheet* menu = [[UIActionSheet alloc] initWithTitle:self.selectedItem.path.lastPathComponent delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil @@ -350,7 +350,7 @@ static void file_action(enum file_action action, NSString* source, NSString* tar [alertView show]; } #ifdef __IPHONE_7_0 - else if ([action isEqualToString:@"AirDrop"] && get_ios_version_major() >= 7) + else if ([action isEqualToString:@"AirDrop"] && IOS_IS_VERSION_7_OR_HIGHER()) { // TODO: Zip if not already zipped diff --git a/apple/iOS/platform.h b/apple/iOS/platform.h index d52d0f5245..6738400769 100644 --- a/apple/iOS/platform.h +++ b/apple/iOS/platform.h @@ -71,6 +71,8 @@ const void* apple_get_frontend_settings(void); // modes are: keyboard, icade and btstack void ios_set_bluetooth_mode(NSString* mode); -int get_ios_version_major(); +int get_ios_version_major(void); + +#define IOS_IS_VERSION_7_OR_HIGHER() ((get_ios_version_major() >= 7)) #endif diff --git a/apple/iOS/platform.m b/apple/iOS/platform.m index c988f340d7..e073ebd156 100644 --- a/apple/iOS/platform.m +++ b/apple/iOS/platform.m @@ -32,7 +32,8 @@ apple_frontend_settings_t apple_frontend_settings; -int get_ios_version_major() +#ifdef IOS +int get_ios_version_major(void) { static int version = -1; @@ -47,6 +48,7 @@ void ios_set_bluetooth_mode(NSString* mode) apple_input_enable_icade([mode isEqualToString:@"icade"]); btstack_set_poweron([mode isEqualToString:@"btstack"]); } +#endif const void* apple_get_frontend_settings(void) { @@ -157,7 +159,7 @@ static void handle_touch_event(NSArray* touches) if ([[event allTouches] count]) handle_touch_event([[event allTouches] allObjects]); - if (get_ios_version_major() < 7 && [event respondsToSelector:@selector(_gsEvent)]) + if (!(IOS_IS_VERSION_7_OR_HIGHER()) && [event respondsToSelector:@selector(_gsEvent)]) { // Stolen from: http://nacho4d-nacho4d.blogspot.com/2012/01/catching-keyboard-events-in-ios.html const uint8_t* eventMem = objc_unretainedPointer([event performSelector:@selector(_gsEvent)]);