(iOS) Remove config file wrapper all together.

This commit is contained in:
meancoot 2013-03-20 19:07:00 -04:00
parent d4664f47d9
commit 4f15a7d77c
9 changed files with 63 additions and 136 deletions

View File

@ -43,7 +43,6 @@
96AFAE3016C1D4EA009DE44C /* GLKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE2F16C1D4EA009DE44C /* GLKit.framework */; };
96AFAE3216C1D4EA009DE44C /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE3116C1D4EA009DE44C /* OpenGLES.framework */; };
96AFAE3816C1D4EA009DE44C /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 96AFAE3616C1D4EA009DE44C /* InfoPlist.strings */; };
96C19C3016D7045700FE8D5A /* config_file_helper.c in Sources */ = {isa = PBXBuildFile; fileRef = 96C19C2F16D7045700FE8D5A /* config_file_helper.c */; };
96F9C26A16F7D9E2002455B3 /* btdynamic.c in Sources */ = {isa = PBXBuildFile; fileRef = 96F9C26816F7D9E2002455B3 /* btdynamic.c */; };
D48581DE16F823F9004BEB17 /* griffin.c in Sources */ = {isa = PBXBuildFile; fileRef = D48581DD16F823F9004BEB17 /* griffin.c */; };
/* End PBXBuildFile section */
@ -108,8 +107,6 @@
96AFAF4516C1E00A009DE44C /* bitmap.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; path = bitmap.bin; sourceTree = "<group>"; };
96AFAF4616C1E00A009DE44C /* bitmap.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; path = bitmap.bmp; sourceTree = "<group>"; };
96C19C2616D455BE00FE8D5A /* rarch_wrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rarch_wrapper.h; sourceTree = "<group>"; };
96C19C2E16D7045600FE8D5A /* config_file_helper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = config_file_helper.h; sourceTree = "<group>"; };
96C19C2F16D7045700FE8D5A /* config_file_helper.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = config_file_helper.c; sourceTree = "<group>"; };
96F9C26816F7D9E2002455B3 /* btdynamic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = btdynamic.c; sourceTree = "<group>"; };
96F9C26916F7D9E2002455B3 /* btdynamic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = btdynamic.h; sourceTree = "<group>"; };
D48581DD16F823F9004BEB17 /* griffin.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = griffin.c; path = ../griffin/griffin.c; sourceTree = "<group>"; };
@ -256,8 +253,6 @@
966B9C8516E40D44005B61E1 /* input */,
96366C6F16CAF62200D64A22 /* settings */,
96297A0E16C5AEA100E6DCE0 /* main.m */,
96C19C2E16D7045600FE8D5A /* config_file_helper.h */,
96C19C2F16D7045700FE8D5A /* config_file_helper.c */,
963F5AC516CC523B009BBD19 /* RAGameView.m */,
96096DD716D1ABAF00BF4499 /* RAModuleInfoList.m */,
96C19C2616D455BE00FE8D5A /* rarch_wrapper.h */,
@ -408,7 +403,6 @@
963F5AC316CC522F009BBD19 /* RASettingsList.m in Sources */,
963F5AC816CC523B009BBD19 /* RAGameView.m in Sources */,
96096DD816D1ABAF00BF4499 /* RAModuleInfoList.m in Sources */,
96C19C3016D7045700FE8D5A /* config_file_helper.c in Sources */,
966B9CA216E418B7005B61E1 /* BTDevice.m in Sources */,
966B9CA416E418B7005B61E1 /* BTstackManager.m in Sources */,
966B9CA616E418B7005B61E1 /* wiimote.c in Sources */,

View File

