(RARCH_CONSOLE) Console ports now use config_load for loading

config file stuff and config_set_default as only place to load
defaults from. Slightly messy defaults will be cleaned up later.
This commit is contained in:
twinaphex 2013-01-10 06:38:19 +01:00
parent d16d58b095
commit cc71a83fa8
13 changed files with 131 additions and 237 deletions

View File

@ -45,8 +45,6 @@ CONSOLE EXTENSIONS
#include "../rarch_console_rsound.c"
#endif
#include "../rarch_console_config.c"
#ifdef HAVE_DEFAULT_RETROPAD_INPUT
#include "../rarch_console_input.c"
#endif

View File

@ -1,102 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
* 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/>.
*/
#include <stdio.h>
#include "../conf/config_file.h"
#include "../conf/config_file_macros.h"
#include "rarch_console_config.h"
void rarch_config_load (void)
{
config_file_t *conf = NULL;
if (*g_extern.config_path)
conf = config_file_new(g_extern.config_path);
else
conf = config_file_new(NULL);
if (!conf)
{
RARCH_ERR("Couldn't find config at path: \"%s\"\n", g_extern.config_path);
rarch_fail(1, "rarch_config_load()");
}
// g_settings
CONFIG_GET_STRING(libretro, "libretro_path");
CONFIG_GET_STRING(system_directory, "system_directory");
#ifdef HAVE_XML
CONFIG_GET_STRING(cheat_database, "cheat_database");
#endif
CONFIG_GET_BOOL(rewind_enable, "rewind_enable");
CONFIG_GET_STRING(video.cg_shader_path, "video_cg_shader");
#ifdef HAVE_FBO
CONFIG_GET_STRING(video.second_pass_shader, "video_second_pass_shader");
CONFIG_GET_FLOAT(video.fbo.scale_x, "video_fbo_scale_x");
CONFIG_GET_FLOAT(video.fbo.scale_y, "video_fbo_scale_y");
CONFIG_GET_BOOL(video.render_to_texture, "video_render_to_texture");
CONFIG_GET_BOOL(video.second_pass_smooth, "video_second_pass_smooth");
#endif
CONFIG_GET_BOOL(video.smooth, "video_smooth");
CONFIG_GET_BOOL(video.vsync, "video_vsync");
CONFIG_GET_INT(video.aspect_ratio_idx, "aspect_ratio_index");
CONFIG_GET_FLOAT(video.aspect_ratio, "video_aspect_ratio");
CONFIG_GET_STRING(audio.device, "audio_device");
CONFIG_GET_BOOL(audio.rate_control, "audio_rate_control");
CONFIG_GET_FLOAT(audio.rate_control_delta, "audio_rate_control_delta");
for (unsigned i = 0; i < 8; i++)
{
char cfg[64];
snprintf(cfg, sizeof(cfg), "input_dpad_emulation_p%u", i + 1);
CONFIG_GET_INT(input.dpad_emulation[i], cfg);
snprintf(cfg, sizeof(cfg), "input_device_p%u", i + 1);
CONFIG_GET_INT(input.device[i], cfg);
}
// g_extern
CONFIG_GET_STRING_EXTERN(console.main_wrap.paths.default_rom_startup_dir, "default_rom_startup_dir");
CONFIG_GET_BOOL_EXTERN(console.screen.gamma_correction, "gamma_correction");
CONFIG_GET_BOOL_EXTERN(console.rmenu.state.msg_info.enable, "info_msg_enable");
CONFIG_GET_BOOL_EXTERN(console.screen.state.screenshots.enable, "screenshots_enable");
CONFIG_GET_BOOL_EXTERN(console.screen.state.throttle.enable, "throttle_enable");
CONFIG_GET_BOOL_EXTERN(console.screen.state.triple_buffering.enable, "triple_buffering_enable");
CONFIG_GET_BOOL_EXTERN(console.screen.state.overscan.enable, "overscan_enable");
CONFIG_GET_BOOL_EXTERN(console.sound.custom_bgm.enable, "custom_bgm_enable");
CONFIG_GET_BOOL_EXTERN(console.main_wrap.state.default_sram_dir.enable, "sram_dir_enable");
CONFIG_GET_BOOL_EXTERN(console.main_wrap.state.default_savestate_dir.enable, "savestate_dir_enable");
CONFIG_GET_FLOAT_EXTERN(console.screen.overscan_amount, "overscan_amount");
#ifdef _XBOX1
CONFIG_GET_INT_EXTERN(console.screen.state.flicker_filter.enable, "flicker_filter");
CONFIG_GET_INT_EXTERN(console.sound.volume_level, "sound_volume_level");
#endif
#ifdef HAVE_ZLIB
CONFIG_GET_INT_EXTERN(file_state.zip_extract_mode, "zip_extract_mode");
#endif
CONFIG_GET_INT_EXTERN(console.screen.resolutions.current.id, "current_resolution_id");
CONFIG_GET_INT_EXTERN(state_slot, "state_slot");
CONFIG_GET_INT_EXTERN(audio_data.mute, "audio_mute");
CONFIG_GET_BOOL_EXTERN(console.screen.state.soft_filter.enable, "soft_display_filter_enable");
CONFIG_GET_INT_EXTERN(console.screen.orientation, "screen_orientation");
CONFIG_GET_INT_EXTERN(console.sound.mode, "sound_mode");
CONFIG_GET_INT_EXTERN(console.screen.viewports.custom_vp.x, "custom_viewport_x");
CONFIG_GET_INT_EXTERN(console.screen.viewports.custom_vp.y, "custom_viewport_y");
CONFIG_GET_INT_EXTERN(console.screen.viewports.custom_vp.width, "custom_viewport_width");
CONFIG_GET_INT_EXTERN(console.screen.viewports.custom_vp.height, "custom_viewport_height");
CONFIG_GET_FLOAT_EXTERN(console.rmenu.font_size, "menu_font_size");
}

