Add input remapping saving/loading

This commit is contained in:
twinaphex 2015-01-24 23:42:31 +01:00
parent 9e9c109bd4
commit 5419757c40
7 changed files with 43 additions and 8 deletions

View File

@ -304,6 +304,8 @@ struct settings
bool autoconfig_descriptor_label_show;
bool input_descriptor_label_show;
bool input_descriptor_hide_unbound;
char remapping_path[PATH_MAX_LENGTH];
} input;
struct

View File

@ -36,6 +36,9 @@ bool input_remapping_load_file(const char *path)
if (!conf)
return false;
strlcpy(g_settings.input.remapping_path, path,
sizeof(g_settings.input.remapping_path));
for (i = 0; i < MAX_USERS; i++)
{
char buf[64];

View File

@ -36,7 +36,10 @@
#include "cheats.h"
#include <compat/getopt.h>
#include <compat/posix_string.h>
#include "input/keyboard_line.h"
#include "input/input_remapping.h"
#include "git_version.h"
#include "intl/intl.h"
@ -1182,6 +1185,14 @@ static void save_files(void)
}
}
static void init_remapping(void)
{
if (!g_settings.input.remap_binds_enable)
return;
input_remapping_load_file(g_settings.input.remapping_path);
}
static void init_cheats(void)
{
bool allow_cheats = true;
@ -2179,6 +2190,7 @@ int rarch_main_init(int argc, char *argv[])
rarch_main_command(RARCH_CMD_CONTROLLERS_INIT);
rarch_main_command(RARCH_CMD_RECORD_INIT);
rarch_main_command(RARCH_CMD_CHEATS_INIT);
rarch_main_command(RARCH_CMD_REMAPPING_INIT);
rarch_main_command(RARCH_CMD_SAVEFILES_INIT);
@ -2560,6 +2572,12 @@ bool rarch_main_command(unsigned cmd)
rarch_main_command(RARCH_CMD_CHEATS_DEINIT);
init_cheats();
break;
case RARCH_CMD_REMAPPING_DEINIT:
break;
case RARCH_CMD_REMAPPING_INIT:
rarch_main_command(RARCH_CMD_REMAPPING_DEINIT);
init_remapping();
break;
case RARCH_CMD_REWIND_DEINIT:
#ifdef HAVE_NETPLAY
if (driver.netplay_data)

View File

@ -317,6 +317,9 @@
# Joypad driver. (Valid: linuxraw, sdl, dinput)
# input_joypad_driver =
# Path to input remapping file.
# input_remapping_path =
# Maximum amount of users supported by RetroArch.
# input_max_users = 16

View File

@ -186,6 +186,8 @@ enum basic_event
/* Toggles fullscreen mode. */
RARCH_CMD_FULLSCREEN_TOGGLE,
RARCH_CMD_PERFCNT_REPORT_FRONTEND_LOG,
RARCH_CMD_REMAPPING_INIT,
RARCH_CMD_REMAPPING_DEINIT,
};
enum action_state

View File

@ -1322,6 +1322,8 @@ static bool config_load_file(const char *path, bool set_defaults)
}
}
CONFIG_GET_PATH(input.remapping_path, "input_remapping_path");
CONFIG_GET_PATH(resampler_directory, "resampler_directory");
CONFIG_GET_PATH(extraction_directory, "extraction_directory");
CONFIG_GET_PATH(input_remapping_directory, "input_remapping_directory");
@ -1556,25 +1558,25 @@ static void config_load_core_specific(void)
static void parse_config_file(void)
{
bool ret;
bool ret = config_load_file((*g_extern.config_path)
? g_extern.config_path : NULL, false);
if (*g_extern.config_path)
{
RARCH_LOG("Loading config from: %s.\n", g_extern.config_path);
ret = config_load_file(g_extern.config_path, false);
}
else
{
RARCH_LOG("Loading default config.\n");
ret = config_load_file(NULL, false);
if (*g_extern.config_path)
RARCH_LOG("Found default config: %s.\n", g_extern.config_path);
}
if (!ret)
{
RARCH_ERR("Couldn't find config at path: \"%s\"\n",
g_extern.config_path);
}
if (ret)
return;
RARCH_ERR("Couldn't find config at path: \"%s\"\n",
g_extern.config_path);
}
@ -1921,6 +1923,8 @@ bool config_save_file(const char *path)
g_settings.extraction_directory);
config_set_path(conf, "input_remapping_directory",
g_settings.input_remapping_directory);
config_set_path(conf, "input_remapping_path",
g_settings.input.remapping_path);
config_set_path(conf, "resampler_directory",
g_settings.resampler_directory);
config_set_string(conf, "audio_resampler", g_settings.audio.resampler);

View File

@ -2905,6 +2905,9 @@ void setting_data_get_label(char *type_str,
#endif
if (!strcmp(label, "cheat_num_passes"))
snprintf(type_str, type_str_size, "%u", g_extern.cheat->buf_size);
else if (!strcmp(label, "remap_file_load"))
fill_pathname_base(type_str, g_settings.input.remapping_path,
type_str_size);
else if (type >= MENU_SETTINGS_CHEAT_BEGIN
&& type <= MENU_SETTINGS_CHEAT_END)
{