@ -18,18 +18,24 @@
{
RAModuleInfo* new = [RAModuleInfo new];
char* dispname = ios_config_get_string(theData, "display_name", [[[thePath lastPathComponent] stringByDeletingPathExtension] UTF8String]);
char* confpath = ios_config_get_string(theData, "supported_extensions", "");
char* dispname = 0;
char* extensions = 0;
if (theData)
{
config_get_string(theData, "display_name", &dispname);
config_get_string(theData, "supported_extensions", &extensions);
}
new.displayName = [NSString stringWithUTF8String:dispname];
new.displayName = dispname ? [NSString stringWithUTF8String:dispname] : [[thePath lastPathComponent] stringByDeletingPathExtension];
new.path = thePath;
new.configPath = [NSString stringWithFormat:@"%@/%@.cfg", [RetroArch_iOS get].system_directory, [[thePath lastPathComponent] stringByDeletingPathExtension]];
new.data = theData;
new.supportedExtensions = [[NSString stringWithUTF8String:confpath] componentsSeparatedByString:@"|"];
new.supportedExtensions = extensions ? [[NSString stringWithUTF8String:extensions] componentsSeparatedByString:@"|"] : [NSArray array];
free(dispname);
free(confpath);
free(extensions);
return new;
}
@ -47,7 +53,7 @@
@end
static NSString* const labels[3] = {@"Emulator Name", @"Manufacturer", @"Name"};
static NSString* const keys[3] = {@"emuname", @"manufacturer", @"systemname"};
static const char* const keys[3] = {"emuname", "manufacturer", "systemname"};
static NSString* const sectionNames[2] = {@"Emulator", @"Hardware"};
static const uint32_t sectionSizes[2] = {1, 2};
@ -92,8 +98,11 @@ static const uint32_t sectionSizes[2] = {1, 2};
cell.textLabel.text = labels[sectionBase + indexPath.row];
char* val = ios_config_get_string(_data.data, [keys[sectionBase + indexPath.row] UTF8String], "Unspecified");
cell.detailTextLabel.text = [NSString stringWithUTF8String:val];
char* val = 0;
if (_data.data)
config_get_string(_data.data, keys[sectionBase + indexPath.row], &val);
cell.detailTextLabel.text = val ? [NSString stringWithUTF8String:val] : @"Unspecified";
free(val);
return cell;

View File

@ -126,7 +126,8 @@
// Read load time settings
config_file_t* conf = config_file_new([self.moduleInfo.configPath UTF8String]);
if (ios_config_get_bool(conf, "ios_auto_bluetooth", false))
bool autoStartBluetooth = false;
if (conf && config_get_bool(conf, "ios_auto_bluetooth", &autoStartBluetooth) && autoStartBluetooth)
[self startBluetooth];
config_file_free(conf);

View File

@ -13,27 +13,36 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#import "config_file_helper.h"
#import "conf/config_file.h"
#import "browser.h"
@implementation RADirectoryGrid
{
NSString* _path;
NSArray* _list;
config_file_t* _config;
}
- (id)initWithPath:(NSString*)path
{
_path = path;
_config = config_file_new([[path stringByAppendingPathComponent:@".raconfig"] UTF8String]);
_list = ra_ios_list_directory(_path);
[self setTitle: [_path lastPathComponent]];
unsigned tileWidth = 100;
unsigned tileHeight = 100;
config_file_t* config = config_file_new([[path stringByAppendingPathComponent:@".raconfig"] UTF8String]);
if (config)
{
config_get_uint(config, "cover_width", &tileWidth);
config_get_uint(config, "cover_height", &tileHeight);
config_file_free(config);
}
// Init collection view
UICollectionViewFlowLayout* layout = [UICollectionViewFlowLayout new];
layout.itemSize = CGSizeMake(ios_config_get_uint(_config, "cover_width", 100), ios_config_get_uint(_config, "cover_height", 100));
layout.itemSize = CGSizeMake(tileWidth, tileHeight);
self = [super initWithCollectionViewLayout:layout];
[self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"dircell"];
@ -43,11 +52,6 @@
return self;
}
- (void)dealloc
{
config_file_free(_config);
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 1;

View File

@ -1,64 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2013 - Jason Fetters
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#import "config_file_helper.h"
bool ios_config_get_bool(config_file_t* config, const char* name, bool default_)
{
if (!config) return default_;
bool result = default_;
config_get_bool(config, name, &result);
return result;
}
unsigned ios_config_get_uint(config_file_t* config, const char* name, unsigned default_)
{
if (!config) return default_;
unsigned result = default_;
config_get_uint(config, name, &result);
return result;
}
double ios_config_get_double(config_file_t* config, const char* name, double default_)
{
if (!config) return default_;
double result = default_;
config_get_double(config, name, &result);
return result;
}
char* ios_config_get_string(config_file_t* config, const char* name, const char* default_)
{
if (config)
{
char* result = 0;
if (config_get_string(config, name, &result))
return result;
}
return default_ ? strdup(default_) : 0;
}
void ios_config_set_string(config_file_t* config, const char* name, const char* value)
{
if (!config)
return;
config_set_string(config, name, value);
}

View File

@ -1,31 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2013 - Jason Fetters
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __IOS_RARCH_CONFIG_H__
#define __IOS_RARCH_CONFIG_H__
#include "conf/config_file.h"
bool ios_config_get_bool(config_file_t* config, const char* name, bool default_);
unsigned ios_config_get_uint(config_file_t* config, const char* name, unsigned default_);
double ios_config_get_double(config_file_t* config, const char* name, double default_);
// You must free the result, even if it returns default_!
char* ios_config_get_string(config_file_t* config, const char* name, const char* default_);
void ios_config_set_string(config_file_t* config, const char* name, const char* value);
#endif

View File

@ -28,8 +28,11 @@
static NSString* get_value_from_config(config_file_t* config, NSString* name, NSString* defaultValue)
{
char* data = ios_config_get_string(config, [name UTF8String], [defaultValue UTF8String]);
NSString* result = [NSString stringWithUTF8String:data];
char* data = 0;
if (config)
config_get_string(config, [name UTF8String], &data);
NSString* result = data ? [NSString stringWithUTF8String:data] : defaultValue;
free(data);
return result;
}
@ -88,9 +91,16 @@ static RASettingData* aspect_setting(config_file_t* config, NSString* label)
RASettingData* result = [[RASettingData alloc] initWithType:AspectSetting label:label name:@"fram"];
result.subValues = [NSArray arrayWithObjects:@"Fill Screen", @"Game Aspect", @"Pixel Aspect", @"4:3", @"16:9", nil];
bool videoForceAspect = ios_config_get_bool(config, "video_force_aspect", true);
bool videoAspectAuto = ios_config_get_bool(config, "video_aspect_ratio_auto", false);
double videoAspect = ios_config_get_double(config, "video_aspect_ratio", 0.0);
bool videoForceAspect = true;
bool videoAspectAuto = false;
double videoAspect = -1.0;
if (config)
{
config_get_bool(config, "video_force_aspect", &videoForceAspect);
config_get_bool(config, "video_aspect_auto", &videoAspectAuto);
config_get_double(config, "video_aspect_ratio", &videoAspect);
}
if (!videoForceAspect)
result.value = @"Fill Screen";
@ -200,7 +210,8 @@ static RASettingData* custom_action(NSString* action)
if (!config)
config = config_file_new(0);
ios_config_set_string(config, "system_directory", [[RetroArch_iOS get].system_directory UTF8String]);
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]);

