ios: Add a module selector.

This commit is contained in:
meancoot 2013-02-08 17:03:19 -05:00
parent 23a3fe63bf
commit 83f0a9ec38
12 changed files with 157 additions and 86 deletions

View File

@ -13,7 +13,8 @@
962979F616C43B9500E6DCE0 /* ic_dir.png in Resources */ = {isa = PBXBuildFile; fileRef = 962979F416C43B9500E6DCE0 /* ic_dir.png */; };
962979F716C43B9500E6DCE0 /* ic_file.png in Resources */ = {isa = PBXBuildFile; fileRef = 962979F516C43B9500E6DCE0 /* ic_file.png */; };
96297A0116C4767F00E6DCE0 /* dirent_list.c in Sources */ = {isa = PBXBuildFile; fileRef = 962979FF16C4767F00E6DCE0 /* dirent_list.c */; };
96297A0516C4996400E6DCE0 /* browser.m in Sources */ = {isa = PBXBuildFile; fileRef = 96297A0416C4996400E6DCE0 /* browser.m */; };
96297A0916C59EC000E6DCE0 /* module_list.m in Sources */ = {isa = PBXBuildFile; fileRef = 96297A0816C59EC000E6DCE0 /* module_list.m */; };
96297A0C16C5AD8D00E6DCE0 /* RetroArch_iOS.m in Sources */ = {isa = PBXBuildFile; fileRef = 96297A0B16C5AD8D00E6DCE0 /* RetroArch_iOS.m */; };
96AFAE2A16C1D4EA009DE44C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE2916C1D4EA009DE44C /* UIKit.framework */; };
96AFAE2C16C1D4EA009DE44C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE2B16C1D4EA009DE44C /* Foundation.framework */; };
96AFAE2E16C1D4EA009DE44C /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE2D16C1D4EA009DE44C /* CoreGraphics.framework */; };
@ -21,7 +22,6 @@
96AFAE3216C1D4EA009DE44C /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96AFAE3116C1D4EA009DE44C /* OpenGLES.framework */; };
96AFAE3816C1D4EA009DE44C /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 96AFAE3616C1D4EA009DE44C /* InfoPlist.strings */; };
96AFAE3A16C1D4EA009DE44C /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAE3916C1D4EA009DE44C /* main.mm */; };
96AFAE3E16C1D4EA009DE44C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAE3D16C1D4EA009DE44C /* AppDelegate.m */; };
96AFAE4016C1D4EA009DE44C /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 96AFAE3F16C1D4EA009DE44C /* Default.png */; };
96AFAE4216C1D4EA009DE44C /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 96AFAE4116C1D4EA009DE44C /* Default@2x.png */; };
96AFAE4416C1D4EA009DE44C /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 96AFAE4316C1D4EA009DE44C /* Default-568h@2x.png */; };
@ -75,7 +75,6 @@
96AFAFAD16C1EEE9009DE44C /* sinc.c in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAEF716C1DC73009DE44C /* sinc.c */; };
96AFAFD416C1FBC0009DE44C /* input_common.c in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAFC916C1FBC0009DE44C /* input_common.c */; };
96AFAFD716C1FBC0009DE44C /* null.c in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAFCD16C1FBC0009DE44C /* null.c */; };
96CF014F16C2BB9E00ABF9C9 /* libretro.dylib in Resources */ = {isa = PBXBuildFile; fileRef = 96CF014A16C2BA1900ABF9C9 /* libretro.dylib */; };
96CF015016C2C0B700ABF9C9 /* overlay.c in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAFCE16C1FBC0009DE44C /* overlay.c */; };
96CF015C16C2F72900ABF9C9 /* ios_input.c in Sources */ = {isa = PBXBuildFile; fileRef = 96CF015B16C2F72900ABF9C9 /* ios_input.c */; };
/* End PBXBuildFile section */
@ -90,8 +89,10 @@
962979F516C43B9500E6DCE0 /* ic_file.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ic_file.png; path = "../android/phoenix/res/drawable-xhdpi/ic_file.png"; sourceTree = "<group>"; };
962979FF16C4767F00E6DCE0 /* dirent_list.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dirent_list.c; sourceTree = "<group>"; };
96297A0016C4767F00E6DCE0 /* dirent_list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = dirent_list.h; sourceTree = "<group>"; };
96297A0316C4996400E6DCE0 /* browser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = browser.h; sourceTree = "<group>"; };
96297A0416C4996400E6DCE0 /* browser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = browser.m; sourceTree = "<group>"; };
96297A0716C59EC000E6DCE0 /* module_list.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = module_list.h; sourceTree = "<group>"; };
96297A0816C59EC000E6DCE0 /* module_list.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = module_list.m; sourceTree = "<group>"; };
96297A0A16C5AD8D00E6DCE0 /* RetroArch_iOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RetroArch_iOS.h; sourceTree = "<group>"; };
96297A0B16C5AD8D00E6DCE0 /* RetroArch_iOS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RetroArch_iOS.m; sourceTree = "<group>"; };
96AFAE2516C1D4EA009DE44C /* RetroArch.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RetroArch.app; sourceTree = BUILT_PRODUCTS_DIR; };
96AFAE2916C1D4EA009DE44C /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
96AFAE2B16C1D4EA009DE44C /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
@ -102,8 +103,6 @@
96AFAE3716C1D4EA009DE44C /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
96AFAE3916C1D4EA009DE44C /* main.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = "<group>"; };
96AFAE3B16C1D4EA009DE44C /* RetroArch-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RetroArch-Prefix.pch"; sourceTree = "<group>"; };
96AFAE3C16C1D4EA009DE44C /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
96AFAE3D16C1D4EA009DE44C /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
96AFAE3F16C1D4EA009DE44C /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = "<group>"; };
96AFAE4116C1D4EA009DE44C /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = "<group>"; };
96AFAE4316C1D4EA009DE44C /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
@ -276,7 +275,6 @@
96AFAFD016C1FBC0009DE44C /* sdl_input.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sdl_input.c; sourceTree = "<group>"; };
96AFAFD116C1FBC0009DE44C /* sdl_joypad.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sdl_joypad.c; sourceTree = "<group>"; };
96AFAFD216C1FBC0009DE44C /* x11_input.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = x11_input.c; sourceTree = "<group>"; };
96CF014A16C2BA1900ABF9C9 /* libretro.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libretro.dylib; sourceTree = "<group>"; };
96CF015B16C2F72900ABF9C9 /* ios_input.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ios_input.c; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -303,7 +301,6 @@
children = (
962979F416C43B9500E6DCE0 /* ic_dir.png */,
962979F516C43B9500E6DCE0 /* ic_file.png */,
96CF014A16C2BA1900ABF9C9 /* libretro.dylib */,
96AFAF2116C1DF88009DE44C /* libz.dylib */,
96AFAF1E16C1DF0A009DE44C /* OpenAL.framework */,
96AFAE9C16C1D976009DE44C /* core */,
@ -336,20 +333,20 @@
96AFAE3316C1D4EA009DE44C /* RetroArch */ = {
isa = PBXGroup;
children = (
96297A0A16C5AD8D00E6DCE0 /* RetroArch_iOS.h */,
96297A0B16C5AD8D00E6DCE0 /* RetroArch_iOS.m */,
962979FF16C4767F00E6DCE0 /* dirent_list.c */,
96297A0016C4767F00E6DCE0 /* dirent_list.h */,
962979EB16C3E86F00E6DCE0 /* gameview.m */,
962979EC16C3E86F00E6DCE0 /* gameview.h */,
96AFAE3C16C1D4EA009DE44C /* AppDelegate.h */,
96AFAE3D16C1D4EA009DE44C /* AppDelegate.m */,
96AFAE4C16C1D4EA009DE44C /* ViewController_iPhone.xib */,
96AFAE4F16C1D4EA009DE44C /* ViewController_iPad.xib */,
96AFAE3416C1D4EA009DE44C /* Supporting Files */,
96CF015B16C2F72900ABF9C9 /* ios_input.c */,
9629797516C3CD2400E6DCE0 /* dirlist.h */,
9629797616C3CD2400E6DCE0 /* dirlist.m */,
96297A0316C4996400E6DCE0 /* browser.h */,
96297A0416C4996400E6DCE0 /* browser.m */,
96297A0716C59EC000E6DCE0 /* module_list.h */,
96297A0816C59EC000E6DCE0 /* module_list.m */,
);
path = RetroArch;
sourceTree = "<group>";
@ -731,7 +728,6 @@
96AFAE4416C1D4EA009DE44C /* Default-568h@2x.png in Resources */,
96AFAE4E16C1D4EA009DE44C /* ViewController_iPhone.xib in Resources */,
96AFAE5116C1D4EA009DE44C /* ViewController_iPad.xib in Resources */,
96CF014F16C2BB9E00ABF9C9 /* libretro.dylib in Resources */,
962979F616C43B9500E6DCE0 /* ic_dir.png in Resources */,
962979F716C43B9500E6DCE0 /* ic_file.png in Resources */,
);
@ -745,7 +741,6 @@
buildActionMask = 2147483647;
files = (
96AFAE3A16C1D4EA009DE44C /* main.mm in Sources */,
96AFAE3E16C1D4EA009DE44C /* AppDelegate.m in Sources */,
96AFAECA16C1D9A9009DE44C /* autosave.c in Sources */,
96AFAECB16C1D9A9009DE44C /* cheats.c in Sources */,
96AFAECC16C1D9A9009DE44C /* command.c in Sources */,
@ -798,7 +793,8 @@
962979ED16C3E86F00E6DCE0 /* gameview.m in Sources */,
962979EF16C3EA3E00E6DCE0 /* ioseagl_ctx.c in Sources */,
96297A0116C4767F00E6DCE0 /* dirent_list.c in Sources */,
96297A0516C4996400E6DCE0 /* browser.m in Sources */,
96297A0916C59EC000E6DCE0 /* module_list.m in Sources */,
96297A0C16C5AD8D00E6DCE0 /* RetroArch_iOS.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -1,14 +0,0 @@
//
// AppDelegate.h
// RetroArch
//
// Copyright (c) 2013 RetroArch. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end

View File

@ -11,4 +11,5 @@
#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "RetroArch_iOS.h"
#endif

View File

@ -0,0 +1,19 @@
//
// AppDelegate.h
// RetroArch
//
// Copyright (c) 2013 RetroArch. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface RetroArch_iOS : UIResponder <UIApplicationDelegate>
+ (RetroArch_iOS*)get;
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) NSString *module_path;
@property (strong, nonatomic) UINavigationController *navigator;
@property (strong, nonatomic) NSString *nib_name;
@end

View File

@ -5,9 +5,8 @@
// Copyright (c) 2013 RetroArch. All rights reserved.
//
#import "AppDelegate.h"
#import "dirlist.h"
#import "browser.h"
#import "module_list.h"
#define MAX_TOUCH 16
extern struct
@ -20,18 +19,23 @@ extern struct
extern uint32_t ios_current_touch_count ;
@implementation AppDelegate
@implementation RetroArch_iOS
+ (RetroArch_iOS*)get
{
return (RetroArch_iOS*)[[UIApplication sharedApplication] delegate];
}
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
bool is_iphone = [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone;
self.nib_name = is_iphone ? @"ViewController_iPhone" : @"ViewController_iPad";
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
self.window.rootViewController = [[browser alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
else
self.window.rootViewController = [[browser alloc] initWithNibName:@"ViewController_iPad" bundle:nil];
self.navigator = [[UINavigationController alloc] initWithNibName:self.nib_name bundle:nil];
[self.navigator pushViewController: [[module_list alloc] initWithNibName:self.nib_name bundle:nil] animated:YES];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = self.navigator;
[self.window makeKeyAndVisible];
}

View File

@ -1,14 +0,0 @@
//
// browser.h
// RetroArch
//
// Created by Jason Fetters on 2/7/13.
// Copyright (c) 2013 RetroArch. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIkit.h>
@interface browser : UINavigationController
@end

View File

@ -1,21 +0,0 @@
//
// browser.m
// RetroArch
//
// Created by Jason Fetters on 2/7/13.
// Copyright (c) 2013 RetroArch. All rights reserved.
//
#import "browser.h"
#import "dirlist.h"
@implementation browser
- (void)viewDidLoad
{
[super viewDidLoad];
[self pushViewController:[[[dirlist_view alloc] init] load_path:"/" ] animated:NO];
}
@end

View File

@ -75,16 +75,13 @@
{
strcat(new_path, "/");
UINavigationController *pvc = (UINavigationController*)self.parentViewController;
[pvc pushViewController:[[[dirlist_view alloc] init] load_path: new_path] animated:YES];
[[RetroArch_iOS get].navigator pushViewController:[[[dirlist_view alloc] init] load_path: new_path] animated:YES];
}
else
{
UIWindow *window = [UIApplication sharedApplication].keyWindow;
bool is_phone = ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone);
window.rootViewController = [[game_view alloc] initWithNibName:
(is_phone ? @"ViewController_iPhone" : @"ViewController_iPad") bundle:nil];
[RetroArch_iOS get].window.rootViewController = [[game_view alloc]
initWithNibName: [RetroArch_iOS get].nib_name
bundle:nil];
extern void ios_load_game(const char*);
ios_load_game(new_path);

View File

@ -27,8 +27,10 @@ void ios_load_game(const char* file_name)
{
if(!ra_initialized && file_name)
{
const char* libretro = [[[NSBundle mainBundle] pathForResource:@"libretro" ofType:@"dylib"] UTF8String];
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 : "");

View File

@ -7,11 +7,9 @@
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
return UIApplicationMain(argc, argv, nil, NSStringFromClass([RetroArch_iOS class]));
}
}

View File

@ -0,0 +1,13 @@
//
// module_list.h
// RetroArch
//
// Created by Jason Fetters on 2/8/13.
// Copyright (c) 2013 RetroArch. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface module_list : UIViewController<UITableViewDelegate, UITableViewDataSource>
@end

View File

@ -0,0 +1,90 @@
//
// module_list.m
// RetroArch
//
// Created by Jason Fetters on 2/8/13.
// Copyright (c) 2013 RetroArch. All rights reserved.
//
#import "module_list.h"
#import "dirlist.h"
@interface module_list ()
@end
@implementation module_list
{
UITableView* table;
NSString* module_dir;
NSMutableArray* modules;
};
- (void)viewDidLoad
{
[super viewDidLoad];
// Get the contents of the modules directory of the bundle.
module_dir = [NSString stringWithFormat:@"%@/%@",
[[NSBundle mainBundle] bundlePath],
@"modules"];
NSArray *module_list = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:module_dir error:nil];
if (module_list == nil || [module_list count] == 0)
{
// TODO: Handle error!
}
// Remove non .dylib files from the list
modules = [NSMutableArray arrayWithArray:module_list];
for (int i = 0; i < [modules count];)
{
if (![[modules objectAtIndex:i] hasSuffix:@".dylib"])
{
[modules removeObjectAtIndex:i];
}
else
{
i ++;
}
}
[self setTitle:@"Choose Emulator"];
table = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 640, 480) style:UITableViewStylePlain];
table.dataSource = self;
table.delegate = self;
self.view = table;
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc]
initWithTitle:@"Parent"
style:UIBarButtonItemStyleBordered
target:nil action:nil];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[RetroArch_iOS get].module_path = [NSString stringWithFormat:@"%@/%@", module_dir, [modules objectAtIndex:indexPath.row]];
[[RetroArch_iOS get].navigator pushViewController:[[[dirlist_view alloc] init] load_path:"/"] animated:YES];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return modules ? [modules count] : 0;
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell* cell = [table dequeueReusableCellWithIdentifier:@"module"];
cell = (cell != nil) ? cell : [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"module"];
if (modules)
{
cell.textLabel.text = [modules objectAtIndex:indexPath.row];
}
return cell;
}
@end