mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
(settings data) Bring back setting_data_save_config
This commit is contained in:
parent
70447d00a2
commit
a44bb7d08a
@ -38,6 +38,13 @@ static const char* get_input_config_prefix(const rarch_setting_t* setting)
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static const char* get_input_config_key(const rarch_setting_t* setting, const char* type)
|
||||
{
|
||||
static char buffer[64];
|
||||
snprintf(buffer, 64, "%s_%s%c%s", get_input_config_prefix(setting), setting->name, type ? '_' : '\0', type);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
//FIXME - make portable
|
||||
#ifdef APPLE
|
||||
static const char* get_key_name(const rarch_setting_t* setting)
|
||||
@ -57,6 +64,32 @@ static const char* get_key_name(const rarch_setting_t* setting)
|
||||
}
|
||||
#endif
|
||||
|
||||
static const char* get_button_name(const rarch_setting_t* setting)
|
||||
{
|
||||
static char buffer[32];
|
||||
|
||||
if (BINDFOR(*setting).joykey == NO_BTN)
|
||||
return "nul";
|
||||
|
||||
snprintf(buffer, 32, "%lld", (long long int)(BINDFOR(*setting).joykey));
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static const char* get_axis_name(const rarch_setting_t* setting)
|
||||
{
|
||||
static char buffer[32];
|
||||
uint32_t joyaxis = BINDFOR(*setting).joyaxis;
|
||||
|
||||
if (AXIS_NEG_GET(joyaxis) != AXIS_DIR_NONE)
|
||||
snprintf(buffer, 8, "-%d", AXIS_NEG_GET(joyaxis));
|
||||
else if (AXIS_POS_GET(joyaxis) != AXIS_DIR_NONE)
|
||||
snprintf(buffer, 8, "+%d", AXIS_POS_GET(joyaxis));
|
||||
else
|
||||
return "nul";
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void setting_data_reset_setting(const rarch_setting_t* setting)
|
||||
{
|
||||
switch (setting->type)
|
||||
@ -167,6 +200,55 @@ bool setting_data_load_config_path(const rarch_setting_t* settings, const char*
|
||||
return config;
|
||||
}
|
||||
|
||||
bool setting_data_save_config(const rarch_setting_t* settings, config_file_t* config)
|
||||
{
|
||||
const rarch_setting_t *setting;
|
||||
|
||||
if (!config)
|
||||
return false;
|
||||
|
||||
for (setting = settings; setting->type != ST_NONE; setting++)
|
||||
{
|
||||
switch (setting->type)
|
||||
{
|
||||
case ST_BOOL:
|
||||
config_set_bool(config, setting->name, *setting->value.boolean);
|
||||
break;
|
||||
case ST_PATH:
|
||||
config_set_path(config, setting->name, setting->value.string);
|
||||
break;
|
||||
case ST_STRING:
|
||||
config_set_string(config, setting->name, setting->value.string);
|
||||
break;
|
||||
case ST_INT:
|
||||
ENFORCE_RANGE(setting, integer);
|
||||
config_set_int(config, setting->name, *setting->value.integer);
|
||||
break;
|
||||
case ST_UINT:
|
||||
ENFORCE_RANGE(setting, unsigned_integer);
|
||||
config_set_uint64(config, setting->name, *setting->value.unsigned_integer);
|
||||
break;
|
||||
case ST_FLOAT:
|
||||
ENFORCE_RANGE(setting, fraction);
|
||||
config_set_float(config, setting->name, *setting->value.fraction);
|
||||
break;
|
||||
case ST_BIND:
|
||||
//FIXME: make portable
|
||||
#ifdef APPLE
|
||||
config_set_string(config, get_input_config_key(setting, 0 ), get_key_name(setting));
|
||||
#endif
|
||||
config_set_string(config, get_input_config_key(setting, "btn" ), get_button_name(setting));
|
||||
config_set_string(config, get_input_config_key(setting, "axis"), get_axis_name(setting));
|
||||
break;
|
||||
case ST_HEX:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
rarch_setting_t* setting_data_find_setting(rarch_setting_t* settings, const char* name)
|
||||
{
|
||||
|
@ -99,6 +99,7 @@ void setting_data_reset_setting(const rarch_setting_t* setting);
|
||||
void setting_data_reset(const rarch_setting_t* settings);
|
||||
|
||||
bool setting_data_load_config_path(const rarch_setting_t* settings, const char* path);
|
||||
bool setting_data_save_config(const rarch_setting_t* settings, config_file_t* config);
|
||||
|
||||
rarch_setting_t* setting_data_find_setting(rarch_setting_t* settings, const char* name);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user