Revert "(Config file) Don't save 'nul' entries in config file anymore -"

This reverts commit 4c6d46137c05e583de5d8978e95991f36344d86b.
This commit is contained in:
twinaphex 2020-02-04 01:02:40 +01:00
parent 4c6d46137c
commit 51bc64559b
5 changed files with 28 additions and 25 deletions

View File

@ -3725,7 +3725,7 @@ bool config_save_autoconf_profile(const char *path, unsigned user)
if (bind->valid) if (bind->valid)
input_config_save_keybind( input_config_save_keybind(
conf, "input", input_config_bind_map_get_base(i), conf, "input", input_config_bind_map_get_base(i),
bind); bind, false);
} }
ret = config_file_write(conf, autoconf_file, false); ret = config_file_write(conf, autoconf_file, false);

View File

@ -53,10 +53,6 @@
var = newvar; \ var = newvar; \
} }
#ifndef EXPLICIT_NULL
#define EXPLICIT_NULL "nul"
#endif
enum crt_switch_type enum crt_switch_type
{ {
CRT_SWITCH_NONE = 0, CRT_SWITCH_NONE = 0,

View File

@ -453,7 +453,7 @@ void fill_short_pathname_representation_wrapper(char* out_rep,
last_slash = find_last_slash(path_short); last_slash = find_last_slash(path_short);
if (last_slash) if (last_slash != NULL)
{ {
/* We handle paths like: /* We handle paths like:
* /path/to/file.7z#mygame.img * /path/to/file.7z#mygame.img

View File

@ -545,7 +545,8 @@ uint16_t input_config_get_vid(unsigned port);
void input_config_save_keybinds_user(void *data, unsigned user); void input_config_save_keybinds_user(void *data, unsigned user);
void input_config_save_keybind(void *data, const char *prefix, void input_config_save_keybind(void *data, const char *prefix,
const char *base, const struct retro_keybind *bind); const char *base, const struct retro_keybind *bind,
bool save_empty);
void input_config_reset(void); void input_config_reset(void);

View File

@ -17731,12 +17731,9 @@ void input_config_save_keybinds_user(void *data, unsigned user)
fill_pathname_join_delim(key, prefix, base, '_', sizeof(key)); fill_pathname_join_delim(key, prefix, base, '_', sizeof(key));
input_keymaps_translate_rk_to_str(bind->key, btn, sizeof(btn)); input_keymaps_translate_rk_to_str(bind->key, btn, sizeof(btn));
config_set_string(conf, key, btn);
if (!string_is_equal(btn, EXPLICIT_NULL)) input_config_save_keybind(conf, prefix, base, bind, true);
{
config_set_string(conf, key, btn);
input_config_save_keybind(conf, prefix, base, bind);
}
} }
} }
@ -17778,7 +17775,7 @@ static void save_keybind_hat(config_file_t *conf, const char *key,
static void save_keybind_joykey(config_file_t *conf, static void save_keybind_joykey(config_file_t *conf,
const char *prefix, const char *prefix,
const char *base, const char *base,
const struct retro_keybind *bind) const struct retro_keybind *bind, bool save_empty)
{ {
char key[64]; char key[64];
@ -17787,7 +17784,12 @@ static void save_keybind_joykey(config_file_t *conf,
fill_pathname_join_delim_concat(key, prefix, fill_pathname_join_delim_concat(key, prefix,
base, '_', "_btn", sizeof(key)); base, '_', "_btn", sizeof(key));
if (GET_HAT_DIR(bind->joykey)) if (bind->joykey == NO_BTN)
{
if (save_empty)
config_set_string(conf, key, "nul");
}
else if (GET_HAT_DIR(bind->joykey))
save_keybind_hat(conf, key, bind); save_keybind_hat(conf, key, bind);
else else
config_set_uint64(conf, key, bind->joykey); config_set_uint64(conf, key, bind->joykey);
@ -17796,7 +17798,7 @@ static void save_keybind_joykey(config_file_t *conf,
static void save_keybind_axis(config_file_t *conf, static void save_keybind_axis(config_file_t *conf,
const char *prefix, const char *prefix,
const char *base, const char *base,
const struct retro_keybind *bind) const struct retro_keybind *bind, bool save_empty)
{ {
char key[64]; char key[64];
unsigned axis = 0; unsigned axis = 0;
@ -17809,7 +17811,12 @@ static void save_keybind_axis(config_file_t *conf,
"_axis", "_axis",
sizeof(key)); sizeof(key));
if (AXIS_NEG_GET(bind->joyaxis) != AXIS_DIR_NONE) if (bind->joyaxis == AXIS_NONE)
{
if (save_empty)
config_set_string(conf, key, "nul");
}
else if (AXIS_NEG_GET(bind->joyaxis) != AXIS_DIR_NONE)
{ {
dir = '-'; dir = '-';
axis = AXIS_NEG_GET(bind->joyaxis); axis = AXIS_NEG_GET(bind->joyaxis);
@ -17834,7 +17841,7 @@ static void save_keybind_axis(config_file_t *conf,
static void save_keybind_mbutton(config_file_t *conf, static void save_keybind_mbutton(config_file_t *conf,
const char *prefix, const char *prefix,
const char *base, const char *base,
const struct retro_keybind *bind) const struct retro_keybind *bind, bool save_empty)
{ {
char key[64]; char key[64];
@ -17873,6 +17880,8 @@ static void save_keybind_mbutton(config_file_t *conf,
config_set_string(conf, key, "whd"); config_set_string(conf, key, "whd");
break; break;
default: default:
if (save_empty)
config_set_string(conf, key, "nul");
break; break;
} }
} }
@ -17888,17 +17897,14 @@ static void save_keybind_mbutton(config_file_t *conf,
* Save a key binding to the config file. * Save a key binding to the config file.
*/ */
void input_config_save_keybind(void *data, const char *prefix, void input_config_save_keybind(void *data, const char *prefix,
const char *base, const struct retro_keybind *bind) const char *base, const struct retro_keybind *bind,
bool save_empty)
{ {
config_file_t *conf = (config_file_t*)data; config_file_t *conf = (config_file_t*)data;
save_keybind_joykey (conf, prefix, base, bind, save_empty);
if (bind->joykey != NO_BTN) save_keybind_axis (conf, prefix, base, bind, save_empty);
save_keybind_joykey(conf, prefix, base, bind); save_keybind_mbutton(conf, prefix, base, bind, save_empty);
if (bind->joyaxis != AXIS_NONE)
save_keybind_axis(conf, prefix, base, bind);
if (bind->mbutton != NO_BTN)
save_keybind_mbutton(conf, prefix, base, bind);
} }
/* MIDI */ /* MIDI */