View File

@ -1,29 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2013 - Hans-Kristian Arntzen
* 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_CONSOLE_CONFIG_H
#define _RARCH_CONSOLE_CONFIG_H
enum
{
CONFIG_FILE,
SHADER_PRESET_FILE,
INPUT_PRESET_FILE
};
void rarch_config_load(void);
#endif

View File

@ -327,89 +327,3 @@ void rarch_settings_create_menu_item_label(char * str, unsigned setting, size_t
#else
#define DEFAULT_GAMMA 0
#endif
void rarch_settings_set_default(void)
{
// g_settings
g_settings.rewind_enable = false;
#ifdef HAVE_XML
strlcpy(g_settings.cheat_database, default_paths.port_dir, sizeof(g_settings.cheat_database));
#endif
#if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL)
strlcpy(g_settings.video.cg_shader_path, default_paths.shader_file, sizeof(g_settings.video.cg_shader_path));
strlcpy(g_settings.video.second_pass_shader, default_paths.shader_file, sizeof(g_settings.video.second_pass_shader));
g_settings.video.second_pass_smooth = true;
#endif
#if defined(_XBOX360)
g_settings.video.shader_type = RARCH_SHADER_HLSL;
#elif defined(__PSL1GHT__)
g_settings.video.shader_type = RARCH_SHADER_GLSL;
#elif defined(__CELLOS_LV2__)
g_settings.video.shader_type = RARCH_SHADER_CG;
#elif defined(HAVE_GLSL)
g_settings.video.shader_type = RARCH_SHADER_GLSL;
#else
g_settings.video.shader_type = RARCH_SHADER_NONE;
#endif
#ifdef HAVE_FBO
g_settings.video.fbo.scale_x = 2.0f;
g_settings.video.fbo.scale_y = 2.0f;
#endif
#ifdef GEKKO
g_settings.audio.rate_control_delta = 0.006;
g_settings.audio.rate_control = true;
#endif
g_settings.video.render_to_texture = true;
g_settings.video.smooth = true;
g_settings.video.vsync = true;
g_settings.video.refresh_rate = 59.92;
strlcpy(g_settings.system_directory, default_paths.system_dir, sizeof(g_settings.system_directory));
g_settings.video.msg_pos_x = 0.05f;
g_settings.video.msg_pos_y = 0.90f;
g_settings.video.aspect_ratio = -1.0f;
// g_extern
strlcpy(g_extern.console.main_wrap.paths.default_sram_dir, default_paths.sram_dir, sizeof(g_extern.console.main_wrap.paths.default_sram_dir));
g_extern.console.screen.state.overscan.enable = false;
g_extern.console.screen.overscan_amount = 0.0f;
g_extern.console.sound.custom_bgm.enable = true;
g_extern.console.screen.gamma_correction = DEFAULT_GAMMA;
g_extern.console.screen.state.screenshots.enable = true;
g_extern.console.screen.state.throttle.enable = true;
g_extern.console.rmenu.state.msg_info.enable = true;
g_extern.console.screen.state.triple_buffering.enable = true;
g_extern.console.main_wrap.state.default_savestate_dir.enable = false;
g_extern.console.main_wrap.state.default_sram_dir.enable = false;
g_extern.console.screen.orientation = ORIENTATION_NORMAL;
g_extern.console.screen.resolutions.current.id = 0;
strlcpy(g_extern.console.main_wrap.paths.default_rom_startup_dir, default_paths.filebrowser_startup_dir, sizeof(g_extern.console.main_wrap.paths.default_rom_startup_dir));
strlcpy(g_extern.console.main_wrap.paths.default_savestate_dir, default_paths.savestate_dir, sizeof(g_extern.console.main_wrap.paths.default_savestate_dir));
g_settings.video.aspect_ratio_idx = 0;
g_extern.console.block_config_read = true;
g_extern.state_slot = 0;
g_extern.audio_data.mute = 0;
g_extern.verbose = true;
g_extern.console.rmenu.mode = MODE_MENU;
g_extern.console.rmenu.font_size = 1.0f;
g_extern.console.sound.mode = SOUND_MODE_NORMAL;
g_extern.console.screen.viewports.custom_vp.width = 0;
g_extern.console.screen.viewports.custom_vp.height = 0;
g_extern.console.screen.viewports.custom_vp.x = 0;
g_extern.console.screen.viewports.custom_vp.y = 0;
#ifdef _XBOX1
g_extern.console.screen.state.flicker_filter.enable = 1;
g_extern.console.sound.volume_level = 0;
#endif
g_extern.console.screen.state.soft_filter.enable = true;
#ifdef HAVE_ZLIB
g_extern.file_state.zip_extract_mode = 0;
#endif
}

View File

@ -107,7 +107,6 @@ enum
void rarch_settings_change(unsigned setting);
void rarch_settings_default(unsigned setting);
void rarch_settings_msg(unsigned setting, unsigned delay);
void rarch_settings_set_default(void);
void rarch_settings_create_menu_item_label(char * str, unsigned setting, size_t size);
void rarch_settings_create_menu_item_label_w(wchar_t *strwbuf, unsigned setting, size_t size);

View File

@ -226,11 +226,8 @@ int main(int argc, char *argv[])
verbose_log_init();
get_environment_settings(argc, argv);
config_set_defaults();
rarch_settings_set_default();
rarch_config_load();
config_load();
init_libretro_sym();
rarch_init_system_info();

View File

@ -30,7 +30,6 @@
#include "../../console/rarch_console.h"
#include "../../console/rarch_console_rom_ext.h"
#include "../../console/rarch_console_input.h"
#include "../../console/rarch_console_config.h"
#include "../../console/rarch_console_settings.h"
#include "../../gfx/image.h"

View File

@ -62,6 +62,13 @@ enum
CATEGORY_INGAME_MENU
};
enum
{
CONFIG_FILE,
SHADER_PRESET_FILE,
INPUT_PRESET_FILE
};
enum
{
FILE_BROWSER_MENU,

View File

@ -22,8 +22,6 @@
#include "../../ps3/ps3_input.h"
#include "../../console/rarch_console.h"
#include "../../console/rarch_console_config.h"
#include "../../console/rarch_console_settings.h"
#include "../../conf/config_file.h"
#include "../../general.h"

View File

@ -37,7 +37,6 @@
#endif
#include "../../console/rarch_console.h"
#include "../../console/rarch_console_config.h"
#include "../../conf/config_file.h"
#include "../../conf/config_file_macros.h"
#include "../../file.h"

View File

@ -472,8 +472,6 @@ struct global
// Settings and/or global state that is specific to a console-style implementation.
struct
{
bool block_config_read;
struct
{
unsigned mode;

View File

@ -2672,7 +2672,10 @@ int rarch_main_init(int argc, char *argv[])
}
validate_cpu_features();
#ifndef RARCH_CONSOLE
/* we already do this at startup */
config_load();
#endif
init_libretro_sym();
rarch_init_system_info();

View File

@ -239,6 +239,78 @@ void config_set_defaults(void)
for (int i = 0; i < MAX_PLAYERS; i++)
g_settings.input.joypad_map[i] = i;
#ifdef RARCH_CONSOLE
/* TODO - will be refactored - I'm aware this is messy right now */
#if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL)
strlcpy(g_settings.video.cg_shader_path, default_paths.shader_file, sizeof(g_settings.video.cg_shader_path));
strlcpy(g_settings.video.second_pass_shader, default_paths.shader_file, sizeof(g_settings.video.second_pass_shader));
g_settings.video.second_pass_smooth = true;
#endif
#if defined(_XBOX360)
g_settings.video.shader_type = RARCH_SHADER_HLSL;
#elif defined(__PSL1GHT__)
g_settings.video.shader_type = RARCH_SHADER_GLSL;
#elif defined(__CELLOS_LV2__)
g_settings.video.shader_type = RARCH_SHADER_CG;
#elif defined(HAVE_GLSL)
g_settings.video.shader_type = RARCH_SHADER_GLSL;
#else
g_settings.video.shader_type = RARCH_SHADER_NONE;
#endif
#ifdef GEKKO
g_settings.audio.rate_control_delta = 0.006;
g_settings.audio.rate_control = true;
#endif
g_settings.video.render_to_texture = true;
g_settings.video.refresh_rate = 59.92;
strlcpy(g_settings.system_directory, default_paths.system_dir, sizeof(g_settings.system_directory));
g_settings.video.msg_pos_x = 0.05f;
g_settings.video.msg_pos_y = 0.90f;
g_settings.video.aspect_ratio = -1.0f;
// g_extern
strlcpy(g_extern.console.main_wrap.paths.default_sram_dir, default_paths.sram_dir, sizeof(g_extern.console.main_wrap.paths.default_sram_dir));
g_extern.console.screen.state.overscan.enable = false;
g_extern.console.screen.overscan_amount = 0.0f;
g_extern.console.sound.custom_bgm.enable = true;
g_extern.console.screen.gamma_correction = DEFAULT_GAMMA;
g_extern.console.screen.state.screenshots.enable = true;
g_extern.console.screen.state.throttle.enable = true;
g_extern.console.rmenu.state.msg_info.enable = true;
g_extern.console.screen.state.triple_buffering.enable = true;
g_extern.console.main_wrap.state.default_savestate_dir.enable = false;
g_extern.console.main_wrap.state.default_sram_dir.enable = false;
g_extern.console.screen.orientation = ORIENTATION_NORMAL;
g_extern.console.screen.resolutions.current.id = 0;
strlcpy(g_extern.console.main_wrap.paths.default_rom_startup_dir, default_paths.filebrowser_startup_dir, sizeof(g_extern.console.main_wrap.paths.default_rom_startup_dir));
strlcpy(g_extern.console.main_wrap.paths.default_savestate_dir, default_paths.savestate_dir, sizeof(g_extern.console.main_wrap.paths.default_savestate_dir));
g_settings.video.aspect_ratio_idx = 0;
g_extern.state_slot = 0;
g_extern.audio_data.mute = 0;
g_extern.verbose = true;
g_extern.console.rmenu.mode = MODE_MENU;
g_extern.console.rmenu.font_size = 1.0f;
g_extern.console.sound.mode = SOUND_MODE_NORMAL;
g_extern.console.screen.viewports.custom_vp.width = 0;
g_extern.console.screen.viewports.custom_vp.height = 0;
g_extern.console.screen.viewports.custom_vp.x = 0;
g_extern.console.screen.viewports.custom_vp.y = 0;
#ifdef _XBOX1
g_extern.console.screen.state.flicker_filter.enable = 1;
g_extern.console.sound.volume_level = 0;
#endif
g_extern.console.screen.state.soft_filter.enable = true;
#ifdef HAVE_ZLIB
g_extern.file_state.zip_extract_mode = 0;
#endif
#endif
rarch_init_msg_queue();
}
@ -246,13 +318,8 @@ static void parse_config_file(void);
void config_load(void)
{
#ifdef RARCH_CONSOLE
if (!g_extern.console.block_config_read)
#endif
{
config_set_defaults();
parse_config_file();
}
config_set_defaults();
parse_config_file();
}
static config_file_t *open_default_config_file(void)
@ -403,6 +470,52 @@ bool config_load_file(const char *path)
CONFIG_GET_FLOAT(video.msg_pos_x, "video_message_pos_x");
CONFIG_GET_FLOAT(video.msg_pos_y, "video_message_pos_y");
#ifdef RARCH_CONSOLE
/* TODO - will be refactored later to make it more clean - it's more
* important that it works for consoles right now */
CONFIG_GET_INT(video.aspect_ratio_idx, "aspect_ratio_index");
CONFIG_GET_FLOAT(video.aspect_ratio, "video_aspect_ratio");
for (unsigned i = 0; i < 8; i++)
{
char cfg[64];
snprintf(cfg, sizeof(cfg), "input_dpad_emulation_p%u", i + 1);
CONFIG_GET_INT(input.dpad_emulation[i], cfg);
snprintf(cfg, sizeof(cfg), "input_device_p%u", i + 1);
CONFIG_GET_INT(input.device[i], cfg);
}
CONFIG_GET_STRING_EXTERN(console.main_wrap.paths.default_rom_startup_dir, "default_rom_startup_dir");
CONFIG_GET_BOOL_EXTERN(console.screen.gamma_correction, "gamma_correction");
CONFIG_GET_BOOL_EXTERN(console.rmenu.state.msg_info.enable, "info_msg_enable");
CONFIG_GET_BOOL_EXTERN(console.screen.state.screenshots.enable, "screenshots_enable");
CONFIG_GET_BOOL_EXTERN(console.screen.state.throttle.enable, "throttle_enable");
CONFIG_GET_BOOL_EXTERN(console.screen.state.triple_buffering.enable, "triple_buffering_enable");
CONFIG_GET_BOOL_EXTERN(console.screen.state.overscan.enable, "overscan_enable");
CONFIG_GET_BOOL_EXTERN(console.sound.custom_bgm.enable, "custom_bgm_enable");
CONFIG_GET_BOOL_EXTERN(console.main_wrap.state.default_sram_dir.enable, "sram_dir_enable");
CONFIG_GET_BOOL_EXTERN(console.main_wrap.state.default_savestate_dir.enable, "savestate_dir_enable");
CONFIG_GET_FLOAT_EXTERN(console.screen.overscan_amount, "overscan_amount");
#ifdef _XBOX1
CONFIG_GET_INT_EXTERN(console.screen.state.flicker_filter.enable, "flicker_filter");
CONFIG_GET_INT_EXTERN(console.sound.volume_level, "sound_volume_level");
#endif
#ifdef HAVE_ZLIB
CONFIG_GET_INT_EXTERN(file_state.zip_extract_mode, "zip_extract_mode");
#endif
CONFIG_GET_INT_EXTERN(console.screen.resolutions.current.id, "current_resolution_id");
CONFIG_GET_INT_EXTERN(state_slot, "state_slot");
CONFIG_GET_INT_EXTERN(audio_data.mute, "audio_mute");
CONFIG_GET_BOOL_EXTERN(console.screen.state.soft_filter.enable, "soft_display_filter_enable");
CONFIG_GET_INT_EXTERN(console.screen.orientation, "screen_orientation");
CONFIG_GET_INT_EXTERN(console.sound.mode, "sound_mode");
CONFIG_GET_INT_EXTERN(console.screen.viewports.custom_vp.x, "custom_viewport_x");
CONFIG_GET_INT_EXTERN(console.screen.viewports.custom_vp.y, "custom_viewport_y");
CONFIG_GET_INT_EXTERN(console.screen.viewports.custom_vp.width, "custom_viewport_width");
CONFIG_GET_INT_EXTERN(console.screen.viewports.custom_vp.height, "custom_viewport_height");
CONFIG_GET_FLOAT_EXTERN(console.rmenu.font_size, "menu_font_size");
#endif
unsigned msg_color = 0;
if (config_get_hex(conf, "video_message_color", &msg_color))
{