(iOS) Move iOS settings code into iOS specific file and fix the issue where every compile unit would get its own copy of apple_frontend_settings

This commit is contained in:
meancoot 2013-12-03 19:24:01 -05:00
parent 1e0b0970e8
commit 8882d07f3f
5 changed files with 84 additions and 108 deletions

View File

@ -600,7 +600,6 @@ static const void* const associated_core_key = &associated_core_key;
- (id)init
{
const rarch_setting_t* apple_get_frontend_settings();
const rarch_setting_t* frontend_setting_data = apple_get_frontend_settings();
if ((self = [super initWithGroup:frontend_setting_data]))
@ -633,7 +632,6 @@ static const void* const associated_core_key = &associated_core_key;
- (void)dealloc
{
const rarch_setting_t* apple_get_frontend_settings();
setting_data_save_config_path(apple_get_frontend_settings(), [RetroArch_iOS get].systemConfigPath.UTF8String);
[[RetroArch_iOS get] refreshSystemConfig];
}

View File

@ -20,6 +20,30 @@
#import <AVFoundation/AVCaptureOutput.h>
#include "views.h"
typedef struct
{
bool portrait;
bool portrait_upside_down;
bool landscape_left;
bool landscape_right;
bool logging_enabled;
char bluetooth_mode[64];
struct
{
int stdout;
int stderr;
FILE* file;
} logging;
} apple_frontend_settings_t;
extern apple_frontend_settings_t apple_frontend_settings;
const void* apple_get_frontend_settings(void);
@interface RAGameView : UIViewController<AVCaptureAudioDataOutputSampleBufferDelegate>
+ (RAGameView*)get;
- (void)iOS7SetiCadeMode:(bool)on;

View File

@ -16,7 +16,6 @@
#include <pthread.h>
#include <string.h>
#include "../../frontend/platform/platform_ios.h"
#import "RetroArch_Apple.h"
#include "rarch_wrapper.h"
@ -31,6 +30,8 @@
#include "file.h"
apple_frontend_settings_t apple_frontend_settings;
//#define HAVE_DEBUG_FILELOG
bool is_ios_7()
{
@ -54,6 +55,64 @@ void ios_set_bluetooth_mode(NSString* mode)
#endif
}
const void* apple_get_frontend_settings(void)
{
static rarch_setting_t settings[16];
if (settings[0].type == ST_NONE)
{
settings[0] = setting_data_group_setting(ST_GROUP, "Frontend Settings");
settings[1] = setting_data_group_setting(ST_SUB_GROUP, "Frontend");
settings[2] = setting_data_bool_setting("ios_use_file_log", "Enable File Logging",
&apple_frontend_settings.logging_enabled, 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[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");
settings[7] = setting_data_group_setting(ST_END_SUB_GROUP, 0);
settings[8] = setting_data_group_setting(ST_SUB_GROUP, "Orientations");
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;
}
void ios_set_logging_state(const char *log_path, bool on)
{
fflush(stdout);
fflush(stderr);
if (on && !apple_frontend_settings.logging.file)
{
apple_frontend_settings.logging.file = fopen(log_path, "a");
apple_frontend_settings.logging.stdout = dup(1);
apple_frontend_settings.logging.stderr = dup(2);
dup2(fileno(apple_frontend_settings.logging.file), 1);
dup2(fileno(apple_frontend_settings.logging.file), 2);
}
else if (!on && apple_frontend_settings.logging.file)
{
dup2(apple_frontend_settings.logging.stdout, 1);
dup2(apple_frontend_settings.logging.stderr, 2);
fclose(apple_frontend_settings.logging.file);
apple_frontend_settings.logging.file = 0;
}
}
// Input helpers: This is kept here because it needs objective-c
static void handle_touch_event(NSArray* touches)
{

View File

@ -21,7 +21,6 @@
#include "../../apple/common/setting_data.h"
#include "../frontend_context.h"
#include "platform_ios.h"
#include <stdint.h>
#include "../../boolean.h"
@ -180,62 +179,6 @@ void *rarch_main_spring(void* args)
return 0;
}
#ifdef IOS
const void* apple_get_frontend_settings(void)
{
static rarch_setting_t settings[16];
settings[0] = setting_data_group_setting(ST_GROUP, "Frontend Settings");
settings[1] = setting_data_group_setting(ST_SUB_GROUP, "Frontend");
settings[2] = setting_data_bool_setting("ios_use_file_log", "Enable File Logging",
&apple_frontend_settings.logging_enabled, 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[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");
settings[7] = setting_data_group_setting(ST_END_SUB_GROUP, 0);
settings[8] = setting_data_group_setting(ST_SUB_GROUP, "Orientations");
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;
}
void ios_set_logging_state(const char *log_path, bool on)
{
fflush(stdout);
fflush(stderr);
if (on && !apple_frontend_settings.logging.file)
{
apple_frontend_settings.logging.file = fopen(log_path, "a");
apple_frontend_settings.logging.stdout = dup(1);
apple_frontend_settings.logging.stderr = dup(2);
dup2(fileno(apple_frontend_settings.logging.file), 1);
dup2(fileno(apple_frontend_settings.logging.file), 2);
}
else if (!on && apple_frontend_settings.logging.file)
{
dup2(apple_frontend_settings.logging.stdout, 1);
dup2(apple_frontend_settings.logging.stderr, 2);
fclose(apple_frontend_settings.logging.file);
apple_frontend_settings.logging.file = 0;
}
}
#endif
const frontend_ctx_driver_t frontend_ctx_apple = {
NULL, /* environment_get */
NULL, /* init */

View File

@ -1,48 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2013 - Jason Fetters
* Copyright (C) 2011-2013 - Daniel De Matteis
*
* 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 _RARCH_PLATFORM_IOS_H
#define _RARCH_PLATFORM_IOS_H
#include <stdbool.h>
#include <file.h>
static struct
{
bool portrait;
bool portrait_upside_down;
bool landscape_left;
bool landscape_right;
bool logging_enabled;
char bluetooth_mode[64];
struct
{
int stdout;
int stderr;
FILE* file;
} logging;
} apple_frontend_settings;
const void* apple_get_frontend_settings(void);
void ios_set_logging_state(const char *log_path, bool on);
extern bool apple_use_tv_mode;
#endif