ios: Add working setting items for key binding; split settings_list.m up.

This commit is contained in:
meancoot 2013-02-12 17:16:34 -05:00
parent e3447803a4
commit c46de51fc3
5 changed files with 227 additions and 100 deletions

View File

@ -15,7 +15,6 @@
96297A0F16C5AEA100E6DCE0 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 96297A0E16C5AEA100E6DCE0 /* main.m */; };
96297A1116C5AEDE00E6DCE0 /* game_view.m in Sources */ = {isa = PBXBuildFile; fileRef = 96297A1016C5AEDE00E6DCE0 /* game_view.m */; };
96297A1316C5AEFD00E6DCE0 /* directory_list.m in Sources */ = {isa = PBXBuildFile; fileRef = 96297A1216C5AEFD00E6DCE0 /* directory_list.m */; };
96297A1D16C6D20900E6DCE0 /* settings_list.m in Sources */ = {isa = PBXBuildFile; fileRef = 96297A1C16C6D20900E6DCE0 /* settings_list.m */; };
96297A2416C818FF00E6DCE0 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 96297A2216C818FF00E6DCE0 /* Icon-72.png */; };
96297A2516C818FF00E6DCE0 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 96297A2316C818FF00E6DCE0 /* Icon.png */; };
96297A2716C82FF100E6DCE0 /* overlays in Resources */ = {isa = PBXBuildFile; fileRef = 96297A2616C82FF100E6DCE0 /* overlays */; };
@ -24,6 +23,9 @@
96366C5316C9A7C100D64A22 /* coreaudio.c in Sources */ = {isa = PBXBuildFile; fileRef = 96AFAEE816C1DC73009DE44C /* coreaudio.c */; };
96366C5516C9AC3300D64A22 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96366C5416C9AC3300D64A22 /* CoreAudio.framework */; };
96366C5916C9ACF500D64A22 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 96366C5816C9ACF500D64A22 /* AudioToolbox.framework */; };
96366C7416CAF62200D64A22 /* button_getter.m in Sources */ = {isa = PBXBuildFile; fileRef = 96366C7016CAF62200D64A22 /* button_getter.m */; };
96366C7516CAF62200D64A22 /* enumeration_list.m in Sources */ = {isa = PBXBuildFile; fileRef = 96366C7116CAF62200D64A22 /* enumeration_list.m */; };
96366C7616CAF62200D64A22 /* settings_list.m in Sources */ = {isa = PBXBuildFile; fileRef = 96366C7316CAF62200D64A22 /* settings_list.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 */; };
@ -96,13 +98,16 @@
96297A0E16C5AEA100E6DCE0 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
96297A1016C5AEDE00E6DCE0 /* game_view.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = game_view.m; sourceTree = "<group>"; };
96297A1216C5AEFD00E6DCE0 /* directory_list.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = directory_list.m; sourceTree = "<group>"; };
96297A1C16C6D20900E6DCE0 /* settings_list.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = settings_list.m; sourceTree = "<group>"; };
96297A2216C818FF00E6DCE0 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-72.png"; path = "RetroArch/Icon-72.png"; sourceTree = "<group>"; };
96297A2316C818FF00E6DCE0 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon.png; path = RetroArch/Icon.png; sourceTree = "<group>"; };
96297A2616C82FF100E6DCE0 /* overlays */ = {isa = PBXFileReference; lastKnownFileType = folder; name = overlays; path = ../media/overlays; sourceTree = "<group>"; };
96366C4F16C9A4E100D64A22 /* resampler.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = resampler.c; sourceTree = "<group>"; };
96366C5416C9AC3300D64A22 /* CoreAudio.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreAudio.framework; path = System/Library/Frameworks/CoreAudio.framework; sourceTree = SDKROOT; };
96366C5816C9ACF500D64A22 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
96366C7016CAF62200D64A22 /* button_getter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = button_getter.m; sourceTree = "<group>"; };
96366C7116CAF62200D64A22 /* enumeration_list.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = enumeration_list.m; sourceTree = "<group>"; };
96366C7216CAF62200D64A22 /* settings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = settings.h; sourceTree = "<group>"; };
96366C7316CAF62200D64A22 /* settings_list.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = settings_list.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; };
@ -305,6 +310,17 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
96366C6F16CAF62200D64A22 /* settings */ = {
isa = PBXGroup;
children = (
96366C7016CAF62200D64A22 /* button_getter.m */,
96366C7116CAF62200D64A22 /* enumeration_list.m */,
96366C7216CAF62200D64A22 /* settings.h */,
96366C7316CAF62200D64A22 /* settings_list.m */,
);
path = settings;
sourceTree = "<group>";
};
96AFAE1A16C1D4EA009DE44C = {
isa = PBXGroup;
children = (
@ -346,6 +362,7 @@
96AFAE3316C1D4EA009DE44C /* RetroArch */ = {
isa = PBXGroup;
children = (
96366C6F16CAF62200D64A22 /* settings */,
96297A1216C5AEFD00E6DCE0 /* directory_list.m */,
96297A1016C5AEDE00E6DCE0 /* game_view.m */,
96297A0D16C5ADDA00E6DCE0 /* views.h */,
@ -356,7 +373,6 @@
96AFAE3416C1D4EA009DE44C /* Supporting Files */,
96CF015B16C2F72900ABF9C9 /* ios_input.c */,
96297A0816C59EC000E6DCE0 /* module_list.m */,
96297A1C16C6D20900E6DCE0 /* settings_list.m */,
);
path = RetroArch;
sourceTree = "<group>";
@ -807,10 +823,12 @@
96297A0F16C5AEA100E6DCE0 /* main.m in Sources */,
96297A1116C5AEDE00E6DCE0 /* game_view.m in Sources */,
96297A1316C5AEFD00E6DCE0 /* directory_list.m in Sources */,
96297A1D16C6D20900E6DCE0 /* settings_list.m in Sources */,
96366C5016C9A4E100D64A22 /* resampler.c in Sources */,
96366C5216C9A4E600D64A22 /* hermite.c in Sources */,
96366C5316C9A7C100D64A22 /* coreaudio.c in Sources */,
96366C7416CAF62200D64A22 /* button_getter.m in Sources */,
96366C7516CAF62200D64A22 /* enumeration_list.m in Sources */,
96366C7616CAF62200D64A22 /* settings_list.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

View File

@ -0,0 +1,126 @@
//
// settings_list.m
// RetroArch
//
// Created by Jason Fetters on 2/8/13.
// Copyright (c) 2013 RetroArch. All rights reserved.
//
#import "settings.h"
static const struct
{
const char* const keyname;
const uint32_t hid_id;
} ios_key_name_map[] = {
{ "left", 0x50 }, { "right", 0x4F },
{ "up", 0x52 }, { "down", 0x51 },
{ "enter", 0x28 }, { "kp_enter", 0x58 },
{ "tab", 0x2B }, { "insert", 0x49 },
{ "del", 0x4C }, { "end", 0x4D },
{ "home", 0x4A }, { "rshift", 0xE5 },
{ "shift", 0xE1 }, { "ctrl", 0xE0 },
{ "alt", 0xE2 }, { "space", 0x2C },
{ "escape", 0x29 }, { "backspace", 0x2A },
{ "backquote", 0x35 }, { "pause", 0x48 },
{ "add", 0x57 }, { "subtract", 0x56 }, /*kp_minus?*/
{ "multiply", 0x55 }, { "divide", 0x54 },
{ "kp_plus", 0x57 }, { "kp_minus", 0x56 },
{ "f1", 0x3A }, { "f2", 0x3B },
{ "f3", 0x3C }, { "f4", 0x3D },
{ "f5", 0x3E }, { "f6", 0x3F },
{ "f7", 0x40 }, { "f8", 0x41 },
{ "f9", 0x42 }, { "f10", 0x43 },
{ "f11", 0x44 }, { "f12", 0x45 },
{ "num0", 0x27 }, { "num1", 0x1E },
{ "num2", 0x1F }, { "num3", 0x20 },
{ "num4", 0x21 }, { "num5", 0x22 },
{ "num6", 0x23 }, { "num7", 0x24 },
{ "num8", 0x25 }, { "num9", 0x26 },
{ "pageup", 0x48 }, { "pagedown", 0x4E },
{ "keypad0", 0x62 }, { "keypad1", 0x59 },
{ "keypad2", 0x5A }, { "keypad3", 0x5B },
{ "keypad4", 0x5C }, { "keypad5", 0x5D },
{ "keypad6", 0x5E }, { "keypad7", 0x5F },
{ "keypad8", 0x60 }, { "keypad9", 0x61 },
/*{ "period", RETROK_PERIOD },
{ "capslock", RETROK_CAPSLOCK }, { "numlock", RETROK_NUMLOCK },
{ "print_screen", RETROK_PRINT },
{ "scroll_lock", RETROK_SCROLLOCK },*/
{ "a", 0x04 }, { "b", 0x05 }, { "c", 0x06 }, { "d", 0x07 },
{ "e", 0x08 }, { "f", 0x09 }, { "g", 0x0A }, { "h", 0x0B },
{ "i", 0x0C }, { "j", 0x0D }, { "k", 0x0E }, { "l", 0x0F },
{ "m", 0x10 }, { "n", 0x11 }, { "o", 0x12 }, { "p", 0x13 },
{ "q", 0x14 }, { "r", 0x15 }, { "s", 0x16 }, { "t", 0x17 },
{ "u", 0x18 }, { "v", 0x19 }, { "w", 0x1A }, { "x", 0x1B },
{ "y", 0x1C }, { "z", 0x1D },
{ "nul", 0x00},
};
static const NSString* get_key_config_name(uint32_t hid_id)
{
for (int i = 0; ios_key_name_map[i].hid_id; i ++)
{
if (hid_id == ios_key_name_map[i].hid_id)
{
return [NSString stringWithUTF8String:ios_key_name_map[i].keyname];
}
}
return @"nul";
}
@implementation button_getter
{
button_getter* me;
NSMutableDictionary* value;
UIAlertView* alert;
UITableView* view;
}
- (id)initWithSetting:(NSMutableDictionary*)setting fromTable:(UITableView*)table
{
self = [super init];
value = setting;
view = table;
me = self;
alert = [[UIAlertView alloc] initWithTitle:@"RetroArch"
message:[value objectForKey:@"LABEL"]
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:nil];
[alert show];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(keyReleased:) name: GSEventKeyUpNotification object: nil];
return self;
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
me = nil;
}
- (void)keyReleased:(NSNotification*) notification
{
int keycode = [[notification.userInfo objectForKey:@"keycode"] intValue];
[value setObject:get_key_config_name(keycode) forKey:@"VALUE"];
[alert dismissWithClickedButtonIndex:0 animated:YES];
[view reloadData];
}
@end

View File

@ -0,0 +1,62 @@
//
// settings_list.m
// RetroArch
//
// Created by Jason Fetters on 2/8/13.
// Copyright (c) 2013 RetroArch. All rights reserved.
//
#import "settings.h"
@implementation enumeration_list
{
NSMutableDictionary* value;
UITableView* view;
};
- (id)initWithSetting:(NSMutableDictionary*)setting fromTable:(UITableView*)table
{
self = [super initWithStyle:UITableViewStyleGrouped];
value = setting;
view = table;
[self setTitle: [value objectForKey:@"LABEL"]];
return self;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return (section == 1) ? [[value objectForKey:@"VALUES"] count] : 1;
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell* cell = [self.tableView dequeueReusableCellWithIdentifier:@"option"];
cell = cell ? cell : [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"option"];
if (indexPath.section == 1)
cell.textLabel.text = [[value objectForKey:@"VALUES"] objectAtIndex:indexPath.row];
else
cell.textLabel.text = @"None";
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 1)
[value setObject:[[value objectForKey:@"VALUES"] objectAtIndex:indexPath.row] forKey:@"VALUE"];
else
[value setObject:@"" forKey:@"VALUE"];
[view reloadData];
[[RetroArch_iOS get].navigator popViewControllerAnimated:YES];
}
@end

