diff --git a/ios/Assets/PauseView.xib b/ios/Assets/PauseView.xib index 238b0695a3..b9fdd78b01 100644 --- a/ios/Assets/PauseView.xib +++ b/ios/Assets/PauseView.xib @@ -2,10 +2,10 @@ 1552 - 12C60 + 12D78 3084 - 1187.34 - 625.00 + 1187.37 + 626.00 com.apple.InterfaceBuilder.IBCocoaTouchPlugin 2083 @@ -42,7 +42,7 @@ 292 {{160, 237}, {120, 44}} - + _NS:9 NO IBIPadFramework @@ -77,6 +77,7 @@ 292 {{20, 20}, {260, 44}} + _NS:9 NO @@ -99,6 +100,7 @@ 292 {{20, 237}, {120, 44}} + _NS:9 NO @@ -121,6 +123,7 @@ 292 {{20, 186}, {120, 44}} + _NS:9 NO @@ -143,6 +146,7 @@ 292 {{160, 186}, {120, 44}} + _NS:9 NO @@ -165,6 +169,7 @@ 292 {{20, 135}, {260, 44}} + _NS:9 NO @@ -236,8 +241,32 @@ 292 - {{20, 71}, {260, 44}} + {{20, 71}, {120, 44}} + + + _NS:9 + NO + IBIPadFramework + 0 + 0 + 1 + System Config + + + 1 + MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA + + + + + + + + 292 + {{160, 71}, {120, 44}} + + _NS:9 NO @@ -245,7 +274,7 @@ 0 0 1 - Settings + Core Config 1 @@ -258,6 +287,7 @@ {{0, 20}, {300, 300}} + 3 @@ -336,12 +366,21 @@ - showSettings + showSystemSettings 7 - 148 + 166 + + + + showSettings + + + 7 + + 154 @@ -484,6 +523,22 @@ 29 3 + + + 6 + 0 + + 6 + 1 + + 0.0 + + 1000 + + 6 + 24 + 2 + 3 @@ -532,6 +587,54 @@ 29 3 + + + 11 + 0 + + 11 + 1 + + 0.0 + + 1000 + + 6 + 24 + 2 + + + + 6 + 0 + + 6 + 1 + + 20 + + 1000 + + 8 + 29 + 3 + + + + 5 + 0 + + 5 + 1 + + 0.0 + + 1000 + + 6 + 24 + 2 + 6 @@ -580,22 +683,6 @@ 29 3 - - - 6 - 0 - - 6 - 1 - - 20 - - 1000 - - 8 - 29 - 3 - 3 @@ -666,6 +753,7 @@ + @@ -702,24 +790,7 @@ 86 - - - - 7 - 0 - - 0 - 1 - - 120 - - 1000 - - 3 - 9 - 1 - - + @@ -752,26 +823,11 @@ - - 115 - - - - - 116 - - - 118 - - 119 - - - 121 @@ -780,24 +836,7 @@ 122 - - - - 7 - 0 - - 0 - 1 - - 120 - - 1000 - - 3 - 9 - 1 - - + @@ -815,11 +854,6 @@ - - 130 - - - 131 @@ -843,7 +877,24 @@ 140 - + + + + 7 + 0 + + 0 + 1 + + 120 + + 1000 + + 3 + 9 + 1 + + @@ -852,13 +903,71 @@ - 143 + 146 + + + + + 149 + + + + + 151 + + + + + 152 + + + + + 7 + 0 + + 0 + 1 + + 120 + + 1000 + + 3 + 9 + 1 + + + + + + 153 + + + + + 157 + + + + + 158 - 146 - + 160 + + + + + 115 + + + + + 116 + @@ -874,13 +983,16 @@ - + + + + @@ -894,19 +1006,14 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -914,18 +1021,28 @@ com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin - com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + + + + + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin + com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin - - - com.apple.InterfaceBuilder.IBCocoaTouchPlugin com.apple.InterfaceBuilder.IBCocoaTouchPlugin @@ -937,9 +1054,72 @@ - 148 + 166 + + + + + NSLayoutConstraint + NSObject + + IBProjectSource + ./Classes/NSLayoutConstraint.h + + + + RetroArch_iOS + UINavigationController + + id + id + id + id + id + id + id + id + + + + chooseState: + id + + + closeGamePressed: + id + + + closePauseMenu: + id + + + loadState: + id + + + resetGame: + id + + + saveState: + id + + + showPauseMenu: + id + + + showSettings + id + + + + IBProjectSource + ./Classes/RetroArch_iOS.h + + + - 0 IBIPadFramework YES diff --git a/ios/RetroArch/RetroArch_iOS.h b/ios/RetroArch/RetroArch_iOS.h index 08bae16b3d..47b3597668 100644 --- a/ios/RetroArch/RetroArch_iOS.h +++ b/ios/RetroArch/RetroArch_iOS.h @@ -20,12 +20,12 @@ + (void)displayErrorMessage:(NSString*)message; + (RetroArch_iOS*)get; -- (void)runGame:(NSString*)path; + +- (void)runGame:(NSString*)path withModule:(RAModuleInfo*)module; - (void)refreshConfig; +- (void)refreshSystemConfig; -- (IBAction)showSettings; - -@property (strong, nonatomic) RAModuleInfo* moduleInfo; +@property (strong, nonatomic) NSString* systemConfigPath; @property (strong, nonatomic) NSString* system_directory; diff --git a/ios/RetroArch/browser/RAModuleList.m b/ios/RetroArch/browser/RAModuleList.m index ba524cc649..20766a9c4e 100644 --- a/ios/RetroArch/browser/RAModuleList.m +++ b/ios/RetroArch/browser/RAModuleList.m @@ -15,6 +15,7 @@ #import "RAMOduleInfo.h" #import "browser.h" +#import "settings.h" @implementation RAModuleList { @@ -79,14 +80,12 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - [RetroArch_iOS get].moduleInfo = [self moduleInfoForIndexPath:indexPath]; - [[RetroArch_iOS get] runGame:_game]; + [RetroArch_iOS.get runGame:_game withModule:[self moduleInfoForIndexPath:indexPath]]; } - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { - [RetroArch_iOS get].moduleInfo = [self moduleInfoForIndexPath:indexPath]; - [[RetroArch_iOS get] showSettings]; + [RetroArch_iOS.get pushViewController:[[RASettingsList alloc] initWithModule:[self moduleInfoForIndexPath:indexPath]] animated:YES]; } - (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath diff --git a/ios/RetroArch/main.m b/ios/RetroArch/main.m index f3d9496ec4..fe86a05fdb 100644 --- a/ios/RetroArch/main.m +++ b/ios/RetroArch/main.m @@ -269,6 +269,8 @@ static void event_reload_config(void* userdata) bool _isGameTop; bool _isPaused; bool _isRunning; + + RAModuleInfo* _module; } + (void)displayErrorMessage:(NSString*)message @@ -290,6 +292,7 @@ static void event_reload_config(void* userdata) - (void)applicationDidFinishLaunching:(UIApplication *)application { self.system_directory = [NSString stringWithFormat:@"%@/.RetroArch", kDOCSFOLDER]; + self.systemConfigPath = [NSString stringWithFormat:@"%@/.RetroArch/frontend.cfg", kDOCSFOLDER]; mkdir([self.system_directory UTF8String], 0755); // Setup window @@ -333,21 +336,21 @@ static void event_reload_config(void* userdata) } #pragma mark EMULATION -- (void)runGame:(NSString*)path +- (void)runGame:(NSString*)path withModule:(RAModuleInfo*)module { if (_isRunning) return; - assert(self.moduleInfo); + _module = module; - [RASettingsList refreshConfigFile]; + [RASettingsList refreshModuleConfig:module]; [self pushViewController:RAGameView.get animated:NO]; _isRunning = true; const char* const sd = [[RetroArch_iOS get].system_directory UTF8String]; - const char* const cf = (ra_ios_is_file(self.moduleInfo.configPath)) ? [self.moduleInfo.configPath UTF8String] : 0; - const char* const libretro = [self.moduleInfo.path UTF8String]; + const char* const cf = (ra_ios_is_file(_module.configPath)) ? [_module.configPath UTF8String] : 0; + const char* const libretro = [_module.path UTF8String]; struct rarch_main_wrap* load_data = malloc(sizeof(struct rarch_main_wrap)); load_data->libretro_path = strdup(libretro); @@ -362,16 +365,8 @@ static void event_reload_config(void* userdata) return; } pthread_detach(_retroThread); - - // Read load time settings - // TODO: Do this better - config_file_t* conf = config_file_new([self.moduleInfo.configPath UTF8String]); - bool autoStartBluetooth = false; - if (conf && config_get_bool(conf, "ios_auto_bluetooth", &autoStartBluetooth) && autoStartBluetooth) - [self startBluetooth]; - if (conf) - config_get_bool(conf, "ios_use_icade", &use_icade); - config_file_free(conf); + + [self refreshSystemConfig]; } - (void)rarchExited:(BOOL)successful @@ -392,6 +387,8 @@ static void event_reload_config(void* userdata) [self popToViewController:[RAGameView get] animated:NO]; [self popViewControllerAnimated:NO]; } + + _module = nil; } - (void)refreshConfig @@ -406,6 +403,22 @@ static void event_reload_config(void* userdata) } } +- (void)refreshSystemConfig +{ + // Read load time settings + // TODO: Do this better + config_file_t* conf = config_file_new([self.systemConfigPath UTF8String]); + + bool autoStartBluetooth = false; + if (conf && config_get_bool(conf, "ios_auto_bluetooth", &autoStartBluetooth) && autoStartBluetooth) + [self startBluetooth]; + + if (conf) + config_get_bool(conf, "ios_use_icade", &use_icade); + + config_file_free(conf); +} + #pragma mark PAUSE MENU - (IBAction)showPauseMenu:(id)sender { @@ -460,7 +473,13 @@ static void event_reload_config(void* userdata) - (IBAction)showSettings { - [self pushViewController:[RASettingsList new] animated:YES]; + if (_module) + [self pushViewController:[[RASettingsList alloc] initWithModule:_module] animated:YES]; +} + +- (IBAction)showSystemSettings +{ + [self pushViewController:[RASystemSettingsList new] animated:YES]; } #pragma mark Bluetooth Helpers diff --git a/ios/RetroArch/settings/settings.h b/ios/RetroArch/settings/settings.h index f834889524..2838072bf4 100644 --- a/ios/RetroArch/settings/settings.h +++ b/ios/RetroArch/settings/settings.h @@ -48,10 +48,14 @@ enum SettingTypes @interface RASettingsSubList : UITableViewController - (id)initWithSettings:(NSArray*)values title:(NSString*)title; -- (void)handleCustomAction:(NSString*)action; +- (void)handleCustomAction:(NSString*)action withUserData:(id)data; - (void)writeSettings:(NSArray*)settingList toConfig:(config_file_t*)config; @end @interface RASettingsList : RASettingsSubList -+ (void)refreshConfigFile; ++ (void)refreshModuleConfig:(RAModuleInfo*)module; +- (id)initWithModule:(RAModuleInfo*)module; @end + +@interface RASystemSettingsList : RASettingsSubList +@end \ No newline at end of file diff --git a/ios/RetroArch/settings/settings.m b/ios/RetroArch/settings/settings.m index ed927d5125..532d0e3284 100644 --- a/ios/RetroArch/settings/settings.m +++ b/ios/RetroArch/settings/settings.m @@ -127,30 +127,38 @@ static RASettingData* aspect_setting(config_file_t* config, NSString* label) return result; } -static RASettingData* custom_action(NSString* action) +static RASettingData* custom_action(NSString* action, id data) { - return [[RASettingData alloc] initWithType:CustomAction label:action name:nil]; + RASettingData* result = [[RASettingData alloc] initWithType:CustomAction label:action name:nil]; + + if (data != nil) + objc_setAssociatedObject(result, "USERDATA", data, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + + return result; } @implementation RASettingsList -+ (void)refreshConfigFile { - (void)[[RASettingsList alloc] init]; + RAModuleInfo* _module; } -- (id)init ++ (void)refreshModuleConfig:(RAModuleInfo*)module; { - config_file_t* config = config_file_new([[RetroArch_iOS get].moduleInfo.configPath UTF8String]); + (void)[[RASettingsList alloc] initWithModule:module]; +} + +- (id)initWithModule:(RAModuleInfo*)module +{ + _module = module; + + config_file_t* config = config_file_new([_module.configPath UTF8String]); NSString* overlay_path = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/overlays/"]; NSString* shader_path = [[[NSBundle mainBundle] bundlePath] stringByAppendingString:@"/shaders/"]; NSArray* settings = [NSArray arrayWithObjects: - [NSArray arrayWithObjects:@"Frontend", - custom_action(@"Module Info"), - custom_action(@"Diagnostic Log"), - boolean_setting(config, @"ios_auto_bluetooth", @"Auto Enable Bluetooth", @"false"), - boolean_setting(config, @"ios_use_icade", @"Native BT is iCade", @"false"), + [NSArray arrayWithObjects:@"Core", + custom_action(@"Core Info", nil), nil], [NSArray arrayWithObjects:@"Video", @@ -236,32 +244,87 @@ static RASettingData* custom_action(NSString* action) nil ]; - self = [super initWithSettings:settings title:@"RetroArch Settings"]; + self = [super initWithSettings:settings title:_module.displayName]; return self; } - (void)dealloc { - config_file_t* config = config_file_new([[RetroArch_iOS get].moduleInfo.configPath UTF8String]); + config_file_t* config = config_file_new([_module.configPath UTF8String]); if (!config) config = config_file_new(0); config_set_string(config, "system_directory", [[RetroArch_iOS get].system_directory UTF8String]); [self writeSettings:nil toConfig:config]; - if (config) - config_file_write(config, [[RetroArch_iOS get].moduleInfo.configPath UTF8String]); + if (config) + config_file_write(config, [_module.configPath UTF8String]); config_file_free(config); - + [[RetroArch_iOS get] refreshConfig]; } -- (void)handleCustomAction:(NSString*)action +- (void)handleCustomAction:(NSString*)action withUserData:(id)data { - if ([@"Module Info" isEqualToString:action]) - [[RetroArch_iOS get] pushViewController:[[RAModuleInfoList alloc] initWithModuleInfo:[RetroArch_iOS get].moduleInfo] animated:YES]; - else if ([@"Diagnostic Log" isEqualToString:action]) + if ([@"Core Info" isEqualToString:action]) + [[RetroArch_iOS get] pushViewController:[[RAModuleInfoList alloc] initWithModuleInfo:_module] animated:YES]; +} + +@end + +@implementation RASystemSettingsList +- (id)init +{ + config_file_t* config = config_file_new([[RetroArch_iOS get].systemConfigPath UTF8String]); + + NSMutableArray* modules = [NSMutableArray array]; + [modules addObject:@"Cores"]; + + NSArray* module_data = [RAModuleInfo getModules]; + for (int i = 0; i != module_data.count; i ++) + { + RAModuleInfo* info = (RAModuleInfo*)module_data[i]; + [modules addObject:custom_action(info.displayName, info)]; + } + + NSArray* settings = [NSArray arrayWithObjects: + [NSArray arrayWithObjects:@"Frontend", + custom_action(@"Diagnostic Log", nil), + nil], + [NSArray arrayWithObjects:@"Bluetooth", + boolean_setting(config, @"ios_use_icade", @"Native BT is iCade", @"false"), + boolean_setting(config, @"ios_auto_bluetooth", @"Auto Enable BTstack", @"false"), + nil], + modules, + nil + ]; + + self = [super initWithSettings:settings title:@"RetroArch Settings"]; + return self; +} + +- (void)dealloc +{ + config_file_t* config = config_file_new([[RetroArch_iOS get].systemConfigPath UTF8String]); + + if (!config) + config = config_file_new(0); + + [self writeSettings:nil toConfig:config]; + + if (config) + config_file_write(config, [[RetroArch_iOS get].systemConfigPath UTF8String]); + config_file_free(config); + + [[RetroArch_iOS get] refreshSystemConfig]; +} + +- (void)handleCustomAction:(NSString*)action withUserData:(id)data +{ + if ([@"Diagnostic Log" isEqualToString:action]) [[RetroArch_iOS get] pushViewController:[RALogView new] animated:YES]; + else if (data) + [[RetroArch_iOS get] pushViewController:[[RASettingsList alloc] initWithModule:(RAModuleInfo*)data] animated:YES]; } @end @@ -280,7 +343,7 @@ static RASettingData* custom_action(NSString* action) return self; } -- (void)handleCustomAction:(NSString*)action +- (void)handleCustomAction:(NSString*)action withUserData:(id)data { } @@ -364,7 +427,7 @@ static RASettingData* custom_action(NSString* action) break; case CustomAction: - [self handleCustomAction:setting.label]; + [self handleCustomAction:setting.label withUserData:objc_getAssociatedObject(setting, "USERDATA")]; break; default: