diff --git a/apple/iOS/platform.m b/apple/iOS/platform.m index 32909f1671..77985118b3 100644 --- a/apple/iOS/platform.m +++ b/apple/iOS/platform.m @@ -115,9 +115,9 @@ static void handle_touch_event(NSArray* touches) for(int i = 0; i != numTouches && g_current_input_data.touch_count < MAX_TOUCHES; i ++) { UITouch* touch = [touches objectAtIndex:i]; - const CGPoint coord = [touch locationInView:touch.view]; + const CGPoint coord = [touch locationInView:[touch view]]; - if (touch.phase != UITouchPhaseEnded && touch.phase != UITouchPhaseCancelled) + if ([touch phase] != UITouchPhaseEnded && [touch phase] != UITouchPhaseCancelled) { g_current_input_data.touches[g_current_input_data.touch_count ].screen_x = coord.x * scale; g_current_input_data.touches[g_current_input_data.touch_count ++].screen_y = coord.y * scale; @@ -156,9 +156,9 @@ static void handle_touch_event(NSArray* touches) [super sendEvent:event]; if ([[event allTouches] count]) - handle_touch_event(event.allTouches.allObjects); + handle_touch_event([[event allTouches] allObjects]); - if ([event respondsToSelector:@selector(_gsEvent)]) + if (get_ios_version_major() < 7 && [event respondsToSelector:@selector(_gsEvent)]) { // Stolen from: http://nacho4d-nacho4d.blogspot.com/2012/01/catching-keyboard-events-in-ios.html uint8_t* eventMem = (uint8_t*)(void*)CFBridgingRetain([event performSelector:@selector(_gsEvent)]); @@ -186,11 +186,10 @@ static void handle_touch_event(NSArray* touches) return (RetroArch_iOS*)[[UIApplication sharedApplication] delegate]; } -#pragma mark LIFECYCLE (UIApplicationDelegate) - (void)applicationDidFinishLaunching:(UIApplication *)application { apple_platform = self; - self.delegate = self; + [self setDelegate:self]; // Setup window _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; @@ -207,13 +206,13 @@ static void handle_touch_event(NSArray* touches) self.coreDirectory = [NSBundle.mainBundle.bundlePath stringByAppendingPathComponent:@"modules"]; self.logPath = [self.systemDirectory stringByAppendingPathComponent:@"stdout.log"]; - const char *path = self.documentsDirectory.UTF8String; + const char *path = [self.documentsDirectory UTF8String]; path_mkdir(path); if (access(path, 0755) != 0) apple_display_alert([NSString stringWithFormat:@"Failed to create or access base directory: %@", self.documentsDirectory], 0); else { - path = self.systemDirectory.UTF8String; + path = [self.systemDirectory UTF8String]; path_mkdir(path); if (access(path, 0755) != 0) apple_display_alert([NSString stringWithFormat:@"Failed to create or access system directory: %@", self.systemDirectory], 0); @@ -222,8 +221,8 @@ static void handle_touch_event(NSArray* touches) } // Warn if there are no cores present - apple_core_info_set_core_path(self.coreDirectory.UTF8String); - apple_core_info_set_config_path(self.configDirectory.UTF8String); + apple_core_info_set_core_path([self.coreDirectory UTF8String]); + apple_core_info_set_config_path([self.configDirectory UTF8String]); const core_info_list_t* core_list = apple_core_info_list_get(); if (!core_list || core_list->count == 0) @@ -232,7 +231,7 @@ static void handle_touch_event(NSArray* touches) // Load system config const rarch_setting_t* frontend_settings = apple_get_frontend_settings(); setting_data_reset(frontend_settings); - setting_data_load_config_path(frontend_settings, self.systemConfigPath.UTF8String); + setting_data_load_config_path(frontend_settings, [self.systemConfigPath UTF8String]); } - (void)applicationDidBecomeActive:(UIApplication *)application @@ -245,16 +244,15 @@ static void handle_touch_event(NSArray* touches) apple_enter_stasis(); } -#pragma mark Frontend Browsing Logic -(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { - NSString* filename = url.path.lastPathComponent; + NSString* filename = [[url path] lastPathComponent]; NSError* error = nil; - [NSFileManager.defaultManager moveItemAtPath:url.path toPath:[self.documentsDirectory stringByAppendingPathComponent:filename] error:&error]; + [[NSFileManager defaultManager] moveItemAtPath:[url path] toPath:[self.documentsDirectory stringByAppendingPathComponent:filename] error:&error]; if (error) - printf("%s\n", error.description.UTF8String); + printf("%s\n", [[error description] UTF8String]); return true; } @@ -263,8 +261,7 @@ static void handle_touch_event(NSArray* touches) - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { apple_input_reset_icade_buttons(); - - [self setToolbarHidden:!viewController.toolbarItems.count animated:YES]; + [self setToolbarHidden:![[viewController toolbarItems] count] animated:YES]; // Workaround to keep frontend settings fresh [self refreshSystemConfig]; @@ -299,25 +296,21 @@ static void handle_touch_event(NSArray* touches) - (void)showGameView { [self popToRootViewControllerAnimated:NO]; - [_window setRootViewController:[RAGameView get]]; - - g_extern.is_paused = false; - + [self setToolbarHidden:true animated:NO]; [[UIApplication sharedApplication] setStatusBarHidden:true withAnimation:UIStatusBarAnimationNone]; [[UIApplication sharedApplication] setIdleTimerDisabled:true]; + [_window setRootViewController:[RAGameView get]]; + g_extern.is_paused = false; } - (IBAction)showPauseMenu:(id)sender { - [_window setRootViewController:self]; - g_extern.is_paused = true; - [[UIApplication sharedApplication] setStatusBarHidden:false withAnimation:UIStatusBarAnimationNone]; [[UIApplication sharedApplication] setIdleTimerDisabled:false]; + [_window setRootViewController:self]; } -#pragma mark RetroArch_Platform - (void)loadingCore:(NSString*)core withFile:(const char*)file { (void)[[RACoreSettingsMenu alloc] initWithCore:core]; @@ -335,7 +328,6 @@ static void handle_touch_event(NSArray* touches) btpad_set_inquiry_state(true); } -#pragma mark FRONTEND CONFIG - (void)refreshSystemConfig { // Get enabled orientations @@ -348,7 +340,7 @@ static void handle_touch_event(NSArray* touches) // Set bluetooth mode ios_set_bluetooth_mode(BOXSTRING(apple_frontend_settings.bluetooth_mode)); - ios_set_logging_state([RetroArch_iOS get].logPath.UTF8String, apple_frontend_settings.logging_enabled); + ios_set_logging_state([[RetroArch_iOS get].logPath UTF8String], apple_frontend_settings.logging_enabled); } @end