(iOS) Some settings menu polish:

The bluetooth mode is updated immediately, previously you had to hit the back button on the frontend settings before it would be applied.
        The custom config state label in the frontend settings menu is updated properly.
This commit is contained in:
meancoot 2013-08-15 12:47:13 -04:00
parent 0d291e809a
commit 26df85f020
3 changed files with 54 additions and 13 deletions

View File

@ -39,4 +39,7 @@
@end
// modes are: keyboard, icade and btstack
void ios_set_bluetooth_mode(NSString* mode);
#endif

View File

@ -29,6 +29,11 @@
#include "file.h"
//#define HAVE_DEBUG_FILELOG
void ios_set_bluetooth_mode(NSString* mode)
{
apple_input_enable_icade([mode isEqualToString:@"icade"]);
btstack_set_poweron([mode isEqualToString:@"btstack"]);
}
// Input helpers: This is kept here because it needs objective-c
static void handle_touch_event(NSArray* touches)
@ -251,9 +256,7 @@ static void handle_touch_event(NSArray* touches)
}
// Setup bluetooth mode
NSString* btmode = objc_get_value_from_config(conf, @"ios_btmode", @"keyboard");
apple_input_enable_icade([btmode isEqualToString:@"icade"]);
btstack_set_poweron([btmode isEqualToString:@"btstack"]);
ios_set_bluetooth_mode(objc_get_value_from_config(conf, @"ios_btmode", @"keyboard"));
bool val;
apple_use_tv_mode = config_get_bool(conf, "ios_tv_mode", & val) && val;

View File

@ -48,8 +48,12 @@ enum SettingTypes
double rangeMin; // < The mininum value of a range setting
double rangeMax; // < The maximum value of a range setting
void (^reload)(RASettingData* action, id userdata);
void (*changed)(RASettingData* action);
void (*reload)(RASettingData* action, id userdata);
}
- (void)setValue:(NSString*)aValue;
@end
@implementation RASettingData
@ -61,6 +65,14 @@ enum SettingTypes
return self;
}
- (void)setValue:(NSString*)aValue;
{
value = aValue;
if (changed)
changed(self);
}
- (uint32_t)enumerationCount
{
return subValues.count / (haveDescriptions ? 2 : 1);
@ -189,7 +201,7 @@ static RASettingData* aspect_setting(config_file_t* config, NSString* label)
return result;
}
static RASettingData* custom_action(NSString* action, NSString* value, id data, void (^reload_func)(RASettingData* action, id userdata))
static RASettingData* custom_action(NSString* action, NSString* value, id data, void (*reload_func)(RASettingData* action, id userdata))
{
RASettingData* result = [[RASettingData alloc] initWithType:CustomAction label:action name:nil];
result->value = value;
@ -201,6 +213,14 @@ static RASettingData* custom_action(NSString* action, NSString* value, id data,
return result;
}
// This adds a change notify function to a setting and returns it; done this way so it can be used in NSArray
// init lists.
static RASettingData* change_notify(RASettingData* setting, void (*change_func)(RASettingData* setting))
{
setting->changed = change_func;
return setting;
}
static NSArray* build_input_port_group(config_file_t* config, uint32_t player)
{
// Only player 1 should have default key bindings
@ -367,6 +387,18 @@ static NSArray* build_input_port_group(config_file_t* config, uint32_t player)
@end
#pragma mark System Settings
static void reload_core_config_state(RASettingData* action, RAModuleInfo* userdata)
{
[action setValue:userdata.hasCustomConfig ? @"[Custom]" : @"[Global]"];
}
static void bluetooth_option_changed(RASettingData* setting)
{
ios_set_bluetooth_mode(setting->value);
}
@implementation RASystemSettingsList
- (id)init
{
@ -379,10 +411,7 @@ static NSArray* build_input_port_group(config_file_t* config, uint32_t player)
NSArray* moduleList = [RAModuleInfo getModules];
for (RAModuleInfo* i in moduleList)
{
[modules addObject:custom_action(i.description, nil, i, ^(RASettingData* action, RAModuleInfo* userdata)
{
action->value = userdata.hasCustomConfig ? @"[Custom]" : @"[Global]";
})];
[modules addObject:custom_action(i.description, nil, i, reload_core_config_state)];
}
@ -397,7 +426,7 @@ static NSArray* build_input_port_group(config_file_t* config, uint32_t player)
boolean_setting(config, @"ios_tv_mode", @"TV Mode", @"false"),
nil],
[NSArray arrayWithObjects:@"Bluetooth",
enumeration_setting(config, @"ios_btmode", @"Mode", @"keyboard", bluetoothOptions, true),
change_notify(enumeration_setting(config, @"ios_btmode", @"Mode", @"keyboard", bluetoothOptions, true), bluetooth_option_changed),
nil],
[NSArray arrayWithObjects:@"Orientations",
boolean_setting(config, @"ios_allow_portrait", @"Portrait", @"true"),
@ -416,6 +445,12 @@ static NSArray* build_input_port_group(config_file_t* config, uint32_t player)
return self;
}
- (void)viewDidAppear:(BOOL)animated
{
[self.tableView reloadData];
[super viewDidAppear:animated];
}
- (void)dealloc
{
config_file_t* config = config_file_new([[RetroArch_iOS get].systemConfigPath UTF8String]);
@ -590,7 +625,7 @@ static NSArray* build_input_port_group(config_file_t* config, uint32_t player)
- (void)handleBooleanSwitch:(UISwitch*)swt
{
RASettingData* setting = objc_getAssociatedObject(swt, "SETTING");
setting->value = (swt.on ? @"true" : @"false");
[setting setValue:swt.on ? @"true" : @"false"];
[self handleCustomAction:setting];
}
@ -598,7 +633,7 @@ static NSArray* build_input_port_group(config_file_t* config, uint32_t player)
- (void)handleSlider:(UISlider*)sld
{
RASettingData* setting = objc_getAssociatedObject(sld, "SETTING");
setting->value = [NSString stringWithFormat:@"%f", sld.value];
[setting setValue:[NSString stringWithFormat:@"%f", sld.value]];
[self handleCustomAction:setting];
}
@ -739,7 +774,7 @@ static NSArray* build_input_port_group(config_file_t* config, uint32_t player)
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
_value->value = (indexPath.section == _mainSection) ? [_value valueForEnumerationIndex:indexPath.row] : @"";
[_value setValue: (indexPath.section == _mainSection) ? [_value valueForEnumerationIndex:indexPath.row] : @""];
[_view reloadData];
[[RetroArch_iOS get] popViewControllerAnimated:YES];