From 83da70586e376fc10b08fb7586c011438c992213 Mon Sep 17 00:00:00 2001
From: Sven <40953353+RetroSven@users.noreply.github.com>
Date: Fri, 13 Jul 2018 16:12:09 -0400
Subject: [PATCH] implement a way to set rewind_buffer_size via the UI
---
.gitignore | 4 +
.project | 16 ++
command.c | 2 +-
config.def.h | 3 +
configuration.c | 103 +++++++-
configuration.h | 8 +-
intl/msg_hash_lbl.h | 4 +
intl/msg_hash_us.c | 16 ++
intl/msg_hash_us.h | 12 +
libretro-common/file/config_file.c | 17 ++
libretro-common/include/retro_miscellaneous.h | 10 +
menu/cbs/menu_cbs_select.c | 1 +
menu/cbs/menu_cbs_sublabel.c | 8 +
menu/menu_displaylist.c | 22 ++
menu/menu_displaylist.h | 3 +-
menu/menu_setting.c | 48 +++-
menu/widgets/menu_entry.c | 2 +
menu/widgets/menu_entry.h | 3 +-
msg_hash.h | 2 +
setting_list.c | 226 ++++++++++++++++++
setting_list.h | 20 ++
21 files changed, 505 insertions(+), 25 deletions(-)
diff --git a/.gitignore b/.gitignore
index 89426b7bff..bc65d666b0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -68,6 +68,10 @@ menu/driverspzarch.c
.pc
/media/shaders_glsl/
/obj-w32/
+.cproject
+.settings
+libretro-super
+run.sh
# Wii U
*.depend
diff --git a/.project b/.project
index 871dee54b0..b5f91e201f 100644
--- a/.project
+++ b/.project
@@ -5,7 +5,23 @@
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.core.ccnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
diff --git a/command.c b/command.c
index 23fa89a565..7b6b682336 100644
--- a/command.c
+++ b/command.c
@@ -1997,7 +1997,7 @@ TODO: Add a setting for these tweaks */
if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
#endif
{
- state_manager_event_init((unsigned)settings->rewind_buffer_size);
+ state_manager_event_init((unsigned)settings->sizes.rewind_buffer_size);
}
}
}
diff --git a/config.def.h b/config.def.h
index 950bca391d..189449b793 100644
--- a/config.def.h
+++ b/config.def.h
@@ -524,6 +524,9 @@ static const bool rewind_enable = false;
* 15-20MB per minute. Very game dependant. */
static const unsigned rewind_buffer_size = 20 << 20; /* 20MiB */
+/* The amount of MB to increase/decrease the rewind_buffer_size when it is changed via the UI. */
+static const unsigned rewind_buffer_size_step = 10; /* 10MB */
+
/* How many frames to rewind at a time. */
static const unsigned rewind_granularity = 1;
diff --git a/configuration.c b/configuration.c
index 953f4b4524..493fb2e7b9 100644
--- a/configuration.c
+++ b/configuration.c
@@ -92,6 +92,16 @@ struct config_uint_setting
enum rarch_override_setting override;
};
+struct config_size_setting
+{
+ const char *ident;
+ size_t *ptr;
+ bool def_enable;
+ size_t def;
+ bool handle;
+ enum rarch_override_setting override;
+};
+
struct config_float_setting
{
const char *ident;
@@ -550,6 +560,9 @@ static enum menu_driver_enum MENU_DEFAULT_DRIVER = MENU_NULL;
#define SETTING_UINT(key, configval, default_enable, default_setting, handle_setting) \
GENERAL_SETTING(key, configval, default_enable, default_setting, struct config_uint_setting, handle_setting)
+#define SETTING_SIZE(key, configval, default_enable, default_setting, handle_setting) \
+ GENERAL_SETTING(key, configval, default_enable, default_setting, struct config_size_setting, handle_setting)
+
#define SETTING_PATH(key, configval, default_enable, default_setting, handle_setting) \
GENERAL_SETTING(key, configval, default_enable, default_setting, struct config_path_setting, handle_setting)
@@ -1508,6 +1521,7 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings,
SETTING_UINT("audio_resampler_quality", &settings->uints.audio_resampler_quality, true, audio_resampler_quality_level, false);
SETTING_UINT("audio_block_frames", &settings->uints.audio_block_frames, true, 0, false);
SETTING_UINT("rewind_granularity", &settings->uints.rewind_granularity, true, rewind_granularity, false);
+ SETTING_UINT("rewind_buffer_size_step", &settings->uints.rewind_buffer_size_step, true, rewind_buffer_size_step, false);
SETTING_UINT("autosave_interval", &settings->uints.autosave_interval, true, autosave_interval, false);
SETTING_UINT("libretro_log_level", &settings->uints.libretro_log_level, true, libretro_log_level, false);
SETTING_UINT("keyboard_gamepad_mapping_type",&settings->uints.input_keyboard_gamepad_mapping_type, true, 1, false);
@@ -1584,6 +1598,18 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings,
return tmp;
}
+static struct config_size_setting *populate_settings_size(settings_t *settings, int *size)
+{
+ unsigned count = 0;
+ struct config_size_setting *tmp = (struct config_size_setting*)malloc((*size + 1) * sizeof(struct config_size_setting));
+
+ SETTING_SIZE("rewind_buffer_size", &settings->sizes.rewind_buffer_size, true, rewind_buffer_size, false);
+
+ *size = count;
+
+ return tmp;
+}
+
static struct config_int_setting *populate_settings_int(settings_t *settings, int *size)
{
unsigned count = 0;
@@ -1619,6 +1645,7 @@ static void config_set_defaults(void)
int float_settings_size = sizeof(settings->floats) / sizeof(settings->floats.placeholder);
int int_settings_size = sizeof(settings->ints) / sizeof(settings->ints.placeholder);
int uint_settings_size = sizeof(settings->uints) / sizeof(settings->uints.placeholder);
+ int size_settings_size = sizeof(settings->sizes) / sizeof(settings->sizes.placeholder);
const char *def_video = config_get_default_video();
const char *def_audio = config_get_default_audio();
const char *def_audio_resampler = config_get_default_audio_resampler();
@@ -1638,6 +1665,7 @@ static void config_set_defaults(void)
struct config_bool_setting *bool_settings = populate_settings_bool (settings, &bool_settings_size);
struct config_int_setting *int_settings = populate_settings_int (settings, &int_settings_size);
struct config_uint_setting *uint_settings = populate_settings_uint (settings, &uint_settings_size);
+ struct config_size_setting *size_settings = populate_settings_size (settings, &size_settings_size);
if (bool_settings && (bool_settings_size > 0))
{
@@ -1672,6 +1700,17 @@ static void config_set_defaults(void)
free(uint_settings);
}
+ if (size_settings && (size_settings_size > 0))
+ {
+ for (i = 0; i < (unsigned)size_settings_size; i++)
+ {
+ if (size_settings[i].def_enable)
+ *size_settings[i].ptr = size_settings[i].def;
+ }
+
+ free(size_settings);
+ }
+
if (float_settings && (float_settings_size > 0))
{
for (i = 0; i < (unsigned)float_settings_size; i++)
@@ -1763,8 +1802,6 @@ static void config_set_defaults(void)
audio_set_float(AUDIO_ACTION_VOLUME_GAIN, settings->floats.audio_volume);
audio_set_float(AUDIO_ACTION_MIXER_VOLUME_GAIN, settings->floats.audio_mixer_volume);
- settings->rewind_buffer_size = rewind_buffer_size;
-
#ifdef HAVE_LAKKA
settings->bools.ssh_enable = filestream_exists(LAKKA_SSH_PATH);
settings->bools.samba_enable = filestream_exists(LAKKA_SAMBA_PATH);
@@ -2463,12 +2500,14 @@ static bool config_load_file(const char *path, bool set_defaults,
int float_settings_size = sizeof(settings->floats) / sizeof(settings->floats.placeholder);
int int_settings_size = sizeof(settings->ints) / sizeof(settings->ints.placeholder);
int uint_settings_size = sizeof(settings->uints) / sizeof(settings->uints.placeholder);
+ int size_settings_size = sizeof(settings->sizes) / sizeof(settings->sizes.placeholder);
int array_settings_size = sizeof(settings->arrays) / sizeof(settings->arrays.placeholder);
int path_settings_size = sizeof(settings->paths) / sizeof(settings->paths.placeholder);
struct config_bool_setting *bool_settings = populate_settings_bool (settings, &bool_settings_size);
struct config_float_setting *float_settings = populate_settings_float (settings, &float_settings_size);
struct config_int_setting *int_settings = populate_settings_int (settings, &int_settings_size);
struct config_uint_setting *uint_settings = populate_settings_uint (settings, &uint_settings_size);
+ struct config_size_setting *size_settings = populate_settings_size (settings, &size_settings_size);
struct config_array_setting *array_settings = populate_settings_array (settings, &array_settings_size);
struct config_path_setting *path_settings = populate_settings_path (settings, &path_settings_size);
@@ -2593,6 +2632,23 @@ static bool config_load_file(const char *path, bool set_defaults,
*uint_settings[i].ptr = tmp;
}
+ for (i = 0; i < (unsigned)size_settings_size; i++)
+ {
+ size_t tmp = 0;
+ if (config_get_size_t(conf, size_settings[i].ident, &tmp))
+ *size_settings[i].ptr = tmp ;
+ /* Special case for rewind_buffer_size - need to convert low values to what they were
+ * intended to be based on the default value in config.def.h
+ * If the value is less than 10000 then multiple by 1MB because if the retroarch.cfg
+ * file contains rewind_buffer_size = "100" then that ultimately gets interpreted as
+ * 100MB, so ensure the internal values represent that.*/
+ if ( strcmp(size_settings[i].ident, "rewind_buffer_size") == 0 ) {
+ if ( *size_settings[i].ptr < 10000) {
+ *size_settings[i].ptr = *size_settings[i].ptr * 1024 * 1024 ;
+ }
+ }
+ }
+
for (i = 0; i < MAX_USERS; i++)
{
char buf[64];
@@ -2624,13 +2680,6 @@ static bool config_load_file(const char *path, bool set_defaults,
CONFIG_GET_INT_BASE(conf, settings, uints.led_map[i], buf);
}
- {
- /* ugly hack around C89 not allowing mixing declarations and code */
- int buffer_size = 0;
- if (config_get_int(conf, "rewind_buffer_size", &buffer_size))
- settings->rewind_buffer_size = buffer_size * UINT64_C(1000000);
- }
-
/* Hexadecimal settings */
@@ -3954,6 +4003,7 @@ bool config_save_file(const char *path)
struct config_bool_setting *bool_settings = NULL;
struct config_int_setting *int_settings = NULL;
struct config_uint_setting *uint_settings = NULL;
+ struct config_size_setting *size_settings = NULL;
struct config_float_setting *float_settings = NULL;
struct config_array_setting *array_settings = NULL;
struct config_path_setting *path_settings = NULL;
@@ -3963,6 +4013,7 @@ bool config_save_file(const char *path)
int float_settings_size = sizeof(settings->floats)/ sizeof(settings->floats.placeholder);
int int_settings_size = sizeof(settings->ints) / sizeof(settings->ints.placeholder);
int uint_settings_size = sizeof(settings->uints) / sizeof(settings->uints.placeholder);
+ int size_settings_size = sizeof(settings->sizes) / sizeof(settings->sizes.placeholder);
int array_settings_size = sizeof(settings->arrays)/ sizeof(settings->arrays.placeholder);
int path_settings_size = sizeof(settings->paths) / sizeof(settings->paths.placeholder);
@@ -3979,6 +4030,7 @@ bool config_save_file(const char *path)
bool_settings = populate_settings_bool (settings, &bool_settings_size);
int_settings = populate_settings_int (settings, &int_settings_size);
uint_settings = populate_settings_uint (settings, &uint_settings_size);
+ size_settings = populate_settings_size (settings, &size_settings_size);
float_settings = populate_settings_float (settings, &float_settings_size);
array_settings = populate_settings_array (settings, &array_settings_size);
path_settings = populate_settings_path (settings, &path_settings_size);
@@ -4056,6 +4108,18 @@ bool config_save_file(const char *path)
free(uint_settings);
}
+ if (size_settings && (size_settings_size > 0))
+ {
+ for (i = 0; i < (unsigned)size_settings_size; i++)
+ if (!size_settings[i].override ||
+ !retroarch_override_setting_is_set(size_settings[i].override, NULL))
+ config_set_int(conf,
+ size_settings[i].ident,
+ *size_settings[i].ptr);
+
+ free(size_settings);
+ }
+
for (i = 0; i < MAX_USERS; i++)
{
char cfg[64];
@@ -4175,8 +4239,10 @@ bool config_save_overrides(int override_type)
struct config_bool_setting *bool_overrides = NULL;
struct config_int_setting *int_settings = NULL;
struct config_uint_setting *uint_settings = NULL;
+ struct config_size_setting *size_settings = NULL;
struct config_int_setting *int_overrides = NULL;
struct config_uint_setting *uint_overrides = NULL;
+ struct config_size_setting *size_overrides = NULL;
struct config_float_setting *float_settings = NULL;
struct config_float_setting *float_overrides= NULL;
struct config_array_setting *array_settings = NULL;
@@ -4193,6 +4259,7 @@ bool config_save_overrides(int override_type)
int float_settings_size = sizeof(settings->floats) / sizeof(settings->floats.placeholder);
int int_settings_size = sizeof(settings->ints) / sizeof(settings->ints.placeholder);
int uint_settings_size = sizeof(settings->uints) / sizeof(settings->uints.placeholder);
+ int size_settings_size = sizeof(settings->sizes) / sizeof(settings->sizes.placeholder);
int array_settings_size = sizeof(settings->arrays) / sizeof(settings->arrays.placeholder);
int path_settings_size = sizeof(settings->paths) / sizeof(settings->paths.placeholder);
rarch_system_info_t *system = runloop_get_system_info();
@@ -4261,6 +4328,10 @@ bool config_save_overrides(int override_type)
tmp_i = sizeof(settings->uints) / sizeof(settings->uints.placeholder);
uint_overrides = populate_settings_uint (overrides, &tmp_i);
+ size_settings = populate_settings_size(settings, &size_settings_size);
+ tmp_i = sizeof(settings->sizes) / sizeof(settings->sizes.placeholder);
+ size_overrides = populate_settings_size (overrides, &tmp_i);
+
float_settings = populate_settings_float(settings, &float_settings_size);
tmp_i = sizeof(settings->floats) / sizeof(settings->floats.placeholder);
float_overrides = populate_settings_float(overrides, &tmp_i);
@@ -4313,6 +4384,18 @@ bool config_save_overrides(int override_type)
(*uint_overrides[i].ptr));
}
}
+ for (i = 0; i < (unsigned)size_settings_size; i++)
+ {
+ if ((*size_settings[i].ptr) != (*size_overrides[i].ptr))
+ {
+ RARCH_LOG(" original: %s=%d\n",
+ size_settings[i].ident, (*size_settings[i].ptr));
+ RARCH_LOG(" override: %s=%d\n",
+ size_overrides[i].ident, (*size_overrides[i].ptr));
+ config_set_int(conf, size_overrides[i].ident,
+ (*size_overrides[i].ptr));
+ }
+ }
for (i = 0; i < (unsigned)float_settings_size; i++)
{
if ((*float_settings[i].ptr) != (*float_overrides[i].ptr))
@@ -4429,6 +4512,8 @@ bool config_save_overrides(int override_type)
free(int_settings);
if (uint_settings)
free(uint_settings);
+ if (size_settings)
+ free(size_settings);
if (int_overrides)
free(int_overrides);
if (uint_overrides)
diff --git a/configuration.h b/configuration.h
index db968639f5..8955319959 100644
--- a/configuration.h
+++ b/configuration.h
@@ -348,6 +348,7 @@ typedef struct settings
unsigned content_history_size;
unsigned libretro_log_level;
unsigned rewind_granularity;
+ unsigned rewind_buffer_size_step;
unsigned autosave_interval;
unsigned network_cmd_port;
unsigned network_remote_base_port;
@@ -411,6 +412,12 @@ typedef struct settings
unsigned midi_volume;
} uints;
+ struct
+ {
+ size_t placeholder;
+ size_t rewind_buffer_size;
+ } sizes;
+
struct
{
char placeholder;
@@ -509,7 +516,6 @@ typedef struct settings
video_viewport_t video_viewport_custom;
- size_t rewind_buffer_size;
} settings_t;
/**
diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h
index 809ef5fa50..779c44441d 100644
--- a/intl/msg_hash_lbl.h
+++ b/intl/msg_hash_lbl.h
@@ -933,6 +933,10 @@ MSG_HASH(MENU_ENUM_LABEL_REWIND_ENABLE,
"rewind_enable")
MSG_HASH(MENU_ENUM_LABEL_REWIND_GRANULARITY,
"rewind_granularity")
+MSG_HASH(MENU_ENUM_LABEL_REWIND_BUFFER_SIZE,
+ "rewind_buffer_size")
+MSG_HASH(MENU_ENUM_LABEL_REWIND_BUFFER_SIZE_STEP,
+ "rewind_buffer_size_step")
MSG_HASH(MENU_ENUM_LABEL_REWIND_SETTINGS,
"rewind_settings")
MSG_HASH(MENU_ENUM_LABEL_RGUI_BROWSER_DIRECTORY,
diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c
index 65df2e805f..a828781ee8 100644
--- a/intl/msg_hash_us.c
+++ b/intl/msg_hash_us.c
@@ -1386,6 +1386,22 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len)
"at a time, increasing the rewinding \n"
"speed.");
break;
+ case MENU_ENUM_LABEL_REWIND_BUFFER_SIZE:
+ snprintf(s, len,
+ "Rewind buffer size (MB).\n"
+ " \n"
+ " The amount of memory in MB to reserve \n"
+ "for rewinding. Increasing this value \n"
+ "increases the rewind history length.\n");
+ break;
+ case MENU_ENUM_LABEL_REWIND_BUFFER_SIZE_STEP:
+ snprintf(s, len,
+ "Rewind buffer size step (MB).\n"
+ " \n"
+ " Each time you increase or decrease \n"
+ "the rewind buffer size value via this \n"
+ "UI it will change by this amount.\n");
+ break;
case MENU_ENUM_LABEL_SCREENSHOT:
snprintf(s, len,
"Take screenshot.");
diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h
index 6c7015a4e2..506655743d 100644
--- a/intl/msg_hash_us.h
+++ b/intl/msg_hash_us.h
@@ -1381,6 +1381,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_REWIND_ENABLE,
"Rewind Enable")
MSG_HASH(MENU_ENUM_LABEL_VALUE_REWIND_GRANULARITY,
"Rewind Granularity")
+MSG_HASH(MENU_ENUM_LABEL_VALUE_REWIND_BUFFER_SIZE,
+ "Rewind Buffer Size (MB)")
+MSG_HASH(MENU_ENUM_LABEL_VALUE_REWIND_BUFFER_SIZE_STEP,
+ "Rewind Buffer Size Step (MB)")
MSG_HASH(MENU_ENUM_LABEL_VALUE_REWIND_SETTINGS,
"Rewind")
MSG_HASH(MENU_ENUM_LABEL_VALUE_RGUI_BROWSER_DIRECTORY,
@@ -2802,6 +2806,14 @@ MSG_HASH(
MENU_ENUM_SUBLABEL_REWIND_GRANULARITY,
"When rewinding a defined number of frames, you can rewind several frames at a time, increasing the rewind speed."
)
+MSG_HASH(
+ MENU_ENUM_SUBLABEL_REWIND_BUFFER_SIZE,
+ "The amount of memory (in MB) to reserve for the rewind buffer. Increasing this will increase the amount of rewind history."
+ )
+MSG_HASH(
+ MENU_ENUM_SUBLABEL_REWIND_BUFFER_SIZE_STEP,
+ "Each time you increase or decrease the rewind buffer size value via this UI it will change by this amount"
+ )
MSG_HASH(
MENU_ENUM_SUBLABEL_LIBRETRO_LOG_LEVEL,
"Sets log level for cores. If a log level issued by a core is below this value, it is ignored."
diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c
index a8f8cfa808..fe2a3928c4 100644
--- a/libretro-common/file/config_file.c
+++ b/libretro-common/file/config_file.c
@@ -592,6 +592,23 @@ bool config_get_int(config_file_t *conf, const char *key, int *in)
return false;
}
+bool config_get_size_t(config_file_t *conf, const char *key, size_t *in)
+{
+ const struct config_entry_list *entry = config_get_entry(conf, key, NULL);
+ errno = 0;
+
+ if (entry)
+ {
+ size_t val = 0 ;
+ if (1 == sscanf(entry->value, "%" PRI_SIZET, &val)) {
+ *in = val;
+ return true;
+ }
+ }
+
+ return false;
+}
+
#if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L
bool config_get_uint64(config_file_t *conf, const char *key, uint64_t *in)
{
diff --git a/libretro-common/include/retro_miscellaneous.h b/libretro-common/include/retro_miscellaneous.h
index afcb885cf7..2988e5efe6 100644
--- a/libretro-common/include/retro_miscellaneous.h
+++ b/libretro-common/include/retro_miscellaneous.h
@@ -155,4 +155,14 @@ typedef struct
uint32_t data[8];
} retro_bits_t;
+#ifdef _WIN32
+# ifdef _WIN64
+# define PRI_SIZET PRIu64
+# else
+# define PRI_SIZET PRIu32
+# endif
+#else
+# define PRI_SIZET "zu"
+#endif
+
#endif
diff --git a/menu/cbs/menu_cbs_select.c b/menu/cbs/menu_cbs_select.c
index 7a6bc5e047..81eede715f 100644
--- a/menu/cbs/menu_cbs_select.c
+++ b/menu/cbs/menu_cbs_select.c
@@ -65,6 +65,7 @@ static int action_select_default(const char *path, const char *label, unsigned t
case ST_BOOL:
case ST_INT:
case ST_UINT:
+ case ST_SIZE:
case ST_FLOAT:
action = MENU_ACTION_RIGHT;
break;
diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c
index 82f8c81689..8f0102625b 100644
--- a/menu/cbs/menu_cbs_sublabel.c
+++ b/menu/cbs/menu_cbs_sublabel.c
@@ -206,6 +206,8 @@ default_sublabel_macro(action_bind_sublabel_run_ahead_hide_warnings, MENU_
default_sublabel_macro(action_bind_sublabel_run_ahead_frames, MENU_ENUM_SUBLABEL_RUN_AHEAD_FRAMES)
default_sublabel_macro(action_bind_sublabel_rewind, MENU_ENUM_SUBLABEL_REWIND_ENABLE)
default_sublabel_macro(action_bind_sublabel_rewind_granularity, MENU_ENUM_SUBLABEL_REWIND_GRANULARITY)
+default_sublabel_macro(action_bind_sublabel_rewind_buffer_size, MENU_ENUM_SUBLABEL_REWIND_BUFFER_SIZE)
+default_sublabel_macro(action_bind_sublabel_rewind_buffer_size_step, MENU_ENUM_SUBLABEL_REWIND_BUFFER_SIZE_STEP)
default_sublabel_macro(action_bind_sublabel_libretro_log_level, MENU_ENUM_SUBLABEL_LIBRETRO_LOG_LEVEL)
default_sublabel_macro(action_bind_sublabel_perfcnt_enable, MENU_ENUM_SUBLABEL_PERFCNT_ENABLE)
default_sublabel_macro(action_bind_sublabel_savestate_auto_save, MENU_ENUM_SUBLABEL_SAVESTATE_AUTO_SAVE)
@@ -1330,6 +1332,12 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_REWIND_GRANULARITY:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_rewind_granularity);
break;
+ case MENU_ENUM_LABEL_REWIND_BUFFER_SIZE:
+ BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_rewind_buffer_size);
+ break;
+ case MENU_ENUM_LABEL_REWIND_BUFFER_SIZE_STEP:
+ BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_rewind_buffer_size_step);
+ break;
case MENU_ENUM_LABEL_SLOWMOTION_RATIO:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_slowmotion_ratio);
break;
diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c
index 87100cde54..e942861a46 100644
--- a/menu/menu_displaylist.c
+++ b/menu/menu_displaylist.c
@@ -2091,6 +2091,9 @@ static int menu_displaylist_parse_settings_internal(void *data,
case PARSE_ONLY_UINT:
precond = ST_UINT;
break;
+ case PARSE_ONLY_SIZE:
+ precond = ST_SIZE;
+ break;
case PARSE_ONLY_BIND:
precond = ST_BIND;
break;
@@ -2162,6 +2165,10 @@ static int menu_displaylist_parse_settings_internal(void *data,
if (type == ST_UINT)
break;
goto loop;
+ case PARSE_ONLY_SIZE:
+ if (type == ST_SIZE)
+ break;
+ goto loop;
case PARSE_ONLY_BIND:
if (type == ST_BIND)
break;
@@ -2226,6 +2233,7 @@ loop:
case PARSE_ONLY_BOOL:
case PARSE_ONLY_INT:
case PARSE_ONLY_UINT:
+ case PARSE_ONLY_SIZE:
case PARSE_ONLY_STRING:
case PARSE_ONLY_PATH:
case PARSE_ONLY_DIR:
@@ -2283,6 +2291,9 @@ static int menu_displaylist_parse_settings_internal_enum(void *data,
case PARSE_ONLY_UINT:
precond = ST_UINT;
break;
+ case PARSE_ONLY_SIZE:
+ precond = ST_SIZE;
+ break;
case PARSE_ONLY_BIND:
precond = ST_BIND;
break;
@@ -2354,6 +2365,10 @@ static int menu_displaylist_parse_settings_internal_enum(void *data,
if (type == ST_UINT)
break;
goto loop;
+ case PARSE_ONLY_SIZE:
+ if (type == ST_SIZE)
+ break;
+ goto loop;
case PARSE_ONLY_BIND:
if (type == ST_BIND)
break;
@@ -2419,6 +2434,7 @@ loop:
case PARSE_ONLY_BOOL:
case PARSE_ONLY_INT:
case PARSE_ONLY_UINT:
+ case PARSE_ONLY_SIZE:
case PARSE_ONLY_PATH:
case PARSE_ONLY_DIR:
case PARSE_ONLY_STRING:
@@ -5106,6 +5122,12 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data)
menu_displaylist_parse_settings_enum(menu, info,
MENU_ENUM_LABEL_REWIND_GRANULARITY,
PARSE_ONLY_UINT, false);
+ menu_displaylist_parse_settings_enum(menu, info,
+ MENU_ENUM_LABEL_REWIND_BUFFER_SIZE,
+ PARSE_ONLY_SIZE, false);
+ menu_displaylist_parse_settings_enum(menu, info,
+ MENU_ENUM_LABEL_REWIND_BUFFER_SIZE_STEP,
+ PARSE_ONLY_UINT, false);
info->need_refresh = true;
info->need_push = true;
diff --git a/menu/menu_displaylist.h b/menu/menu_displaylist.h
index b3c12b9804..4924a465da 100644
--- a/menu/menu_displaylist.h
+++ b/menu/menu_displaylist.h
@@ -45,7 +45,8 @@ enum menu_displaylist_parse_type
PARSE_ONLY_STRING_OPTIONS = (1 << 11),
PARSE_ONLY_HEX = (1 << 12),
PARSE_ONLY_DIR = (1 << 13),
- PARSE_SUB_GROUP = (1 << 14)
+ PARSE_SUB_GROUP = (1 << 14),
+ PARSE_ONLY_SIZE = (1 << 15)
};
enum menu_displaylist_ctl_state
diff --git a/menu/menu_setting.c b/menu/menu_setting.c
index 300d9a508b..e273fbe65d 100644
--- a/menu/menu_setting.c
+++ b/menu/menu_setting.c
@@ -775,6 +775,7 @@ int menu_action_handle_setting(rarch_setting_t *setting,
case ST_BOOL:
case ST_INT:
case ST_UINT:
+ case ST_SIZE:
case ST_HEX:
case ST_FLOAT:
case ST_STRING:
@@ -931,6 +932,8 @@ void *setting_get_ptr(rarch_setting_t *setting)
return setting->value.target.integer;
case ST_UINT:
return setting->value.target.unsigned_integer;
+ case ST_SIZE:
+ return setting->value.target.sizet;
case ST_FLOAT:
return setting->value.target.fraction;
case ST_BIND:
@@ -1636,6 +1639,14 @@ void general_write_handler(void *data)
case MENU_ENUM_LABEL_SUSTAINED_PERFORMANCE_MODE:
frontend_driver_set_sustained_performance_mode(settings->bools.sustained_performance_mode);
break;
+ case MENU_ENUM_LABEL_REWIND_BUFFER_SIZE_STEP:
+ {
+ rarch_setting_t *buffer_size_setting = menu_setting_find("rewind_buffer_size");
+ if ( buffer_size_setting ) {
+ buffer_size_setting->step = (*setting->value.target.unsigned_integer)*1024*1024 ;
+ }
+ }
+ break;
default:
break;
}
@@ -3083,18 +3094,6 @@ static bool setting_append_list(
SD_FLAG_CMD_APPLY_AUTO);
menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_REWIND_TOGGLE);
-#if 0
- CONFIG_SIZE(
- settings->rewind_buffer_size,
- "rewind_buffer_size",
- "Rewind Buffer Size",
- rewind_buffer_size,
- group_info,
- subgroup_info,
- parent_group,
- general_write_handler,
- general_read_handler)
-#endif
CONFIG_UINT(
list, list_info,
&settings->uints.rewind_granularity,
@@ -3107,6 +3106,31 @@ static bool setting_append_list(
general_write_handler,
general_read_handler);
menu_settings_list_current_add_range(list, list_info, 1, 32768, 1, true, true);
+ CONFIG_SIZE(
+ list, list_info,
+ &settings->sizes.rewind_buffer_size,
+ MENU_ENUM_LABEL_REWIND_BUFFER_SIZE,
+ MENU_ENUM_LABEL_VALUE_REWIND_BUFFER_SIZE,
+ rewind_buffer_size,
+ &group_info,
+ &subgroup_info,
+ parent_group,
+ general_write_handler,
+ general_read_handler,
+ &setting_get_string_representation_size_in_mb);
+ menu_settings_list_current_add_range(list, list_info, 1024*1024, 1024*1024*1024, settings->uints.rewind_buffer_size_step*1024*1024, true, true);
+ CONFIG_UINT(
+ list, list_info,
+ &settings->uints.rewind_buffer_size_step,
+ MENU_ENUM_LABEL_REWIND_BUFFER_SIZE_STEP,
+ MENU_ENUM_LABEL_VALUE_REWIND_BUFFER_SIZE_STEP,
+ rewind_buffer_size_step,
+ &group_info,
+ &subgroup_info,
+ parent_group,
+ general_write_handler,
+ general_read_handler);
+ menu_settings_list_current_add_range(list, list_info, 1, 100, 1, true, true);
END_SUB_GROUP(list, list_info, parent_group);
END_GROUP(list, list_info, parent_group);
diff --git a/menu/widgets/menu_entry.c b/menu/widgets/menu_entry.c
index ea5be0c4cc..a5e83ab32f 100644
--- a/menu/widgets/menu_entry.c
+++ b/menu/widgets/menu_entry.c
@@ -54,6 +54,8 @@ enum menu_entry_type menu_entry_get_type(uint32_t i)
return MENU_ENTRY_INT;
case ST_UINT:
return MENU_ENTRY_UINT;
+ case ST_SIZE:
+ return MENU_ENTRY_SIZE;
case ST_FLOAT:
return MENU_ENTRY_FLOAT;
case ST_PATH:
diff --git a/menu/widgets/menu_entry.h b/menu/widgets/menu_entry.h
index b32ec148ee..f3ebb6b37b 100644
--- a/menu/widgets/menu_entry.h
+++ b/menu/widgets/menu_entry.h
@@ -40,7 +40,8 @@ enum menu_entry_type
MENU_ENTRY_STRING,
MENU_ENTRY_HEX,
MENU_ENTRY_BIND,
- MENU_ENTRY_ENUM
+ MENU_ENTRY_ENUM,
+ MENU_ENTRY_SIZE
};
typedef struct menu_entry
diff --git a/msg_hash.h b/msg_hash.h
index 482f5b7500..41dfbb57dc 100644
--- a/msg_hash.h
+++ b/msg_hash.h
@@ -1193,6 +1193,8 @@ enum msg_hash_enums
MENU_LABEL(SCREENSHOT),
MENU_LABEL(REWIND),
MENU_LABEL(REWIND_GRANULARITY),
+ MENU_LABEL(REWIND_BUFFER_SIZE),
+ MENU_LABEL(REWIND_BUFFER_SIZE_STEP),
MENU_LABEL(INPUT_META_REWIND),
MENU_LABEL(SCREEN_RESOLUTION),
diff --git a/setting_list.c b/setting_list.c
index 254bd62e38..3199179060 100644
--- a/setting_list.c
+++ b/setting_list.c
@@ -155,6 +155,24 @@ static void setting_get_string_representation_uint(void *data,
*setting->value.target.unsigned_integer);
}
+static void setting_get_string_representation_size(void *data,
+ char *s, size_t len)
+{
+ rarch_setting_t *setting = (rarch_setting_t*)data;
+ if (setting)
+ snprintf(s, len, "%" PRI_SIZET,
+ *setting->value.target.sizet);
+}
+
+void setting_get_string_representation_size_in_mb(void *data,
+ char *s, size_t len)
+{
+ rarch_setting_t *setting = (rarch_setting_t*)data;
+ if (setting)
+ snprintf(s, len, "%" PRI_SIZET,
+ (*setting->value.target.sizet)/(1024*1024));
+}
+
static int setting_uint_action_left_default(void *data, bool wraparound)
{
rarch_setting_t *setting = (rarch_setting_t*)data;
@@ -228,6 +246,79 @@ static int setting_uint_action_right_default(void *data, bool wraparound)
return 0;
}
+static int setting_size_action_left_default(void *data, bool wraparound)
+{
+ rarch_setting_t *setting = (rarch_setting_t*)data;
+ double min = 0.0f;
+ bool overflowed = false;
+
+ if (!setting)
+ return -1;
+
+ min = setting->min;
+
+ (void)wraparound; /* TODO/FIXME - handle this */
+
+ overflowed = setting->step > *setting->value.target.sizet;
+
+ if (!overflowed)
+ *setting->value.target.sizet = *setting->value.target.sizet - setting->step;
+
+ if (setting->enforce_minrange)
+ {
+ if (overflowed || *setting->value.target.sizet < min)
+ {
+ settings_t *settings = config_get_ptr();
+
+#ifdef HAVE_MENU
+ double max = setting->max;
+
+ if (settings && settings->bools.menu_navigation_wraparound_enable)
+ *setting->value.target.sizet = max;
+ else
+#endif
+ *setting->value.target.sizet = min;
+ }
+ }
+
+ return 0;
+}
+
+static int setting_size_action_right_default(void *data, bool wraparound)
+{
+ rarch_setting_t *setting = (rarch_setting_t*)data;
+ double max = 0.0f;
+
+ if (!setting)
+ return -1;
+
+ max = setting->max;
+
+ (void)wraparound; /* TODO/FIXME - handle this */
+
+ *setting->value.target.sizet =
+ *setting->value.target.sizet + setting->step;
+
+ if (setting->enforce_maxrange)
+ {
+ if (*setting->value.target.sizet > max)
+ {
+ settings_t *settings = config_get_ptr();
+
+#ifdef HAVE_MENU
+ double min = setting->min;
+
+ if (settings && settings->bools.menu_navigation_wraparound_enable)
+ *setting->value.target.sizet = min;
+ else
+#endif
+ *setting->value.target.sizet = max;
+ }
+ }
+
+ return 0;
+}
+
int setting_generic_action_ok_default(void *data, bool wraparound)
{
rarch_setting_t *setting = (rarch_setting_t*)data;
@@ -310,6 +401,24 @@ int setting_set_with_string_representation(rarch_setting_t* setting,
}
}
break;
+ case ST_SIZE:
+ sscanf(value, "%" PRI_SIZET, setting->value.target.sizet);
+ if (flags & SD_FLAG_HAS_RANGE)
+ {
+ if (setting->enforce_minrange && *setting->value.target.sizet < min)
+ *setting->value.target.sizet = min;
+ if (setting->enforce_maxrange && *setting->value.target.sizet > max)
+ {
+#ifdef HAVE_MENU
+ settings_t *settings = config_get_ptr();
+ if (settings && settings->bools.menu_navigation_wraparound_enable)
+ *setting->value.target.sizet = min;
+ else
+#endif
+ *setting->value.target.sizet = max;
+ }
+ }
+ break;
case ST_FLOAT:
sscanf(value, "%f", setting->value.target.fraction);
if (flags & SD_FLAG_HAS_RANGE)
@@ -443,6 +552,9 @@ static void setting_reset_setting(rarch_setting_t* setting)
case ST_UINT:
*setting->value.target.unsigned_integer = setting->default_value.unsigned_integer;
break;
+ case ST_SIZE:
+ *setting->value.target.sizet = setting->default_value.sizet;
+ break;
case ST_FLOAT:
*setting->value.target.fraction = setting->default_value.fraction;
break;
@@ -875,6 +987,85 @@ static rarch_setting_t setting_uint_setting(const char* name,
return result;
}
+/**
+ * setting_size_setting:
+ * @name : name of setting.
+ * @short_description : Short description of setting.
+ * @target : Target of size_t setting.
+ * @default_value : Default value (in size_t format).
+ * @group : Group that the setting belongs to.
+ * @subgroup : Subgroup that the setting belongs to.
+ * @change_handler : Function callback for change handler function pointer.
+ * @read_handler : Function callback for read handler function pointer.
+ * @dont_use_enum_idx : Boolean indicating whether or not to use the enum idx
+ * @string_representation_handler : Function callback for converting the setting to a string
+ *
+ * Initializes a setting of type ST_SIZE.
+ *
+ * Returns: setting of type ST_SIZE.
+ **/
+static rarch_setting_t setting_size_setting(const char* name,
+ const char* short_description, size_t* target,
+ size_t default_value,
+ const char *group, const char *subgroup, const char *parent_group,
+ change_handler_t change_handler, change_handler_t read_handler,
+ bool dont_use_enum_idx, get_string_representation_t string_representation_handler)
+{
+ rarch_setting_t result;
+
+ result.enum_idx = MSG_UNKNOWN;
+ result.type = ST_SIZE;
+
+ result.size = sizeof(size_t);
+
+ result.name = name;
+ result.short_description = short_description;
+ result.group = group;
+ result.subgroup = subgroup;
+ result.parent_group = parent_group;
+ result.values = NULL;
+
+ result.index = 0;
+ result.index_offset = 0;
+
+ result.min = 0.0;
+ result.max = 0.0;
+
+ result.flags = 0;
+ result.free_flags = 0;
+
+ result.change_handler = change_handler;
+ result.read_handler = read_handler;
+ result.action_start = setting_generic_action_start_default;
+ result.action_left = setting_size_action_left_default;
+ result.action_right = setting_size_action_right_default;
+ result.action_up = NULL;
+ result.action_down = NULL;
+ result.action_cancel = NULL;
+ result.action_ok = setting_generic_action_ok_default;
+ result.action_select = setting_generic_action_ok_default;
+ result.get_string_representation = &setting_get_string_representation_size;
+ result.get_string_representation = string_representation_handler;
+
+ result.bind_type = 0;
+ result.browser_selection_type = ST_NONE;
+ result.step = 0.0f;
+ result.rounding_fraction = NULL;
+ result.enforce_minrange = false;
+ result.enforce_maxrange = false;
+
+ result.value.target.sizet = target;
+ result.original_value.sizet = *target;
+ result.default_value.sizet = default_value;
+
+ result.cmd_trigger.idx = CMD_EVENT_NONE;
+ result.cmd_trigger.triggered = false;
+
+ result.dont_use_enum_idx_representation = dont_use_enum_idx;
+
+ return result;
+}
+
/**
* setting_hex_setting:
* @name : name of setting.
@@ -1613,6 +1804,39 @@ bool CONFIG_UINT(
return true;
}
+bool CONFIG_SIZE(
+ rarch_setting_t **list,
+ rarch_setting_info_t *list_info,
+ size_t *target,
+ enum msg_hash_enums name_enum_idx,
+ enum msg_hash_enums SHORT_enum_idx,
+ size_t default_value,
+ rarch_setting_group_info_t *group_info,
+ rarch_setting_group_info_t *subgroup_info,
+ const char *parent_group,
+ change_handler_t change_handler, change_handler_t read_handler,
+ get_string_representation_t string_representation_handler)
+{
+ rarch_setting_t value = setting_size_setting (
+ msg_hash_to_str(name_enum_idx),
+ msg_hash_to_str(SHORT_enum_idx),
+ target, default_value,
+ group_info->name,
+ subgroup_info->name, parent_group,
+ change_handler, read_handler,
+ false, string_representation_handler);
+ if (!(settings_list_append(list, list_info)))
+ return false;
+ (*list)[list_info->index++] = value;
+
+#ifdef HAVE_MENU
+ menu_settings_list_current_add_enum_idx(list, list_info, name_enum_idx);
+ menu_settings_list_current_add_enum_value_idx(list, list_info, SHORT_enum_idx);
+#endif
+
+ return true;
+}
+
bool CONFIG_FLOAT(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
@@ -2014,6 +2238,7 @@ static int setting_generic_action_ok_linefeed(void *data, bool wraparound)
switch (setting_get_type(setting))
{
+ case ST_SIZE:
case ST_UINT:
cb = menu_input_st_uint_cb;
break;
@@ -2060,6 +2285,7 @@ static void setting_add_special_callbacks(
switch ((*list)[idx].type)
{
+ case ST_SIZE:
case ST_UINT:
(*list)[idx].action_cancel = NULL;
break;
diff --git a/setting_list.h b/setting_list.h
index abd5a26652..01bf89d37b 100644
--- a/setting_list.h
+++ b/setting_list.h
@@ -32,6 +32,7 @@ enum setting_type
ST_BOOL,
ST_INT,
ST_UINT,
+ ST_SIZE,
ST_FLOAT,
ST_PATH,
ST_DIR,
@@ -141,6 +142,7 @@ struct rarch_setting
unsigned int unsigned_integer;
float fraction;
const struct retro_keybind *keybind;
+ size_t sizet;
} default_value;
struct
@@ -153,6 +155,7 @@ struct rarch_setting
unsigned int *unsigned_integer;
float *fraction;
struct retro_keybind *keybind;
+ size_t *sizet;
} target;
} value;
@@ -162,6 +165,7 @@ struct rarch_setting
int integer;
unsigned int unsigned_integer;
float fraction;
+ size_t sizet;
} original_value;
struct
@@ -289,6 +293,19 @@ bool CONFIG_UINT(
const char *parent_group,
change_handler_t change_handler, change_handler_t read_handler);
+bool CONFIG_SIZE(
+ rarch_setting_t **list,
+ rarch_setting_info_t *list_info,
+ size_t *target,
+ enum msg_hash_enums name_enum_idx,
+ enum msg_hash_enums SHORT_enum_idx,
+ size_t default_value,
+ rarch_setting_group_info_t *group_info,
+ rarch_setting_group_info_t *subgroup_info,
+ const char *parent_group,
+ change_handler_t change_handler, change_handler_t read_handler,
+ get_string_representation_t string_representation_handler);
+
bool CONFIG_FLOAT(
rarch_setting_t **list,
rarch_setting_info_t *list_info,
@@ -414,6 +431,9 @@ void settings_data_list_current_add_free_flags(
rarch_setting_info_t *list_info,
unsigned values);
+void setting_get_string_representation_size_in_mb(void *data,
+ char *s, size_t len);
+
#define setting_get_type(setting) ((setting) ? setting->type : ST_NONE)
RETRO_END_DECLS