View File

@ -39,6 +39,9 @@ static const char* const SETTINGID = "SETTING";
- (void)writeSettings:(NSArray*)settingList toConfig:(config_file_t*)config
{
if (!config)
return;
NSArray* list = settingList ? settingList : settings;
for (int i = 0; i != [list count]; i ++)
@ -57,33 +60,33 @@ static const char* const SETTINGID = "SETTING";
case FileListSetting:
if ([setting.value length] > 0)
ios_config_set_string(config, [setting.name UTF8String], [[setting.path stringByAppendingPathComponent:setting.value] UTF8String]);
config_set_string(config, [setting.name UTF8String], [[setting.path stringByAppendingPathComponent:setting.value] UTF8String]);
else
ios_config_set_string(config, [setting.name UTF8String], "");
config_set_string(config, [setting.name UTF8String], "");
break;
case ButtonSetting:
if (setting.msubValues[0] && [setting.msubValues[0] length])
ios_config_set_string(config, [setting.name UTF8String], [setting.msubValues[0] UTF8String]);
config_set_string(config, [setting.name UTF8String], [setting.msubValues[0] UTF8String]);
if (setting.msubValues[1] && [setting.msubValues[1] length])
ios_config_set_string(config, [[setting.name stringByAppendingString:@"_btn"] UTF8String], [setting.msubValues[1] UTF8String]);
config_set_string(config, [[setting.name stringByAppendingString:@"_btn"] UTF8String], [setting.msubValues[1] UTF8String]);
break;
case AspectSetting:
ios_config_set_string(config, "video_force_aspect", [@"Fill Screen" isEqualToString:setting.value] ? "false" : "true");
ios_config_set_string(config, "video_aspect_ratio_auto", [@"Game Aspect" isEqualToString:setting.value] ? "true" : "false");
ios_config_set_string(config, "video_aspect_ratio", "-1.0");
config_set_string(config, "video_force_aspect", [@"Fill Screen" isEqualToString:setting.value] ? "false" : "true");
config_set_string(config, "video_aspect_ratio_auto", [@"Game Aspect" isEqualToString:setting.value] ? "true" : "false");
config_set_string(config, "video_aspect_ratio", "-1.0");
if([@"4:3" isEqualToString:setting.value])
ios_config_set_string(config, "video_aspect_ratio", "1.33333333");
config_set_string(config, "video_aspect_ratio", "1.33333333");
else if([@"16:9" isEqualToString:setting.value])
ios_config_set_string(config, "video_aspect_ratio", "1.77777777");
config_set_string(config, "video_aspect_ratio", "1.77777777");
break;
case CustomAction:
break;
default:
ios_config_set_string(config, [setting.name UTF8String], [setting.value UTF8String]);
config_set_string(config, [setting.name UTF8String], [setting.value UTF8String]);
break;
}
}

View File

@ -16,7 +16,7 @@
#import <UIKit/UIKit.h>
#import <GLKit/GLKit.h>
#import "config_file_helper.h"
#include "conf/config_file.h"
@interface RAGameView : UIViewController
+ (RAGameView*)get;