View File

@ -0,0 +1,15 @@
//
// settings_list.m
// RetroArch
//
// Created by Jason Fetters on 2/8/13.
// Copyright (c) 2013 RetroArch. All rights reserved.
//
@interface button_getter : NSObject<UIAlertViewDelegate>
- (id)initWithSetting:(NSMutableDictionary*)setting fromTable:(UITableView*)table;
@end
@interface enumeration_list : UITableViewController
- (id)initWithSetting:(NSMutableDictionary*)setting fromTable:(UITableView*)table;
@end

View File

@ -7,6 +7,7 @@
//
#import <objc/runtime.h>
#import "settings.h"
#include "config_file.h"
static const char* const SETTINGID = "SETTING";
@ -84,101 +85,6 @@ static NSMutableDictionary* subpath_setting(config_file_t* config, NSString* nam
nil];
}
@interface button_getter : NSObject<UIAlertViewDelegate>
@end
@implementation button_getter
{
button_getter* me;
NSMutableDictionary* value;
UIAlertView* alert;
}
- (id)initWithSetting:(NSMutableDictionary*)setting
{
value = setting;
alert = [[UIAlertView alloc] initWithTitle:@"RetroArch"
message:[value objectForKey:@"LABEL"]
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:nil];
[alert show];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(keyReleased:) name: GSEventKeyUpNotification object: nil];
me = self;
return self;
}
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
me = nil;
}
- (void)keyReleased:(NSNotification*) notification
{
[alert dismissWithClickedButtonIndex:0 animated:YES];
}
@end
@interface enumeration_list : UITableViewController
@end
@implementation enumeration_list
{
NSMutableDictionary* value;
UITableView* view;
};
- (id)initWithSetting:(NSMutableDictionary*)setting fromTable:(UITableView*)table
{
self = [super initWithStyle:UITableViewStyleGrouped];
value = setting;
view = table;
[self setTitle: [value objectForKey:@"LABEL"]];
return self;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return (section == 1) ? [[value objectForKey:@"VALUES"] count] : 1;
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell* cell = [self.tableView dequeueReusableCellWithIdentifier:@"option"];
cell = cell ? cell : [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"option"];
if (indexPath.section == 1)
cell.textLabel.text = [[value objectForKey:@"VALUES"] objectAtIndex:indexPath.row];
else
cell.textLabel.text = @"None";
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 1)
[value setObject:[[value objectForKey:@"VALUES"] objectAtIndex:indexPath.row] forKey:@"VALUE"];
else
[value setObject:@"" forKey:@"VALUE"];
[view reloadData];
[[RetroArch_iOS get].navigator popViewControllerAnimated:YES];
}
@end
@implementation settings_list
{
@ -289,7 +195,7 @@ static NSMutableDictionary* subpath_setting(config_file_t* config, NSString* nam
}
else if([type isEqualToString:@"C"])
{
[[button_getter alloc] initWithSetting:setting];
(void)[[button_getter alloc] initWithSetting:setting fromTable:(UITableView*)self.view];
}
}