diff --git a/ios/RetroArch/RetroArch_iOS.h b/ios/RetroArch/RetroArch_iOS.h index d8cb0c95c4..c9cd7f427a 100644 --- a/ios/RetroArch/RetroArch_iOS.h +++ b/ios/RetroArch/RetroArch_iOS.h @@ -15,5 +15,9 @@ @property (strong, nonatomic) NSString *module_path; @property (strong, nonatomic) UINavigationController *navigator; @property (strong, nonatomic) NSString *nib_name; +@property (strong, nonatomic) UIImage* file_icon; +@property (strong, nonatomic) UIImage* folder_icon; + +@property const char* system_directory; @end diff --git a/ios/RetroArch/RetroArch_iOS.m b/ios/RetroArch/RetroArch_iOS.m index f15015cb95..26acd373d2 100644 --- a/ios/RetroArch/RetroArch_iOS.m +++ b/ios/RetroArch/RetroArch_iOS.m @@ -5,6 +5,8 @@ // Copyright (c) 2013 RetroArch. All rights reserved. // +#include + #define MAX_TOUCH 16 extern struct { @@ -25,8 +27,16 @@ extern uint32_t ios_current_touch_count ; - (void)applicationDidFinishLaunching:(UIApplication *)application { + // TODO: Relocate this! + self.system_directory = "/var/mobile/Library/RetroArch/"; + mkdir(self.system_directory, 0755); + bool is_iphone = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone; self.nib_name = is_iphone ? @"ViewController_iPhone" : @"ViewController_iPad"; + + self.file_icon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ic_file" ofType:@"png"]]; + self.folder_icon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ic_dir" ofType:@"png"]]; + self.navigator = [[UINavigationController alloc] initWithNibName:self.nib_name bundle:nil]; [self.navigator pushViewController: [[module_list alloc] initWithNibName:self.nib_name bundle:nil] animated:YES]; diff --git a/ios/RetroArch/directory_list.m b/ios/RetroArch/directory_list.m index 3e8d2b04be..33a3e8f5f4 100644 --- a/ios/RetroArch/directory_list.m +++ b/ios/RetroArch/directory_list.m @@ -14,9 +14,6 @@ UITableView* table; struct dirent_list* files; - - UIImage* file_icon; - UIImage* folder_icon; }; - (id)load_path:(const char*)directory @@ -43,9 +40,6 @@ { [super viewDidLoad]; - file_icon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ic_file" ofType:@"png"]]; - folder_icon = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ic_dir" ofType:@"png"]]; - table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 640, 480) style:UITableViewStylePlain]; table.dataSource = self; table.delegate = self; @@ -102,7 +96,7 @@ { cell.textLabel.text = [[NSString string] initWithUTF8String:item->d_name]; cell.accessoryType = (item->d_type) ? UITableViewCellAccessoryDisclosureIndicator : UITableViewCellAccessoryNone; - cell.imageView.image = (item->d_type) ? folder_icon : file_icon; + cell.imageView.image = (item->d_type) ? [RetroArch_iOS get].folder_icon : [RetroArch_iOS get].file_icon; [cell.imageView sizeToFit]; } diff --git a/ios/RetroArch/game_view.m b/ios/RetroArch/game_view.m index ef1e8b77ba..95c3aa46f8 100644 --- a/ios/RetroArch/game_view.m +++ b/ios/RetroArch/game_view.m @@ -26,15 +26,16 @@ void ios_load_game(const char* file_name) { if(!ra_initialized && file_name) { + const char* const sd = [RetroArch_iOS get].system_directory; const char* libretro = [[RetroArch_iOS get].module_path UTF8String]; - const char* overlay = [[[NSBundle mainBundle] pathForResource:@"overlay" ofType:@"cfg"] UTF8String]; - - printf("%s\n", overlay); - strcpy(g_settings.input.overlay, overlay ? overlay : ""); + char config_path[PATH_MAX]; + snprintf(config_path, PATH_MAX, "%s/retroarch.cfg", sd); + config_path[PATH_MAX - 1] = 0; + bool have_config = 0 == access(config_path, R_OK); - const char* argv[] = {"retroarch", "-L", libretro, file_name, 0}; - if (rarch_main_init(6, (char**)argv) == 0) + struct rarch_main_wrap main_wrapper = {file_name, sd, sd, have_config ? config_path : 0, libretro}; + if (rarch_main_init_wrap(&main_wrapper) == 0) { rarch_init_msg_queue(); ra_initialized = TRUE;