Fix iOS 6 UI layout issues caused by previous commit.
    Reduce use of dot notation in apple/iOS/platform.m for stylistic continuity with OSX code.
This commit is contained in:
meancoot 2013-12-17 17:59:44 -05:00
parent bd1e970027
commit a101645d7c

View File

@ -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 ++) for(int i = 0; i != numTouches && g_current_input_data.touch_count < MAX_TOUCHES; i ++)
{ {
UITouch* touch = [touches objectAtIndex: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_x = coord.x * scale;
g_current_input_data.touches[g_current_input_data.touch_count ++].screen_y = coord.y * 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]; [super sendEvent:event];
if ([[event allTouches] count]) 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 // 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)]); 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]; return (RetroArch_iOS*)[[UIApplication sharedApplication] delegate];
} }
#pragma mark LIFECYCLE (UIApplicationDelegate)
- (void)applicationDidFinishLaunching:(UIApplication *)application - (void)applicationDidFinishLaunching:(UIApplication *)application
{ {
apple_platform = self; apple_platform = self;
self.delegate = self; [self setDelegate:self];
// Setup window // Setup window
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; _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.coreDirectory = [NSBundle.mainBundle.bundlePath stringByAppendingPathComponent:@"modules"];
self.logPath = [self.systemDirectory stringByAppendingPathComponent:@"stdout.log"]; self.logPath = [self.systemDirectory stringByAppendingPathComponent:@"stdout.log"];
const char *path = self.documentsDirectory.UTF8String; const char *path = [self.documentsDirectory UTF8String];
path_mkdir(path); path_mkdir(path);
if (access(path, 0755) != 0) if (access(path, 0755) != 0)
apple_display_alert([NSString stringWithFormat:@"Failed to create or access base directory: %@", self.documentsDirectory], 0); apple_display_alert([NSString stringWithFormat:@"Failed to create or access base directory: %@", self.documentsDirectory], 0);
else else
{ {
path = self.systemDirectory.UTF8String; path = [self.systemDirectory UTF8String];
path_mkdir(path); path_mkdir(path);
if (access(path, 0755) != 0) if (access(path, 0755) != 0)
apple_display_alert([NSString stringWithFormat:@"Failed to create or access system directory: %@", self.systemDirectory], 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 // Warn if there are no cores present
apple_core_info_set_core_path(self.coreDirectory.UTF8String); apple_core_info_set_core_path([self.coreDirectory UTF8String]);
apple_core_info_set_config_path(self.configDirectory.UTF8String); apple_core_info_set_config_path([self.configDirectory UTF8String]);
const core_info_list_t* core_list = apple_core_info_list_get(); const core_info_list_t* core_list = apple_core_info_list_get();
if (!core_list || core_list->count == 0) if (!core_list || core_list->count == 0)
@ -232,7 +231,7 @@ static void handle_touch_event(NSArray* touches)
// Load system config // Load system config
const rarch_setting_t* frontend_settings = apple_get_frontend_settings(); const rarch_setting_t* frontend_settings = apple_get_frontend_settings();
setting_data_reset(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 - (void)applicationDidBecomeActive:(UIApplication *)application
@ -245,16 +244,15 @@ static void handle_touch_event(NSArray* touches)
apple_enter_stasis(); apple_enter_stasis();
} }
#pragma mark Frontend Browsing Logic
-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation -(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; 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) if (error)
printf("%s\n", error.description.UTF8String); printf("%s\n", [[error description] UTF8String]);
return true; return true;
} }
@ -263,8 +261,7 @@ static void handle_touch_event(NSArray* touches)
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{ {
apple_input_reset_icade_buttons(); 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 // Workaround to keep frontend settings fresh
[self refreshSystemConfig]; [self refreshSystemConfig];
@ -299,25 +296,21 @@ static void handle_touch_event(NSArray* touches)
- (void)showGameView - (void)showGameView
{ {
[self popToRootViewControllerAnimated:NO]; [self popToRootViewControllerAnimated:NO];
[_window setRootViewController:[RAGameView get]]; [self setToolbarHidden:true animated:NO];
g_extern.is_paused = false;
[[UIApplication sharedApplication] setStatusBarHidden:true withAnimation:UIStatusBarAnimationNone]; [[UIApplication sharedApplication] setStatusBarHidden:true withAnimation:UIStatusBarAnimationNone];
[[UIApplication sharedApplication] setIdleTimerDisabled:true]; [[UIApplication sharedApplication] setIdleTimerDisabled:true];
[_window setRootViewController:[RAGameView get]];
g_extern.is_paused = false;
} }
- (IBAction)showPauseMenu:(id)sender - (IBAction)showPauseMenu:(id)sender
{ {
[_window setRootViewController:self];
g_extern.is_paused = true; g_extern.is_paused = true;
[[UIApplication sharedApplication] setStatusBarHidden:false withAnimation:UIStatusBarAnimationNone]; [[UIApplication sharedApplication] setStatusBarHidden:false withAnimation:UIStatusBarAnimationNone];
[[UIApplication sharedApplication] setIdleTimerDisabled:false]; [[UIApplication sharedApplication] setIdleTimerDisabled:false];
[_window setRootViewController:self];
} }
#pragma mark RetroArch_Platform
- (void)loadingCore:(NSString*)core withFile:(const char*)file - (void)loadingCore:(NSString*)core withFile:(const char*)file
{ {
(void)[[RACoreSettingsMenu alloc] initWithCore:core]; (void)[[RACoreSettingsMenu alloc] initWithCore:core];
@ -335,7 +328,6 @@ static void handle_touch_event(NSArray* touches)
btpad_set_inquiry_state(true); btpad_set_inquiry_state(true);
} }
#pragma mark FRONTEND CONFIG
- (void)refreshSystemConfig - (void)refreshSystemConfig
{ {
// Get enabled orientations // Get enabled orientations
@ -348,7 +340,7 @@ static void handle_touch_event(NSArray* touches)
// Set bluetooth mode // Set bluetooth mode
ios_set_bluetooth_mode(BOXSTRING(apple_frontend_settings.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 @end