mirror of
https://github.com/libretro/RetroArch
synced 2025-03-01 07:13:35 +00:00
(iOS) Add an enumeration type setting and use it for selecting screen orientations and bluetooth mode
This commit is contained in:
parent
8882d07f3f
commit
96c9357273
@ -84,6 +84,14 @@
|
|||||||
/*********************************************/
|
/*********************************************/
|
||||||
@interface RAMenuItemPathSetting : RAMenuItemGeneralSetting<RAMenuItemBase> @end
|
@interface RAMenuItemPathSetting : RAMenuItemGeneralSetting<RAMenuItemBase> @end
|
||||||
|
|
||||||
|
/*********************************************/
|
||||||
|
/* RAMenuItemEnumSetting */
|
||||||
|
/* A menu item that displays and allows */
|
||||||
|
/* a setting to be set from a list of */
|
||||||
|
/* allowed choices. */
|
||||||
|
/*********************************************/
|
||||||
|
@interface RAMenuItemEnumSetting : RAMenuItemGeneralSetting<RAMenuItemBase> @end
|
||||||
|
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
/* RAMenuItemBindSetting */
|
/* RAMenuItemBindSetting */
|
||||||
/* A menu item that displays and allows */
|
/* A menu item that displays and allows */
|
||||||
|
@ -136,6 +136,9 @@
|
|||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (setting->type == ST_STRING && setting->values)
|
||||||
|
return [[RAMenuItemEnumSetting alloc] initWithSetting:setting];
|
||||||
|
|
||||||
RAMenuItemGeneralSetting* item = [[RAMenuItemGeneralSetting alloc] initWithSetting:setting];
|
RAMenuItemGeneralSetting* item = [[RAMenuItemGeneralSetting alloc] initWithSetting:setting];
|
||||||
|
|
||||||
if (item.setting->type == ST_INT || item.setting->type == ST_UINT || item.setting->type == ST_FLOAT)
|
if (item.setting->type == ST_INT || item.setting->type == ST_UINT || item.setting->type == ST_FLOAT)
|
||||||
@ -286,6 +289,51 @@
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
/*********************************************/
|
||||||
|
/* RAMenuItemEnumSetting */
|
||||||
|
/* A menu item that displays and allows */
|
||||||
|
/* a setting to be set from a list of */
|
||||||
|
/* allowed choices. */
|
||||||
|
/*********************************************/
|
||||||
|
@interface RAMenuItemEnumSetting() <UIActionSheetDelegate>
|
||||||
|
@property (nonatomic) UIActionSheet* actionSheet;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@implementation RAMenuItemEnumSetting
|
||||||
|
|
||||||
|
- (void)wasSelectedOnTableView:(UITableView*)tableView ofController:(UIViewController*)controller
|
||||||
|
{
|
||||||
|
struct string_list* options = string_split(self.setting->values, "|");
|
||||||
|
|
||||||
|
self.actionSheet = [UIActionSheet new];
|
||||||
|
self.actionSheet.title = @(self.setting->short_description);
|
||||||
|
self.actionSheet.delegate = self;
|
||||||
|
|
||||||
|
for (int i = 0; i < options->size; i ++)
|
||||||
|
{
|
||||||
|
[self.actionSheet addButtonWithTitle:@(options->elems[i].data)];
|
||||||
|
}
|
||||||
|
|
||||||
|
self.actionSheet.cancelButtonIndex = [self.actionSheet addButtonWithTitle:@"Cancel"];
|
||||||
|
[self.actionSheet showInView:self.parentTable];
|
||||||
|
|
||||||
|
string_list_free(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
|
||||||
|
{
|
||||||
|
if (buttonIndex != actionSheet.cancelButtonIndex)
|
||||||
|
{
|
||||||
|
setting_data_set_with_string_representation(self.setting, [actionSheet buttonTitleAtIndex:buttonIndex].UTF8String);
|
||||||
|
[self.parentTable reloadData];
|
||||||
|
}
|
||||||
|
|
||||||
|
self.actionSheet = nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
/* RAMenuItemBindSetting */
|
/* RAMenuItemBindSetting */
|
||||||
/* A menu item that displays and allows */
|
/* A menu item that displays and allows */
|
||||||
@ -604,6 +652,8 @@ static const void* const associated_core_key = &associated_core_key;
|
|||||||
|
|
||||||
if ((self = [super initWithGroup:frontend_setting_data]))
|
if ((self = [super initWithGroup:frontend_setting_data]))
|
||||||
{
|
{
|
||||||
|
[[RetroArch_iOS get] refreshSystemConfig];
|
||||||
|
|
||||||
RAFrontendSettingsMenu* __weak weakSelf = self;
|
RAFrontendSettingsMenu* __weak weakSelf = self;
|
||||||
|
|
||||||
self.title = @"Frontend Settings";
|
self.title = @"Frontend Settings";
|
||||||
|
@ -22,22 +22,18 @@
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
bool portrait;
|
char orientations[32];
|
||||||
bool portrait_upside_down;
|
bool logging_enabled;
|
||||||
bool landscape_left;
|
|
||||||
bool landscape_right;
|
|
||||||
|
|
||||||
bool logging_enabled;
|
char bluetooth_mode[64];
|
||||||
|
|
||||||
char bluetooth_mode[64];
|
struct
|
||||||
|
{
|
||||||
struct
|
int stdout;
|
||||||
{
|
int stderr;
|
||||||
int stdout;
|
|
||||||
int stderr;
|
|
||||||
|
|
||||||
FILE* file;
|
FILE* file;
|
||||||
} logging;
|
} logging;
|
||||||
} apple_frontend_settings_t;
|
} apple_frontend_settings_t;
|
||||||
extern apple_frontend_settings_t apple_frontend_settings;
|
extern apple_frontend_settings_t apple_frontend_settings;
|
||||||
|
|
||||||
|
@ -57,33 +57,24 @@ void ios_set_bluetooth_mode(NSString* mode)
|
|||||||
|
|
||||||
const void* apple_get_frontend_settings(void)
|
const void* apple_get_frontend_settings(void)
|
||||||
{
|
{
|
||||||
static rarch_setting_t settings[16];
|
static rarch_setting_t settings[8];
|
||||||
|
|
||||||
if (settings[0].type == ST_NONE)
|
if (settings[0].type == ST_NONE)
|
||||||
{
|
{
|
||||||
settings[0] = setting_data_group_setting(ST_GROUP, "Frontend Settings");
|
settings[0] = setting_data_group_setting(ST_GROUP, "Frontend Settings");
|
||||||
settings[1] = setting_data_group_setting(ST_SUB_GROUP, "Frontend");
|
settings[1] = setting_data_group_setting(ST_SUB_GROUP, "Frontend");
|
||||||
settings[2] = setting_data_bool_setting("ios_use_file_log", "Enable File Logging",
|
settings[2] = setting_data_bool_setting("ios_use_file_log", "Enable File Logging",
|
||||||
&apple_frontend_settings.logging_enabled, false);
|
&apple_frontend_settings.logging_enabled, false);
|
||||||
settings[3] = setting_data_bool_setting("ios_tv_mode", "TV Mode", &apple_use_tv_mode, false);
|
settings[3] = setting_data_bool_setting("ios_tv_mode", "TV Mode", &apple_use_tv_mode, false);
|
||||||
settings[4] = setting_data_group_setting(ST_END_SUB_GROUP, 0);
|
settings[4] = setting_data_string_setting(ST_STRING, "ios_btmode", "Bluetooth Input Type", apple_frontend_settings.bluetooth_mode,
|
||||||
|
|
||||||
settings[5] = setting_data_group_setting(ST_SUB_GROUP, "Bluetooth");
|
|
||||||
settings[6] = setting_data_string_setting(ST_STRING, "ios_btmode", "Mode", apple_frontend_settings.bluetooth_mode,
|
|
||||||
sizeof(apple_frontend_settings.bluetooth_mode), "keyboard");
|
sizeof(apple_frontend_settings.bluetooth_mode), "keyboard");
|
||||||
settings[7] = setting_data_group_setting(ST_END_SUB_GROUP, 0);
|
settings[4].values = "icade|keyboard|btstack";
|
||||||
|
settings[5] = setting_data_string_setting(ST_STRING, "ios_orientations", "Screen Orientations", apple_frontend_settings.orientations,
|
||||||
|
sizeof(apple_frontend_settings.orientations), "both");
|
||||||
|
settings[5].values = "both|landscape|portrait";
|
||||||
|
settings[6] = setting_data_group_setting(ST_END_SUB_GROUP, 0);
|
||||||
|
|
||||||
settings[8] = setting_data_group_setting(ST_SUB_GROUP, "Orientations");
|
settings[7] = setting_data_group_setting(ST_END_GROUP, 0);
|
||||||
settings[9] = setting_data_bool_setting("ios_allow_portrait", "Portrait",
|
|
||||||
&apple_frontend_settings.portrait, true);
|
|
||||||
settings[10] = setting_data_bool_setting("ios_allow_portrait_upside_down", "Portrait Upside Down",
|
|
||||||
&apple_frontend_settings.portrait_upside_down, true);
|
|
||||||
settings[11] = setting_data_bool_setting("ios_allow_landscape_left", "Landscape Left",
|
|
||||||
&apple_frontend_settings.landscape_left, true);
|
|
||||||
settings[12] = setting_data_bool_setting("ios_allow_landscape_right", "Landscape Right",
|
|
||||||
&apple_frontend_settings.landscape_right, true);
|
|
||||||
settings[13] = setting_data_group_setting(ST_END_SUB_GROUP, 0);
|
|
||||||
settings[14] = setting_data_group_setting(ST_END_GROUP, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return settings;
|
return settings;
|
||||||
@ -339,18 +330,12 @@ static void handle_touch_event(NSArray* touches)
|
|||||||
setting_data_load_config_path(frontend_settings, self.systemConfigPath.UTF8String);
|
setting_data_load_config_path(frontend_settings, self.systemConfigPath.UTF8String);
|
||||||
|
|
||||||
// Get enabled orientations
|
// Get enabled orientations
|
||||||
static const struct { const bool* value; uint32_t orientation; } orientationSettings[4] =
|
_enabledOrientations = UIInterfaceOrientationMaskAll;
|
||||||
{
|
|
||||||
{ &apple_frontend_settings.portrait, UIInterfaceOrientationMaskPortrait },
|
|
||||||
{ &apple_frontend_settings.portrait_upside_down, UIInterfaceOrientationMaskPortraitUpsideDown },
|
|
||||||
{ &apple_frontend_settings.landscape_left, UIInterfaceOrientationMaskLandscapeLeft },
|
|
||||||
{ &apple_frontend_settings.landscape_right, UIInterfaceOrientationMaskLandscapeRight }
|
|
||||||
};
|
|
||||||
|
|
||||||
_enabledOrientations = 0;
|
if (strcmp(apple_frontend_settings.orientations, "landscape") == 0)
|
||||||
|
_enabledOrientations = UIInterfaceOrientationMaskLandscape;
|
||||||
for (int i = 0; i < 4; i ++)
|
else if (strcmp(apple_frontend_settings.orientations, "portrait") == 0)
|
||||||
_enabledOrientations |= (*orientationSettings[i].value) ? orientationSettings[i].orientation : 0;
|
_enabledOrientations = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
|
||||||
|
|
||||||
// Set bluetooth mode
|
// Set bluetooth mode
|
||||||
ios_set_bluetooth_mode(@(apple_frontend_settings.bluetooth_mode));
|
ios_set_bluetooth_mode(@(apple_frontend_settings.bluetooth_mode));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user