2011-01-17 19:54:58 +00:00
|
|
|
/* SSNES - A Super Nintendo Entertainment System (SNES) Emulator frontend for libsnes.
|
2011-01-23 19:29:28 +00:00
|
|
|
* Copyright (C) 2010-2011 - Hans-Kristian Arntzen
|
2010-12-30 00:50:37 +00:00
|
|
|
*
|
|
|
|
* Some code herein may be based on code found in BSNES.
|
|
|
|
*
|
|
|
|
* SSNES 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.
|
|
|
|
*
|
|
|
|
* SSNES 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 SSNES.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2010-12-29 18:00:21 +00:00
|
|
|
#include "general.h"
|
|
|
|
#include "conf/config_file.h"
|
2011-09-13 12:40:33 +00:00
|
|
|
#include "input/keysym.h"
|
2010-12-29 18:00:21 +00:00
|
|
|
#include <assert.h>
|
2011-04-03 20:29:36 +00:00
|
|
|
#include "strl.h"
|
2011-01-08 21:15:02 +00:00
|
|
|
#include "config.def.h"
|
2011-08-24 13:47:39 +00:00
|
|
|
#include "file.h"
|
2011-01-07 16:59:53 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
2010-12-30 02:02:30 +00:00
|
|
|
#include "config.h"
|
2011-01-07 16:59:53 +00:00
|
|
|
#endif
|
|
|
|
|
2010-12-30 03:51:08 +00:00
|
|
|
#include <ctype.h>
|
2010-12-29 18:00:21 +00:00
|
|
|
|
|
|
|
struct settings g_settings;
|
2011-08-26 15:32:04 +00:00
|
|
|
struct global g_extern;
|
2010-12-29 18:00:21 +00:00
|
|
|
|
2011-01-19 12:07:11 +00:00
|
|
|
#ifdef HAVE_CONFIGFILE
|
2010-12-30 03:51:08 +00:00
|
|
|
static void read_keybinds(config_file_t *conf);
|
2011-01-19 12:07:11 +00:00
|
|
|
#endif
|
2010-12-30 03:51:08 +00:00
|
|
|
|
2010-12-29 18:00:21 +00:00
|
|
|
static void set_defaults(void)
|
|
|
|
{
|
2010-12-29 19:50:50 +00:00
|
|
|
const char *def_video = NULL;
|
|
|
|
const char *def_audio = NULL;
|
2011-01-06 17:34:11 +00:00
|
|
|
const char *def_input = NULL;
|
2010-12-29 19:50:50 +00:00
|
|
|
|
|
|
|
switch (VIDEO_DEFAULT_DRIVER)
|
|
|
|
{
|
|
|
|
case VIDEO_GL:
|
2011-01-06 17:34:11 +00:00
|
|
|
def_video = "gl";
|
2010-12-29 19:50:50 +00:00
|
|
|
break;
|
2011-03-13 03:51:09 +00:00
|
|
|
case VIDEO_XVIDEO:
|
|
|
|
def_video = "xvideo";
|
|
|
|
break;
|
2011-04-21 01:23:44 +00:00
|
|
|
case VIDEO_SDL:
|
|
|
|
def_video = "sdl";
|
|
|
|
break;
|
2011-05-11 15:57:31 +00:00
|
|
|
case VIDEO_EXT:
|
|
|
|
def_video = "ext";
|
|
|
|
break;
|
2010-12-29 19:50:50 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (AUDIO_DEFAULT_DRIVER)
|
|
|
|
{
|
|
|
|
case AUDIO_RSOUND:
|
|
|
|
def_audio = "rsound";
|
|
|
|
break;
|
|
|
|
case AUDIO_OSS:
|
|
|
|
def_audio = "oss";
|
|
|
|
break;
|
|
|
|
case AUDIO_ALSA:
|
|
|
|
def_audio = "alsa";
|
|
|
|
break;
|
|
|
|
case AUDIO_ROAR:
|
|
|
|
def_audio = "roar";
|
|
|
|
break;
|
2011-08-08 15:27:52 +00:00
|
|
|
case AUDIO_COREAUDIO:
|
|
|
|
def_audio = "coreaudio";
|
|
|
|
break;
|
2010-12-29 19:50:50 +00:00
|
|
|
case AUDIO_AL:
|
|
|
|
def_audio = "openal";
|
|
|
|
break;
|
2011-01-07 16:59:53 +00:00
|
|
|
case AUDIO_SDL:
|
|
|
|
def_audio = "sdl";
|
|
|
|
break;
|
2011-08-04 16:45:40 +00:00
|
|
|
case AUDIO_DSOUND:
|
|
|
|
def_audio = "dsound";
|
|
|
|
break;
|
2011-01-27 00:46:00 +00:00
|
|
|
case AUDIO_XAUDIO:
|
|
|
|
def_audio = "xaudio";
|
|
|
|
break;
|
2011-01-29 00:15:09 +00:00
|
|
|
case AUDIO_PULSE:
|
|
|
|
def_audio = "pulse";
|
|
|
|
break;
|
2011-05-14 23:46:11 +00:00
|
|
|
case AUDIO_EXT:
|
|
|
|
def_audio = "ext";
|
|
|
|
break;
|
2010-12-29 19:50:50 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-01-06 17:34:11 +00:00
|
|
|
switch (INPUT_DEFAULT_DRIVER)
|
|
|
|
{
|
|
|
|
case INPUT_SDL:
|
|
|
|
def_input = "sdl";
|
|
|
|
break;
|
2011-03-13 03:51:09 +00:00
|
|
|
case INPUT_X:
|
|
|
|
def_input = "x";
|
|
|
|
break;
|
2011-01-06 17:34:11 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-12-29 19:50:50 +00:00
|
|
|
if (def_video)
|
2011-04-03 20:29:36 +00:00
|
|
|
strlcpy(g_settings.video.driver, def_video, sizeof(g_settings.video.driver));
|
2010-12-29 19:50:50 +00:00
|
|
|
if (def_audio)
|
2011-04-03 20:29:36 +00:00
|
|
|
strlcpy(g_settings.audio.driver, def_audio, sizeof(g_settings.audio.driver));
|
2011-01-06 17:34:11 +00:00
|
|
|
if (def_input)
|
2011-04-03 20:29:36 +00:00
|
|
|
strlcpy(g_settings.input.driver, def_input, sizeof(g_settings.input.driver));
|
2010-12-29 19:50:50 +00:00
|
|
|
|
2010-12-29 18:00:21 +00:00
|
|
|
g_settings.video.xscale = xscale;
|
|
|
|
g_settings.video.yscale = yscale;
|
2011-07-09 06:37:08 +00:00
|
|
|
g_settings.video.fullscreen = g_extern.force_fullscreen ? true : fullscreen;
|
2010-12-29 18:00:21 +00:00
|
|
|
g_settings.video.fullscreen_x = fullscreen_x;
|
|
|
|
g_settings.video.fullscreen_y = fullscreen_y;
|
2011-04-21 11:12:45 +00:00
|
|
|
g_settings.video.force_16bit = force_16bit;
|
2011-08-07 13:00:34 +00:00
|
|
|
g_settings.video.disable_composition = disable_composition;
|
2010-12-29 18:00:21 +00:00
|
|
|
g_settings.video.vsync = vsync;
|
2010-12-29 18:18:37 +00:00
|
|
|
g_settings.video.smooth = video_smooth;
|
2010-12-29 18:00:21 +00:00
|
|
|
g_settings.video.force_aspect = force_aspect;
|
2011-05-05 12:13:12 +00:00
|
|
|
g_settings.video.crop_overscan = crop_overscan;
|
2011-01-06 19:01:32 +00:00
|
|
|
g_settings.video.aspect_ratio = SNES_ASPECT_RATIO;
|
2011-02-28 15:59:31 +00:00
|
|
|
g_settings.video.shader_type = SSNES_SHADER_AUTO;
|
2010-12-29 18:00:21 +00:00
|
|
|
|
2011-01-23 01:48:06 +00:00
|
|
|
#ifdef HAVE_FREETYPE
|
|
|
|
g_settings.video.font_size = font_size;
|
2011-01-23 01:59:44 +00:00
|
|
|
g_settings.video.msg_pos_x = message_pos_offset_x;
|
|
|
|
g_settings.video.msg_pos_y = message_pos_offset_y;
|
2011-09-05 15:00:28 +00:00
|
|
|
|
|
|
|
g_settings.video.msg_color_r = ((message_color >> 16) & 0xff) / 255.0f;
|
|
|
|
g_settings.video.msg_color_g = ((message_color >> 8) & 0xff) / 255.0f;
|
|
|
|
g_settings.video.msg_color_b = ((message_color >> 0) & 0xff) / 255.0f;
|
2011-01-23 01:48:06 +00:00
|
|
|
#endif
|
|
|
|
|
2011-03-06 17:19:31 +00:00
|
|
|
#if defined(HAVE_CG) || defined(HAVE_XML)
|
|
|
|
g_settings.video.render_to_texture = render_to_texture;
|
|
|
|
g_settings.video.fbo_scale_x = fbo_scale_x;
|
|
|
|
g_settings.video.fbo_scale_y = fbo_scale_y;
|
|
|
|
g_settings.video.second_pass_smooth = second_pass_smooth;
|
|
|
|
#endif
|
|
|
|
|
2011-08-11 03:25:31 +00:00
|
|
|
g_settings.video.hires_record = hires_record;
|
|
|
|
g_settings.video.post_filter_record = post_filter_record;
|
|
|
|
|
2010-12-29 18:00:21 +00:00
|
|
|
g_settings.audio.enable = audio_enable;
|
|
|
|
g_settings.audio.out_rate = out_rate;
|
|
|
|
g_settings.audio.in_rate = in_rate;
|
2011-01-29 17:42:21 +00:00
|
|
|
g_settings.audio.rate_step = audio_rate_step;
|
2010-12-29 18:00:21 +00:00
|
|
|
if (audio_device)
|
2011-04-03 20:29:36 +00:00
|
|
|
strlcpy(g_settings.audio.device, audio_device, sizeof(g_settings.audio.device));
|
2010-12-29 18:00:21 +00:00
|
|
|
g_settings.audio.latency = out_latency;
|
|
|
|
g_settings.audio.sync = audio_sync;
|
2011-02-06 12:29:48 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_SRC
|
2010-12-29 18:00:21 +00:00
|
|
|
g_settings.audio.src_quality = SAMPLERATE_QUALITY;
|
2011-02-06 12:29:48 +00:00
|
|
|
#endif
|
2010-12-29 18:00:21 +00:00
|
|
|
|
2011-01-31 17:06:57 +00:00
|
|
|
g_settings.rewind_enable = rewind_enable;
|
|
|
|
g_settings.rewind_buffer_size = rewind_buffer_size;
|
2011-02-01 16:30:18 +00:00
|
|
|
g_settings.rewind_granularity = rewind_granularity;
|
2011-02-05 20:45:44 +00:00
|
|
|
g_settings.pause_nonactive = pause_nonactive;
|
2011-02-10 20:16:59 +00:00
|
|
|
g_settings.autosave_interval = autosave_interval;
|
2011-01-31 17:06:57 +00:00
|
|
|
|
2010-12-29 18:00:21 +00:00
|
|
|
assert(sizeof(g_settings.input.binds[0]) >= sizeof(snes_keybinds_1));
|
2011-05-18 12:07:31 +00:00
|
|
|
assert(sizeof(g_settings.input.binds[1]) >= sizeof(snes_keybinds_rest));
|
2010-12-29 18:00:21 +00:00
|
|
|
memcpy(g_settings.input.binds[0], snes_keybinds_1, sizeof(snes_keybinds_1));
|
2011-05-18 12:07:31 +00:00
|
|
|
for (unsigned i = 1; i < 5; i++)
|
|
|
|
memcpy(g_settings.input.binds[i], snes_keybinds_rest, sizeof(snes_keybinds_rest));
|
2010-12-29 18:43:17 +00:00
|
|
|
|
2011-09-06 17:53:22 +00:00
|
|
|
g_settings.input.axis_threshold = axis_threshold;
|
2011-02-20 11:12:53 +00:00
|
|
|
g_settings.input.netplay_client_swap_input = netplay_client_swap_input;
|
2011-01-27 22:05:20 +00:00
|
|
|
for (int i = 0; i < MAX_PLAYERS; i++)
|
2011-01-10 15:53:37 +00:00
|
|
|
g_settings.input.joypad_map[i] = i;
|
2011-02-20 11:12:53 +00:00
|
|
|
|
2010-12-29 18:00:21 +00:00
|
|
|
}
|
|
|
|
|
2011-01-19 11:54:19 +00:00
|
|
|
#ifdef HAVE_CONFIGFILE
|
|
|
|
static void parse_config_file(void);
|
|
|
|
#endif
|
|
|
|
|
2010-12-29 18:00:21 +00:00
|
|
|
void parse_config(void)
|
|
|
|
{
|
2011-01-19 11:54:19 +00:00
|
|
|
set_defaults();
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIGFILE
|
|
|
|
parse_config_file();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-05-26 18:44:12 +00:00
|
|
|
#ifdef HAVE_CONFIGFILE
|
2011-02-22 10:28:28 +00:00
|
|
|
static config_file_t *open_default_config_file(void)
|
|
|
|
{
|
|
|
|
config_file_t *conf = NULL;
|
|
|
|
#ifdef _WIN32
|
|
|
|
// Just do something for now.
|
|
|
|
conf = config_file_new("ssnes.cfg");
|
|
|
|
if (!conf)
|
|
|
|
{
|
|
|
|
const char *appdata = getenv("APPDATA");
|
|
|
|
if (appdata)
|
|
|
|
{
|
2011-08-26 15:32:04 +00:00
|
|
|
char conf_path[MAXPATHLEN];
|
2011-06-16 20:47:37 +00:00
|
|
|
strlcpy(conf_path, appdata, sizeof(conf_path));
|
|
|
|
strlcat(conf_path, "/ssnes.cfg", sizeof(conf_path));
|
2011-02-22 10:28:28 +00:00
|
|
|
conf = config_file_new(conf_path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#elif defined(__APPLE__)
|
|
|
|
const char *home = getenv("HOME");
|
|
|
|
if (home)
|
|
|
|
{
|
2011-08-26 15:32:04 +00:00
|
|
|
char conf_path[MAXPATHLEN];
|
2011-06-16 20:47:37 +00:00
|
|
|
strlcpy(conf_path, home, sizeof(conf_path));
|
|
|
|
strlcat(conf_path, "/.ssnes.cfg", sizeof(conf_path));
|
2011-02-22 10:28:28 +00:00
|
|
|
conf = config_file_new(conf_path);
|
|
|
|
}
|
|
|
|
if (!conf)
|
|
|
|
conf = config_file_new("/etc/ssnes.cfg");
|
|
|
|
#else
|
|
|
|
const char *xdg = getenv("XDG_CONFIG_HOME");
|
|
|
|
if (!xdg)
|
2011-05-19 13:51:30 +00:00
|
|
|
SSNES_WARN("XDG_CONFIG_HOME is not defined. Will look for config in $HOME/.ssnes.cfg ...\n");
|
2011-02-22 10:28:28 +00:00
|
|
|
|
|
|
|
const char *home = getenv("HOME");
|
|
|
|
if (xdg)
|
|
|
|
{
|
2011-08-26 15:32:04 +00:00
|
|
|
char conf_path[MAXPATHLEN];
|
2011-06-16 20:47:37 +00:00
|
|
|
strlcpy(conf_path, xdg, sizeof(conf_path));
|
|
|
|
strlcat(conf_path, "/ssnes/ssnes.cfg", sizeof(conf_path));
|
2011-02-22 10:28:28 +00:00
|
|
|
conf = config_file_new(conf_path);
|
|
|
|
}
|
|
|
|
else if (home)
|
|
|
|
{
|
2011-08-26 15:32:04 +00:00
|
|
|
char conf_path[MAXPATHLEN];
|
2011-06-16 20:47:37 +00:00
|
|
|
strlcpy(conf_path, home, sizeof(conf_path));
|
|
|
|
strlcat(conf_path, "/.ssnes.cfg", sizeof(conf_path));
|
2011-02-22 10:28:28 +00:00
|
|
|
conf = config_file_new(conf_path);
|
|
|
|
}
|
|
|
|
// Try this as a last chance...
|
|
|
|
if (!conf)
|
|
|
|
conf = config_file_new("/etc/ssnes.cfg");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return conf;
|
|
|
|
}
|
2011-05-26 18:44:12 +00:00
|
|
|
#endif
|
2011-02-22 10:28:28 +00:00
|
|
|
|
2011-02-01 16:13:26 +00:00
|
|
|
// Macros to ease config getting.
|
|
|
|
#define CONFIG_GET_BOOL(var, key) if (config_get_bool(conf, key, &tmp_bool)) \
|
|
|
|
g_settings.var = tmp_bool
|
|
|
|
|
|
|
|
#define CONFIG_GET_INT(var, key) if (config_get_int(conf, key, &tmp_int)) \
|
|
|
|
g_settings.var = tmp_int
|
|
|
|
|
|
|
|
#define CONFIG_GET_DOUBLE(var, key) if (config_get_double(conf, key, &tmp_double)) \
|
|
|
|
g_settings.var = tmp_double
|
|
|
|
|
2011-08-25 14:29:17 +00:00
|
|
|
#define CONFIG_GET_STRING(var, key) \
|
|
|
|
config_get_array(conf, key, g_settings.var, sizeof(g_settings.var))
|
2011-02-01 16:13:26 +00:00
|
|
|
|
2011-01-19 11:54:19 +00:00
|
|
|
#ifdef HAVE_CONFIGFILE
|
|
|
|
static void parse_config_file(void)
|
|
|
|
{
|
2010-12-29 18:00:21 +00:00
|
|
|
config_file_t *conf = NULL;
|
|
|
|
|
2010-12-30 00:33:40 +00:00
|
|
|
if (strlen(g_extern.config_path) > 0)
|
2010-12-29 18:00:21 +00:00
|
|
|
{
|
2010-12-30 00:33:40 +00:00
|
|
|
conf = config_file_new(g_extern.config_path);
|
|
|
|
if (!conf)
|
|
|
|
{
|
|
|
|
SSNES_ERR("Couldn't find config at path: \"%s\"\n", g_extern.config_path);
|
|
|
|
exit(1);
|
|
|
|
}
|
2010-12-29 18:00:21 +00:00
|
|
|
}
|
|
|
|
else
|
2011-02-22 10:28:28 +00:00
|
|
|
conf = open_default_config_file();
|
2010-12-29 18:00:21 +00:00
|
|
|
|
|
|
|
if (conf == NULL)
|
|
|
|
return;
|
|
|
|
|
2011-01-09 14:50:30 +00:00
|
|
|
if (g_extern.verbose)
|
|
|
|
config_file_dump(conf, stderr);
|
|
|
|
|
2010-12-29 18:00:21 +00:00
|
|
|
int tmp_int;
|
|
|
|
double tmp_double;
|
|
|
|
bool tmp_bool;
|
2011-08-25 14:15:34 +00:00
|
|
|
char tmp_str[MAXPATHLEN];
|
2010-12-29 18:00:21 +00:00
|
|
|
|
2011-02-01 16:13:26 +00:00
|
|
|
CONFIG_GET_DOUBLE(video.xscale, "video_xscale");
|
|
|
|
CONFIG_GET_DOUBLE(video.yscale, "video_yscale");
|
|
|
|
CONFIG_GET_INT(video.fullscreen_x, "video_fullscreen_x");
|
|
|
|
CONFIG_GET_INT(video.fullscreen_y, "video_fullscreen_y");
|
2011-07-09 06:37:08 +00:00
|
|
|
|
|
|
|
if (!g_extern.force_fullscreen)
|
|
|
|
{
|
|
|
|
CONFIG_GET_BOOL(video.fullscreen, "video_fullscreen");
|
|
|
|
}
|
|
|
|
|
2011-04-21 11:12:45 +00:00
|
|
|
CONFIG_GET_BOOL(video.force_16bit, "video_force_16bit");
|
2011-08-07 13:00:34 +00:00
|
|
|
CONFIG_GET_BOOL(video.disable_composition, "video_disable_composition");
|
2011-02-01 16:13:26 +00:00
|
|
|
CONFIG_GET_BOOL(video.vsync, "video_vsync");
|
|
|
|
CONFIG_GET_BOOL(video.smooth, "video_smooth");
|
|
|
|
CONFIG_GET_BOOL(video.force_aspect, "video_force_aspect");
|
2011-05-05 12:13:12 +00:00
|
|
|
CONFIG_GET_BOOL(video.crop_overscan, "video_crop_overscan");
|
2011-02-01 16:13:26 +00:00
|
|
|
CONFIG_GET_DOUBLE(video.aspect_ratio, "video_aspect_ratio");
|
2010-12-29 18:00:21 +00:00
|
|
|
|
2011-02-01 16:13:26 +00:00
|
|
|
CONFIG_GET_STRING(video.cg_shader_path, "video_cg_shader");
|
|
|
|
CONFIG_GET_STRING(video.bsnes_shader_path, "video_bsnes_shader");
|
2011-03-06 17:19:31 +00:00
|
|
|
CONFIG_GET_STRING(video.second_pass_shader, "video_second_pass_shader");
|
|
|
|
CONFIG_GET_BOOL(video.render_to_texture, "video_render_to_texture");
|
|
|
|
CONFIG_GET_DOUBLE(video.fbo_scale_x, "video_fbo_scale_x");
|
2011-03-06 18:56:35 +00:00
|
|
|
CONFIG_GET_DOUBLE(video.fbo_scale_y, "video_fbo_scale_y");
|
2011-03-06 17:19:31 +00:00
|
|
|
CONFIG_GET_BOOL(video.second_pass_smooth, "video_second_pass_smooth");
|
2011-01-23 01:48:06 +00:00
|
|
|
|
2011-01-23 01:59:44 +00:00
|
|
|
#ifdef HAVE_FREETYPE
|
2011-02-01 16:13:26 +00:00
|
|
|
CONFIG_GET_STRING(video.font_path, "video_font_path");
|
|
|
|
CONFIG_GET_INT(video.font_size, "video_font_size");
|
|
|
|
CONFIG_GET_DOUBLE(video.msg_pos_x, "video_message_pos_x");
|
|
|
|
CONFIG_GET_DOUBLE(video.msg_pos_y, "video_message_pos_y");
|
2011-09-05 15:00:28 +00:00
|
|
|
|
|
|
|
unsigned msg_color;
|
|
|
|
if (config_get_hex(conf, "video_message_color", &msg_color))
|
|
|
|
{
|
|
|
|
g_settings.video.msg_color_r = ((msg_color >> 16) & 0xff) / 255.0f;
|
|
|
|
g_settings.video.msg_color_g = ((msg_color >> 8) & 0xff) / 255.0f;
|
|
|
|
g_settings.video.msg_color_b = ((msg_color >> 0) & 0xff) / 255.0f;
|
|
|
|
}
|
2011-01-23 01:59:44 +00:00
|
|
|
#endif
|
|
|
|
|
2011-08-11 03:25:31 +00:00
|
|
|
CONFIG_GET_BOOL(video.hires_record, "video_hires_record");
|
|
|
|
CONFIG_GET_BOOL(video.post_filter_record, "video_post_filter_record");
|
|
|
|
|
2011-05-11 15:52:16 +00:00
|
|
|
#ifdef HAVE_DYLIB
|
2011-03-07 16:22:03 +00:00
|
|
|
CONFIG_GET_STRING(video.filter_path, "video_filter");
|
2011-05-11 15:52:16 +00:00
|
|
|
CONFIG_GET_STRING(video.external_driver, "video_external_driver");
|
2011-05-14 23:46:11 +00:00
|
|
|
CONFIG_GET_STRING(audio.external_driver, "audio_external_driver");
|
2010-12-30 00:33:40 +00:00
|
|
|
#endif
|
2010-12-29 18:00:21 +00:00
|
|
|
|
2011-02-28 15:59:31 +00:00
|
|
|
#if defined(HAVE_CG) || defined(HAVE_XML)
|
2011-08-25 14:15:34 +00:00
|
|
|
if (config_get_array(conf, "video_shader_type", tmp_str, sizeof(tmp_str)))
|
2011-02-28 15:59:31 +00:00
|
|
|
{
|
|
|
|
if (strcmp("cg", tmp_str) == 0)
|
|
|
|
g_settings.video.shader_type = SSNES_SHADER_CG;
|
|
|
|
else if (strcmp("bsnes", tmp_str) == 0)
|
|
|
|
g_settings.video.shader_type = SSNES_SHADER_BSNES;
|
|
|
|
else if (strcmp("auto", tmp_str) == 0)
|
|
|
|
g_settings.video.shader_type = SSNES_SHADER_AUTO;
|
|
|
|
else if (strcmp("none", tmp_str) == 0)
|
|
|
|
g_settings.video.shader_type = SSNES_SHADER_NONE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2011-03-29 16:04:41 +00:00
|
|
|
#if defined(HAVE_XML)
|
|
|
|
CONFIG_GET_STRING(video.shader_dir, "video_shader_dir");
|
|
|
|
#endif
|
|
|
|
|
2011-02-01 16:13:26 +00:00
|
|
|
CONFIG_GET_DOUBLE(input.axis_threshold, "input_axis_threshold");
|
2011-02-20 11:12:53 +00:00
|
|
|
CONFIG_GET_BOOL(input.netplay_client_swap_input, "netplay_client_swap_input");
|
2011-02-01 16:13:26 +00:00
|
|
|
CONFIG_GET_INT(input.joypad_map[0], "input_player1_joypad_index");
|
|
|
|
CONFIG_GET_INT(input.joypad_map[1], "input_player2_joypad_index");
|
|
|
|
CONFIG_GET_INT(input.joypad_map[2], "input_player3_joypad_index");
|
|
|
|
CONFIG_GET_INT(input.joypad_map[3], "input_player4_joypad_index");
|
|
|
|
CONFIG_GET_INT(input.joypad_map[4], "input_player5_joypad_index");
|
2011-01-10 15:53:37 +00:00
|
|
|
|
2010-12-29 18:00:21 +00:00
|
|
|
// Audio settings.
|
2011-02-01 16:13:26 +00:00
|
|
|
CONFIG_GET_BOOL(audio.enable, "audio_enable");
|
|
|
|
CONFIG_GET_INT(audio.out_rate, "audio_out_rate");
|
|
|
|
CONFIG_GET_DOUBLE(audio.in_rate, "audio_in_rate");
|
|
|
|
CONFIG_GET_DOUBLE(audio.rate_step, "audio_rate_step");
|
|
|
|
CONFIG_GET_STRING(audio.device, "audio_device");
|
|
|
|
CONFIG_GET_INT(audio.latency, "audio_latency");
|
|
|
|
CONFIG_GET_BOOL(audio.sync, "audio_sync");
|
2010-12-29 18:00:21 +00:00
|
|
|
|
2011-02-06 12:29:48 +00:00
|
|
|
#ifdef HAVE_SRC
|
2010-12-29 18:00:21 +00:00
|
|
|
if (config_get_int(conf, "audio_src_quality", &tmp_int))
|
|
|
|
{
|
2010-12-30 00:33:40 +00:00
|
|
|
int quals[] = { SRC_ZERO_ORDER_HOLD, SRC_LINEAR, SRC_SINC_FASTEST,
|
|
|
|
SRC_SINC_MEDIUM_QUALITY, SRC_SINC_BEST_QUALITY };
|
2010-12-29 18:00:21 +00:00
|
|
|
|
|
|
|
if (tmp_int > 0 && tmp_int < 6)
|
|
|
|
g_settings.audio.src_quality = quals[tmp_int];
|
|
|
|
}
|
2011-02-06 12:29:48 +00:00
|
|
|
#endif
|
2010-12-29 18:00:21 +00:00
|
|
|
|
2011-02-01 16:13:26 +00:00
|
|
|
CONFIG_GET_STRING(video.driver, "video_driver");
|
|
|
|
CONFIG_GET_STRING(audio.driver, "audio_driver");
|
2011-05-13 19:05:28 +00:00
|
|
|
CONFIG_GET_STRING(audio.dsp_plugin, "audio_dsp_plugin");
|
2011-02-01 16:13:26 +00:00
|
|
|
CONFIG_GET_STRING(input.driver, "input_driver");
|
|
|
|
CONFIG_GET_STRING(libsnes, "libsnes_path");
|
2011-08-24 13:47:39 +00:00
|
|
|
|
2011-05-15 15:16:29 +00:00
|
|
|
CONFIG_GET_STRING(screenshot_directory, "screenshot_directory");
|
2011-08-24 13:47:39 +00:00
|
|
|
if (*g_settings.screenshot_directory && !path_is_directory(g_settings.screenshot_directory))
|
|
|
|
{
|
|
|
|
SSNES_WARN("screenshot_directory is not an existing directory, ignoring ...\n");
|
|
|
|
*g_settings.screenshot_directory = '\0';
|
|
|
|
}
|
2011-01-31 17:06:57 +00:00
|
|
|
|
2011-02-01 16:13:26 +00:00
|
|
|
CONFIG_GET_BOOL(rewind_enable, "rewind_enable");
|
2011-02-05 10:31:35 +00:00
|
|
|
|
|
|
|
if (config_get_int(conf, "rewind_buffer_size", &tmp_int))
|
|
|
|
g_settings.rewind_buffer_size = tmp_int * 1000000;
|
|
|
|
|
2011-02-01 16:30:18 +00:00
|
|
|
CONFIG_GET_INT(rewind_granularity, "rewind_granularity");
|
2011-01-31 17:06:57 +00:00
|
|
|
|
2011-02-05 20:45:44 +00:00
|
|
|
CONFIG_GET_BOOL(pause_nonactive, "pause_nonactive");
|
2011-02-10 20:16:59 +00:00
|
|
|
CONFIG_GET_INT(autosave_interval, "autosave_interval");
|
2011-02-05 20:45:44 +00:00
|
|
|
|
2011-04-17 11:30:59 +00:00
|
|
|
CONFIG_GET_STRING(cheat_database, "cheat_database_path");
|
2011-09-05 15:57:30 +00:00
|
|
|
CONFIG_GET_STRING(cheat_settings_path, "cheat_settings_path");
|
2011-04-17 11:30:59 +00:00
|
|
|
|
2011-08-26 16:28:05 +00:00
|
|
|
if (!g_extern.has_set_save_path && config_get_array(conf, "savefile_directory", tmp_str, sizeof(tmp_str)))
|
2011-08-24 13:47:39 +00:00
|
|
|
{
|
2011-08-26 16:28:05 +00:00
|
|
|
if (path_is_directory(tmp_str))
|
2011-08-24 13:47:39 +00:00
|
|
|
{
|
2011-08-26 16:28:05 +00:00
|
|
|
strlcpy(g_extern.savefile_name_srm, tmp_str, sizeof(g_extern.savefile_name_srm));
|
2011-08-24 13:47:39 +00:00
|
|
|
fill_pathname_dir(g_extern.savefile_name_srm, g_extern.basename, ".srm", sizeof(g_extern.savefile_name_srm));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SSNES_WARN("savefile_directory is not a directory, ignoring ...!\n");
|
|
|
|
}
|
2011-08-26 16:28:05 +00:00
|
|
|
if (!g_extern.has_set_state_path && config_get_array(conf, "savestate_directory", tmp_str, sizeof(tmp_str)))
|
2011-08-24 13:47:39 +00:00
|
|
|
{
|
2011-08-26 16:28:05 +00:00
|
|
|
if (path_is_directory(tmp_str))
|
2011-08-24 13:47:39 +00:00
|
|
|
{
|
2011-08-26 16:28:05 +00:00
|
|
|
strlcpy(g_extern.savestate_name, tmp_str, sizeof(g_extern.savestate_name));
|
2011-08-24 13:47:39 +00:00
|
|
|
fill_pathname_dir(g_extern.savestate_name, g_extern.basename, ".state", sizeof(g_extern.savestate_name));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
SSNES_WARN("savestate_directory is not a directory, ignoring ...\n");
|
|
|
|
}
|
|
|
|
|
2010-12-30 03:51:08 +00:00
|
|
|
read_keybinds(conf);
|
2010-12-29 20:12:56 +00:00
|
|
|
|
2010-12-29 18:00:21 +00:00
|
|
|
config_file_free(conf);
|
|
|
|
}
|
2010-12-30 03:51:08 +00:00
|
|
|
|
|
|
|
struct bind_map
|
|
|
|
{
|
|
|
|
const char *key;
|
2010-12-30 04:30:47 +00:00
|
|
|
const char *btn;
|
|
|
|
const char *axis;
|
2010-12-30 03:51:08 +00:00
|
|
|
int snes_key;
|
|
|
|
};
|
|
|
|
|
2011-01-08 17:37:45 +00:00
|
|
|
|
|
|
|
#define DECLARE_BIND(x, bind) { "input_" #x, "input_" #x "_btn", "input_" #x "_axis", bind },
|
2010-12-31 02:00:19 +00:00
|
|
|
// Big and nasty bind map... :)
|
2011-01-10 15:53:37 +00:00
|
|
|
static const struct bind_map bind_maps[MAX_PLAYERS][MAX_BINDS - 1] = {
|
2010-12-30 03:51:08 +00:00
|
|
|
{
|
2011-01-08 17:37:45 +00:00
|
|
|
DECLARE_BIND(player1_a, SNES_DEVICE_ID_JOYPAD_A)
|
|
|
|
DECLARE_BIND(player1_b, SNES_DEVICE_ID_JOYPAD_B)
|
|
|
|
DECLARE_BIND(player1_y, SNES_DEVICE_ID_JOYPAD_Y)
|
|
|
|
DECLARE_BIND(player1_x, SNES_DEVICE_ID_JOYPAD_X)
|
|
|
|
DECLARE_BIND(player1_start, SNES_DEVICE_ID_JOYPAD_START)
|
|
|
|
DECLARE_BIND(player1_select, SNES_DEVICE_ID_JOYPAD_SELECT)
|
|
|
|
DECLARE_BIND(player1_l, SNES_DEVICE_ID_JOYPAD_L)
|
|
|
|
DECLARE_BIND(player1_r, SNES_DEVICE_ID_JOYPAD_R)
|
|
|
|
DECLARE_BIND(player1_left, SNES_DEVICE_ID_JOYPAD_LEFT)
|
|
|
|
DECLARE_BIND(player1_right, SNES_DEVICE_ID_JOYPAD_RIGHT)
|
|
|
|
DECLARE_BIND(player1_up, SNES_DEVICE_ID_JOYPAD_UP)
|
|
|
|
DECLARE_BIND(player1_down, SNES_DEVICE_ID_JOYPAD_DOWN)
|
|
|
|
DECLARE_BIND(toggle_fast_forward, SSNES_FAST_FORWARD_KEY)
|
2011-05-24 00:31:21 +00:00
|
|
|
DECLARE_BIND(hold_fast_forward, SSNES_FAST_FORWARD_HOLD_KEY)
|
2011-01-08 17:37:45 +00:00
|
|
|
DECLARE_BIND(save_state, SSNES_SAVE_STATE_KEY)
|
|
|
|
DECLARE_BIND(load_state, SSNES_LOAD_STATE_KEY)
|
2011-01-23 22:09:54 +00:00
|
|
|
DECLARE_BIND(state_slot_increase, SSNES_STATE_SLOT_PLUS)
|
|
|
|
DECLARE_BIND(state_slot_decrease, SSNES_STATE_SLOT_MINUS)
|
2011-01-08 17:37:45 +00:00
|
|
|
DECLARE_BIND(exit_emulator, SSNES_QUIT_KEY)
|
|
|
|
DECLARE_BIND(toggle_fullscreen, SSNES_FULLSCREEN_TOGGLE_KEY)
|
2011-01-29 17:42:21 +00:00
|
|
|
DECLARE_BIND(rate_step_up, SSNES_AUDIO_INPUT_RATE_PLUS)
|
|
|
|
DECLARE_BIND(rate_step_down, SSNES_AUDIO_INPUT_RATE_MINUS)
|
2011-01-31 17:06:57 +00:00
|
|
|
DECLARE_BIND(rewind, SSNES_REWIND)
|
2011-02-02 11:45:56 +00:00
|
|
|
DECLARE_BIND(movie_record_toggle, SSNES_MOVIE_RECORD_TOGGLE)
|
2011-02-26 23:24:50 +00:00
|
|
|
DECLARE_BIND(pause_toggle, SSNES_PAUSE_TOGGLE)
|
2011-03-24 19:41:28 +00:00
|
|
|
DECLARE_BIND(reset, SSNES_RESET)
|
2011-03-29 16:04:41 +00:00
|
|
|
DECLARE_BIND(shader_next, SSNES_SHADER_NEXT)
|
|
|
|
DECLARE_BIND(shader_prev, SSNES_SHADER_PREV)
|
2011-04-17 11:30:59 +00:00
|
|
|
DECLARE_BIND(cheat_index_plus, SSNES_CHEAT_INDEX_PLUS)
|
|
|
|
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
|
|
|
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
2011-05-15 15:16:29 +00:00
|
|
|
DECLARE_BIND(screenshot, SSNES_SCREENSHOT)
|
2011-05-17 17:20:41 +00:00
|
|
|
DECLARE_BIND(dsp_config, SSNES_DSP_CONFIG)
|
2011-01-08 17:37:45 +00:00
|
|
|
},
|
2010-12-30 03:51:08 +00:00
|
|
|
{
|
2011-01-08 17:37:45 +00:00
|
|
|
DECLARE_BIND(player2_a, SNES_DEVICE_ID_JOYPAD_A)
|
|
|
|
DECLARE_BIND(player2_b, SNES_DEVICE_ID_JOYPAD_B)
|
|
|
|
DECLARE_BIND(player2_y, SNES_DEVICE_ID_JOYPAD_Y)
|
|
|
|
DECLARE_BIND(player2_x, SNES_DEVICE_ID_JOYPAD_X)
|
|
|
|
DECLARE_BIND(player2_start, SNES_DEVICE_ID_JOYPAD_START)
|
|
|
|
DECLARE_BIND(player2_select, SNES_DEVICE_ID_JOYPAD_SELECT)
|
|
|
|
DECLARE_BIND(player2_l, SNES_DEVICE_ID_JOYPAD_L)
|
|
|
|
DECLARE_BIND(player2_r, SNES_DEVICE_ID_JOYPAD_R)
|
|
|
|
DECLARE_BIND(player2_left, SNES_DEVICE_ID_JOYPAD_LEFT)
|
|
|
|
DECLARE_BIND(player2_right, SNES_DEVICE_ID_JOYPAD_RIGHT)
|
|
|
|
DECLARE_BIND(player2_up, SNES_DEVICE_ID_JOYPAD_UP)
|
|
|
|
DECLARE_BIND(player2_down, SNES_DEVICE_ID_JOYPAD_DOWN)
|
|
|
|
DECLARE_BIND(toggle_fast_forward, SSNES_FAST_FORWARD_KEY)
|
2011-05-24 00:31:21 +00:00
|
|
|
DECLARE_BIND(hold_fast_forward, SSNES_FAST_FORWARD_HOLD_KEY)
|
2011-01-08 17:37:45 +00:00
|
|
|
DECLARE_BIND(save_state, SSNES_SAVE_STATE_KEY)
|
|
|
|
DECLARE_BIND(load_state, SSNES_LOAD_STATE_KEY)
|
2011-01-23 22:09:54 +00:00
|
|
|
DECLARE_BIND(state_slot_increase, SSNES_STATE_SLOT_PLUS)
|
|
|
|
DECLARE_BIND(state_slot_decrease, SSNES_STATE_SLOT_MINUS)
|
2011-01-08 17:37:45 +00:00
|
|
|
DECLARE_BIND(exit_emulator, SSNES_QUIT_KEY)
|
|
|
|
DECLARE_BIND(toggle_fullscreen, SSNES_FULLSCREEN_TOGGLE_KEY)
|
2011-01-29 17:42:21 +00:00
|
|
|
DECLARE_BIND(rate_step_up, SSNES_AUDIO_INPUT_RATE_PLUS)
|
|
|
|
DECLARE_BIND(rate_step_down, SSNES_AUDIO_INPUT_RATE_MINUS)
|
2011-01-31 17:06:57 +00:00
|
|
|
DECLARE_BIND(rewind, SSNES_REWIND)
|
2011-02-02 11:45:56 +00:00
|
|
|
DECLARE_BIND(movie_record_toggle, SSNES_MOVIE_RECORD_TOGGLE)
|
2011-02-26 23:24:50 +00:00
|
|
|
DECLARE_BIND(pause_toggle, SSNES_PAUSE_TOGGLE)
|
2011-03-24 19:41:28 +00:00
|
|
|
DECLARE_BIND(reset, SSNES_RESET)
|
2011-03-29 16:04:41 +00:00
|
|
|
DECLARE_BIND(shader_next, SSNES_SHADER_NEXT)
|
|
|
|
DECLARE_BIND(shader_prev, SSNES_SHADER_PREV)
|
2011-04-17 11:30:59 +00:00
|
|
|
DECLARE_BIND(cheat_index_plus, SSNES_CHEAT_INDEX_PLUS)
|
|
|
|
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
|
|
|
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
2011-05-15 15:16:29 +00:00
|
|
|
DECLARE_BIND(screenshot, SSNES_SCREENSHOT)
|
2011-05-17 17:20:41 +00:00
|
|
|
DECLARE_BIND(dsp_config, SSNES_DSP_CONFIG)
|
2011-01-10 15:53:37 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
DECLARE_BIND(player3_a, SNES_DEVICE_ID_JOYPAD_A)
|
|
|
|
DECLARE_BIND(player3_b, SNES_DEVICE_ID_JOYPAD_B)
|
|
|
|
DECLARE_BIND(player3_y, SNES_DEVICE_ID_JOYPAD_Y)
|
|
|
|
DECLARE_BIND(player3_x, SNES_DEVICE_ID_JOYPAD_X)
|
|
|
|
DECLARE_BIND(player3_start, SNES_DEVICE_ID_JOYPAD_START)
|
|
|
|
DECLARE_BIND(player3_select, SNES_DEVICE_ID_JOYPAD_SELECT)
|
|
|
|
DECLARE_BIND(player3_l, SNES_DEVICE_ID_JOYPAD_L)
|
|
|
|
DECLARE_BIND(player3_r, SNES_DEVICE_ID_JOYPAD_R)
|
|
|
|
DECLARE_BIND(player3_left, SNES_DEVICE_ID_JOYPAD_LEFT)
|
|
|
|
DECLARE_BIND(player3_right, SNES_DEVICE_ID_JOYPAD_RIGHT)
|
|
|
|
DECLARE_BIND(player3_up, SNES_DEVICE_ID_JOYPAD_UP)
|
|
|
|
DECLARE_BIND(player3_down, SNES_DEVICE_ID_JOYPAD_DOWN)
|
|
|
|
DECLARE_BIND(toggle_fast_forward, SSNES_FAST_FORWARD_KEY)
|
2011-05-24 00:31:21 +00:00
|
|
|
DECLARE_BIND(hold_fast_forward, SSNES_FAST_FORWARD_HOLD_KEY)
|
2011-01-10 15:53:37 +00:00
|
|
|
DECLARE_BIND(save_state, SSNES_SAVE_STATE_KEY)
|
|
|
|
DECLARE_BIND(load_state, SSNES_LOAD_STATE_KEY)
|
2011-01-23 22:09:54 +00:00
|
|
|
DECLARE_BIND(state_slot_increase, SSNES_STATE_SLOT_PLUS)
|
|
|
|
DECLARE_BIND(state_slot_decrease, SSNES_STATE_SLOT_MINUS)
|
2011-01-10 15:53:37 +00:00
|
|
|
DECLARE_BIND(exit_emulator, SSNES_QUIT_KEY)
|
|
|
|
DECLARE_BIND(toggle_fullscreen, SSNES_FULLSCREEN_TOGGLE_KEY)
|
2011-01-29 17:42:21 +00:00
|
|
|
DECLARE_BIND(rate_step_up, SSNES_AUDIO_INPUT_RATE_PLUS)
|
|
|
|
DECLARE_BIND(rate_step_down, SSNES_AUDIO_INPUT_RATE_MINUS)
|
2011-01-31 17:06:57 +00:00
|
|
|
DECLARE_BIND(rewind, SSNES_REWIND)
|
2011-02-02 11:45:56 +00:00
|
|
|
DECLARE_BIND(movie_record_toggle, SSNES_MOVIE_RECORD_TOGGLE)
|
2011-02-26 23:24:50 +00:00
|
|
|
DECLARE_BIND(pause_toggle, SSNES_PAUSE_TOGGLE)
|
2011-03-24 19:41:28 +00:00
|
|
|
DECLARE_BIND(reset, SSNES_RESET)
|
2011-03-29 16:04:41 +00:00
|
|
|
DECLARE_BIND(shader_next, SSNES_SHADER_NEXT)
|
|
|
|
DECLARE_BIND(shader_prev, SSNES_SHADER_PREV)
|
2011-04-17 11:30:59 +00:00
|
|
|
DECLARE_BIND(cheat_index_plus, SSNES_CHEAT_INDEX_PLUS)
|
|
|
|
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
|
|
|
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
2011-05-15 15:16:29 +00:00
|
|
|
DECLARE_BIND(screenshot, SSNES_SCREENSHOT)
|
2011-05-17 17:20:41 +00:00
|
|
|
DECLARE_BIND(dsp_config, SSNES_DSP_CONFIG)
|
2011-01-10 15:53:37 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
DECLARE_BIND(player4_a, SNES_DEVICE_ID_JOYPAD_A)
|
|
|
|
DECLARE_BIND(player4_b, SNES_DEVICE_ID_JOYPAD_B)
|
|
|
|
DECLARE_BIND(player4_y, SNES_DEVICE_ID_JOYPAD_Y)
|
|
|
|
DECLARE_BIND(player4_x, SNES_DEVICE_ID_JOYPAD_X)
|
|
|
|
DECLARE_BIND(player4_start, SNES_DEVICE_ID_JOYPAD_START)
|
|
|
|
DECLARE_BIND(player4_select, SNES_DEVICE_ID_JOYPAD_SELECT)
|
|
|
|
DECLARE_BIND(player4_l, SNES_DEVICE_ID_JOYPAD_L)
|
|
|
|
DECLARE_BIND(player4_r, SNES_DEVICE_ID_JOYPAD_R)
|
|
|
|
DECLARE_BIND(player4_left, SNES_DEVICE_ID_JOYPAD_LEFT)
|
|
|
|
DECLARE_BIND(player4_right, SNES_DEVICE_ID_JOYPAD_RIGHT)
|
|
|
|
DECLARE_BIND(player4_up, SNES_DEVICE_ID_JOYPAD_UP)
|
|
|
|
DECLARE_BIND(player4_down, SNES_DEVICE_ID_JOYPAD_DOWN)
|
|
|
|
DECLARE_BIND(toggle_fast_forward, SSNES_FAST_FORWARD_KEY)
|
2011-05-24 00:31:21 +00:00
|
|
|
DECLARE_BIND(hold_fast_forward, SSNES_FAST_FORWARD_HOLD_KEY)
|
2011-01-10 15:53:37 +00:00
|
|
|
DECLARE_BIND(save_state, SSNES_SAVE_STATE_KEY)
|
|
|
|
DECLARE_BIND(load_state, SSNES_LOAD_STATE_KEY)
|
2011-01-23 22:09:54 +00:00
|
|
|
DECLARE_BIND(state_slot_increase, SSNES_STATE_SLOT_PLUS)
|
|
|
|
DECLARE_BIND(state_slot_decrease, SSNES_STATE_SLOT_MINUS)
|
2011-01-10 15:53:37 +00:00
|
|
|
DECLARE_BIND(exit_emulator, SSNES_QUIT_KEY)
|
|
|
|
DECLARE_BIND(toggle_fullscreen, SSNES_FULLSCREEN_TOGGLE_KEY)
|
2011-01-29 17:42:21 +00:00
|
|
|
DECLARE_BIND(rate_step_up, SSNES_AUDIO_INPUT_RATE_PLUS)
|
|
|
|
DECLARE_BIND(rate_step_down, SSNES_AUDIO_INPUT_RATE_MINUS)
|
2011-01-31 17:06:57 +00:00
|
|
|
DECLARE_BIND(rewind, SSNES_REWIND)
|
2011-02-02 11:45:56 +00:00
|
|
|
DECLARE_BIND(movie_record_toggle, SSNES_MOVIE_RECORD_TOGGLE)
|
2011-02-26 23:24:50 +00:00
|
|
|
DECLARE_BIND(pause_toggle, SSNES_PAUSE_TOGGLE)
|
2011-03-24 19:41:28 +00:00
|
|
|
DECLARE_BIND(reset, SSNES_RESET)
|
2011-03-29 16:04:41 +00:00
|
|
|
DECLARE_BIND(shader_next, SSNES_SHADER_NEXT)
|
|
|
|
DECLARE_BIND(shader_prev, SSNES_SHADER_PREV)
|
2011-04-17 11:30:59 +00:00
|
|
|
DECLARE_BIND(cheat_index_plus, SSNES_CHEAT_INDEX_PLUS)
|
|
|
|
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
|
|
|
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
2011-05-15 15:16:29 +00:00
|
|
|
DECLARE_BIND(screenshot, SSNES_SCREENSHOT)
|
2011-05-17 17:20:41 +00:00
|
|
|
DECLARE_BIND(dsp_config, SSNES_DSP_CONFIG)
|
2011-01-10 15:53:37 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
DECLARE_BIND(player5_a, SNES_DEVICE_ID_JOYPAD_A)
|
|
|
|
DECLARE_BIND(player5_b, SNES_DEVICE_ID_JOYPAD_B)
|
|
|
|
DECLARE_BIND(player5_y, SNES_DEVICE_ID_JOYPAD_Y)
|
|
|
|
DECLARE_BIND(player5_x, SNES_DEVICE_ID_JOYPAD_X)
|
|
|
|
DECLARE_BIND(player5_start, SNES_DEVICE_ID_JOYPAD_START)
|
|
|
|
DECLARE_BIND(player5_select, SNES_DEVICE_ID_JOYPAD_SELECT)
|
|
|
|
DECLARE_BIND(player5_l, SNES_DEVICE_ID_JOYPAD_L)
|
|
|
|
DECLARE_BIND(player5_r, SNES_DEVICE_ID_JOYPAD_R)
|
|
|
|
DECLARE_BIND(player5_left, SNES_DEVICE_ID_JOYPAD_LEFT)
|
|
|
|
DECLARE_BIND(player5_right, SNES_DEVICE_ID_JOYPAD_RIGHT)
|
|
|
|
DECLARE_BIND(player5_up, SNES_DEVICE_ID_JOYPAD_UP)
|
|
|
|
DECLARE_BIND(player5_down, SNES_DEVICE_ID_JOYPAD_DOWN)
|
|
|
|
DECLARE_BIND(toggle_fast_forward, SSNES_FAST_FORWARD_KEY)
|
2011-05-24 00:31:21 +00:00
|
|
|
DECLARE_BIND(hold_fast_forward, SSNES_FAST_FORWARD_HOLD_KEY)
|
2011-01-10 15:53:37 +00:00
|
|
|
DECLARE_BIND(save_state, SSNES_SAVE_STATE_KEY)
|
|
|
|
DECLARE_BIND(load_state, SSNES_LOAD_STATE_KEY)
|
2011-01-23 22:09:54 +00:00
|
|
|
DECLARE_BIND(state_slot_increase, SSNES_STATE_SLOT_PLUS)
|
|
|
|
DECLARE_BIND(state_slot_decrease, SSNES_STATE_SLOT_MINUS)
|
2011-01-10 15:53:37 +00:00
|
|
|
DECLARE_BIND(exit_emulator, SSNES_QUIT_KEY)
|
|
|
|
DECLARE_BIND(toggle_fullscreen, SSNES_FULLSCREEN_TOGGLE_KEY)
|
2011-01-29 17:42:21 +00:00
|
|
|
DECLARE_BIND(rate_step_up, SSNES_AUDIO_INPUT_RATE_PLUS)
|
|
|
|
DECLARE_BIND(rate_step_down, SSNES_AUDIO_INPUT_RATE_MINUS)
|
2011-01-31 17:06:57 +00:00
|
|
|
DECLARE_BIND(rewind, SSNES_REWIND)
|
2011-02-02 11:45:56 +00:00
|
|
|
DECLARE_BIND(movie_record_toggle, SSNES_MOVIE_RECORD_TOGGLE)
|
2011-02-26 23:24:50 +00:00
|
|
|
DECLARE_BIND(pause_toggle, SSNES_PAUSE_TOGGLE)
|
2011-03-24 19:41:28 +00:00
|
|
|
DECLARE_BIND(reset, SSNES_RESET)
|
2011-03-29 16:04:41 +00:00
|
|
|
DECLARE_BIND(shader_next, SSNES_SHADER_NEXT)
|
|
|
|
DECLARE_BIND(shader_prev, SSNES_SHADER_PREV)
|
2011-04-17 11:30:59 +00:00
|
|
|
DECLARE_BIND(cheat_index_plus, SSNES_CHEAT_INDEX_PLUS)
|
|
|
|
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
|
|
|
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
2011-05-15 15:16:29 +00:00
|
|
|
DECLARE_BIND(screenshot, SSNES_SCREENSHOT)
|
2011-05-17 17:20:41 +00:00
|
|
|
DECLARE_BIND(dsp_config, SSNES_DSP_CONFIG)
|
2011-01-10 15:53:37 +00:00
|
|
|
},
|
2010-12-30 03:51:08 +00:00
|
|
|
};
|
|
|
|
|
2011-01-06 17:34:11 +00:00
|
|
|
struct key_map
|
2010-12-30 03:51:08 +00:00
|
|
|
{
|
|
|
|
const char *str;
|
|
|
|
int key;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Edit: Not portable to different input systems atm. Might move this map into the driver itself or something.
|
2011-01-08 17:37:45 +00:00
|
|
|
// However, this should map nicely over to other systems aswell since the definition are mostly the same anyways.
|
2011-09-13 12:40:33 +00:00
|
|
|
static const struct key_map sk_map[] = {
|
|
|
|
{ "left", SK_LEFT },
|
|
|
|
{ "right", SK_RIGHT },
|
|
|
|
{ "up", SK_UP },
|
|
|
|
{ "down", SK_DOWN },
|
|
|
|
{ "enter", SK_RETURN },
|
|
|
|
{ "kp_enter", SK_KP_ENTER },
|
|
|
|
{ "tab", SK_TAB },
|
|
|
|
{ "insert", SK_INSERT },
|
|
|
|
{ "del", SK_DELETE },
|
|
|
|
{ "end", SK_END },
|
|
|
|
{ "home", SK_HOME },
|
|
|
|
{ "rshift", SK_RSHIFT },
|
|
|
|
{ "shift", SK_LSHIFT },
|
|
|
|
{ "ctrl", SK_LCTRL },
|
|
|
|
{ "alt", SK_LALT },
|
|
|
|
{ "space", SK_SPACE },
|
|
|
|
{ "escape", SK_ESCAPE },
|
|
|
|
{ "add", SK_KP_PLUS },
|
|
|
|
{ "subtract", SK_KP_MINUS },
|
|
|
|
{ "f1", SK_F1 },
|
|
|
|
{ "f2", SK_F2 },
|
|
|
|
{ "f3", SK_F3 },
|
|
|
|
{ "f4", SK_F4 },
|
|
|
|
{ "f5", SK_F5 },
|
|
|
|
{ "f6", SK_F6 },
|
|
|
|
{ "f7", SK_F7 },
|
|
|
|
{ "f8", SK_F8 },
|
|
|
|
{ "f9", SK_F9 },
|
|
|
|
{ "f10", SK_F10 },
|
|
|
|
{ "f11", SK_F11 },
|
|
|
|
{ "f12", SK_F12 },
|
|
|
|
{ "num0", SK_0 },
|
|
|
|
{ "num1", SK_1 },
|
|
|
|
{ "num2", SK_2 },
|
|
|
|
{ "num3", SK_3 },
|
|
|
|
{ "num4", SK_4 },
|
|
|
|
{ "num5", SK_5 },
|
|
|
|
{ "num6", SK_6 },
|
|
|
|
{ "num7", SK_7 },
|
|
|
|
{ "num8", SK_8 },
|
|
|
|
{ "num9", SK_9 },
|
|
|
|
{ "pageup", SK_PAGEUP },
|
|
|
|
{ "pagedown", SK_PAGEDOWN },
|
|
|
|
{ "keypad0", SK_KP0 },
|
|
|
|
{ "keypad1", SK_KP1 },
|
|
|
|
{ "keypad2", SK_KP2 },
|
|
|
|
{ "keypad3", SK_KP3 },
|
|
|
|
{ "keypad4", SK_KP4 },
|
|
|
|
{ "keypad5", SK_KP5 },
|
|
|
|
{ "keypad6", SK_KP6 },
|
|
|
|
{ "keypad7", SK_KP7 },
|
|
|
|
{ "keypad8", SK_KP8 },
|
|
|
|
{ "keypad9", SK_KP9 },
|
|
|
|
{ "period", SK_PERIOD },
|
|
|
|
{ "capslock", SK_CAPSLOCK },
|
|
|
|
{ "numlock", SK_NUMLOCK },
|
|
|
|
{ "backspace", SK_BACKSPACE },
|
|
|
|
{ "multiply", SK_KP_MULTIPLY },
|
|
|
|
{ "divide", SK_KP_DIVIDE },
|
|
|
|
{ "print_screen", SK_PRINT },
|
|
|
|
{ "scroll_lock", SK_SCROLLOCK },
|
|
|
|
{ "tilde", SK_BACKQUOTE },
|
|
|
|
{ "backquote", SK_BACKQUOTE },
|
|
|
|
{ "nul", SK_UNKNOWN },
|
2010-12-30 03:51:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct snes_keybind *find_snes_bind(unsigned port, int id)
|
|
|
|
{
|
|
|
|
struct snes_keybind *binds = g_settings.input.binds[port];
|
|
|
|
|
|
|
|
for (int i = 0; binds[i].id != -1; i++)
|
|
|
|
{
|
|
|
|
if (id == binds[i].id)
|
|
|
|
return &binds[i];
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-09-13 12:40:33 +00:00
|
|
|
static int find_sk_bind(const char *str)
|
2010-12-30 03:51:08 +00:00
|
|
|
{
|
2011-09-13 12:40:33 +00:00
|
|
|
for (int i = 0; i < sizeof(sk_map)/sizeof(struct key_map); i++)
|
2010-12-30 03:51:08 +00:00
|
|
|
{
|
2011-09-13 12:40:33 +00:00
|
|
|
if (strcasecmp(sk_map[i].str, str) == 0)
|
|
|
|
return sk_map[i].key;
|
2010-12-30 03:51:08 +00:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-09-13 12:40:33 +00:00
|
|
|
static int find_sk_key(const char *str)
|
2010-12-30 03:51:08 +00:00
|
|
|
{
|
2010-12-30 04:30:47 +00:00
|
|
|
// If the bind is a normal key-press ...
|
|
|
|
if (strlen(str) == 1 && isalpha(*str))
|
2011-09-13 12:40:33 +00:00
|
|
|
return (int)SK_a + (tolower(*str) - (int)'a');
|
2010-12-30 04:30:47 +00:00
|
|
|
else // Check if we have a special mapping for it.
|
2011-09-13 12:40:33 +00:00
|
|
|
return find_sk_bind(str);
|
2010-12-30 04:30:47 +00:00
|
|
|
}
|
|
|
|
|
2011-02-26 17:47:32 +00:00
|
|
|
// Yes, this function needs a good refactor :)
|
2010-12-30 04:30:47 +00:00
|
|
|
static void read_keybinds(config_file_t *conf)
|
|
|
|
{
|
|
|
|
char *tmp_key = NULL;
|
2011-01-08 21:15:02 +00:00
|
|
|
char *tmp_btn = NULL;
|
2010-12-30 04:30:47 +00:00
|
|
|
char *tmp_axis = NULL;
|
2010-12-30 03:51:08 +00:00
|
|
|
|
2011-01-10 15:53:37 +00:00
|
|
|
for (int j = 0; j < MAX_PLAYERS; j++)
|
2010-12-30 03:51:08 +00:00
|
|
|
{
|
2011-01-10 15:53:37 +00:00
|
|
|
for (int i = 0; i < sizeof(bind_maps[0])/sizeof(struct bind_map); i++)
|
2010-12-30 03:51:08 +00:00
|
|
|
{
|
2010-12-30 04:30:47 +00:00
|
|
|
struct snes_keybind *bind = find_snes_bind(j, bind_maps[j][i].snes_key);
|
|
|
|
if (!bind)
|
|
|
|
continue;
|
|
|
|
|
2011-02-26 17:49:41 +00:00
|
|
|
// Check keybind
|
2010-12-30 04:30:47 +00:00
|
|
|
if (bind_maps[j][i].key && config_get_string(conf, bind_maps[j][i].key, &tmp_key))
|
2010-12-30 03:51:08 +00:00
|
|
|
{
|
2011-09-13 12:40:33 +00:00
|
|
|
int key = find_sk_key(tmp_key);
|
2010-12-30 03:51:08 +00:00
|
|
|
|
2010-12-30 04:30:47 +00:00
|
|
|
if (key >= 0)
|
|
|
|
bind->key = key;
|
2010-12-30 03:51:08 +00:00
|
|
|
|
2010-12-30 04:30:47 +00:00
|
|
|
free(tmp_key);
|
|
|
|
tmp_key = NULL;
|
|
|
|
}
|
2010-12-30 03:51:08 +00:00
|
|
|
|
2011-02-26 17:49:41 +00:00
|
|
|
// Check joybutton bind (hats too)
|
2011-01-08 21:15:02 +00:00
|
|
|
if (bind_maps[j][i].btn && config_get_string(conf, bind_maps[j][i].btn, &tmp_btn))
|
2010-12-30 04:30:47 +00:00
|
|
|
{
|
2011-01-08 21:15:02 +00:00
|
|
|
const char *btn = tmp_btn;
|
2011-02-26 17:47:32 +00:00
|
|
|
if (strcmp(tmp_btn, "nul") == 0)
|
2011-01-08 21:15:02 +00:00
|
|
|
{
|
2011-02-26 17:47:32 +00:00
|
|
|
bind->joykey = NO_BTN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (*btn++ == 'h')
|
2011-01-08 21:15:02 +00:00
|
|
|
{
|
2011-02-26 17:47:32 +00:00
|
|
|
if (isdigit(*btn))
|
2011-01-08 21:15:02 +00:00
|
|
|
{
|
2011-02-26 17:47:32 +00:00
|
|
|
char *dir = NULL;
|
|
|
|
int hat = strtol(btn, &dir, 0);
|
|
|
|
int hat_dir = 0;
|
|
|
|
if (dir)
|
|
|
|
{
|
|
|
|
if (strcasecmp(dir, "up") == 0)
|
|
|
|
hat_dir = HAT_UP_MASK;
|
|
|
|
else if (strcasecmp(dir, "down") == 0)
|
|
|
|
hat_dir = HAT_DOWN_MASK;
|
|
|
|
else if (strcasecmp(dir, "left") == 0)
|
|
|
|
hat_dir = HAT_LEFT_MASK;
|
|
|
|
else if (strcasecmp(dir, "right") == 0)
|
|
|
|
hat_dir = HAT_RIGHT_MASK;
|
|
|
|
|
|
|
|
if (hat_dir)
|
|
|
|
bind->joykey = HAT_MAP(hat, hat_dir);
|
|
|
|
}
|
2011-01-08 21:15:02 +00:00
|
|
|
}
|
|
|
|
}
|
2011-02-26 17:47:32 +00:00
|
|
|
else
|
|
|
|
bind->joykey = strtol(tmp_btn, NULL, 0);
|
2011-01-08 21:15:02 +00:00
|
|
|
}
|
|
|
|
free(tmp_btn);
|
2010-12-30 04:30:47 +00:00
|
|
|
}
|
|
|
|
|
2011-02-26 17:49:41 +00:00
|
|
|
// Check joyaxis binds.
|
2010-12-30 04:30:47 +00:00
|
|
|
if (bind_maps[j][i].axis && config_get_string(conf, bind_maps[j][i].axis, &tmp_axis))
|
|
|
|
{
|
2011-02-26 17:47:32 +00:00
|
|
|
if (strcmp(tmp_axis, "nul") == 0)
|
|
|
|
{
|
|
|
|
bind->joyaxis = AXIS_NONE;
|
|
|
|
}
|
|
|
|
else if (strlen(tmp_axis) >= 2 && (*tmp_axis == '+' || *tmp_axis == '-'))
|
2010-12-30 04:30:47 +00:00
|
|
|
{
|
|
|
|
int axis = strtol(tmp_axis + 1, NULL, 0);
|
|
|
|
if (*tmp_axis == '+')
|
|
|
|
bind->joyaxis = AXIS_POS(axis);
|
|
|
|
else
|
|
|
|
bind->joyaxis = AXIS_NEG(axis);
|
|
|
|
|
|
|
|
}
|
|
|
|
free(tmp_axis);
|
|
|
|
tmp_axis = NULL;
|
2010-12-30 03:51:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-19 12:07:11 +00:00
|
|
|
#endif
|