Merge pull request #2 from libretro/master

updates
This commit is contained in:
Ömercan Kömür 2019-07-18 23:51:36 +03:00 committed by GitHub
commit 797063cc78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
39 changed files with 409 additions and 278 deletions

View File

@ -2405,7 +2405,7 @@ static config_file_t *open_default_config_file(void)
fill_pathname_resolve_relative(conf_path, app_path,
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
conf = config_file_new(conf_path);
conf = config_file_new_from_path_to_string(conf_path);
if (!conf)
{
@ -2414,7 +2414,7 @@ static config_file_t *open_default_config_file(void)
{
fill_pathname_join(conf_path, application_data,
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
conf = config_file_new(conf_path);
conf = config_file_new_from_path_to_string(conf_path);
}
}
@ -2457,7 +2457,7 @@ static config_file_t *open_default_config_file(void)
fill_pathname_join(conf_path, application_data,
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
conf = config_file_new(conf_path);
conf = config_file_new_from_path_to_string(conf_path);
if (!conf)
{
@ -2490,7 +2490,7 @@ static config_file_t *open_default_config_file(void)
fill_pathname_join(conf_path, application_data,
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
RARCH_LOG("Looking for config in: \"%s\".\n", conf_path);
conf = config_file_new(conf_path);
conf = config_file_new_from_path_to_string(conf_path);
}
/* Fallback to $HOME/.retroarch.cfg. */
@ -2499,7 +2499,7 @@ static config_file_t *open_default_config_file(void)
fill_pathname_join(conf_path, getenv("HOME"),
".retroarch.cfg", path_size);
RARCH_LOG("Looking for config in: \"%s\".\n", conf_path);
conf = config_file_new(conf_path);
conf = config_file_new_from_path_to_string(conf_path);
}
if (!conf && has_application_data)
@ -2533,7 +2533,7 @@ static config_file_t *open_default_config_file(void)
fill_pathname_join(skeleton_conf, GLOBAL_CONFIG_DIR,
file_path_str(FILE_PATH_MAIN_CONFIG), path_size);
conf = config_file_new(skeleton_conf);
conf = config_file_new_from_path_to_string(skeleton_conf);
if (conf)
RARCH_WARN("Config: using skeleton config \"%s\" as base for a new config file.\n", skeleton_conf);
else
@ -2652,7 +2652,7 @@ static bool config_load_file(const char *path, settings_t *settings)
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);
config_file_t *conf = path ? config_file_new(path) : open_default_config_file();
config_file_t *conf = path ? config_file_new_from_path_to_string(path) : open_default_config_file();
tmp_str[0] = '\0';
@ -3452,7 +3452,7 @@ bool config_load_remap(void)
path_size);
/* Create a new config file from game_path */
new_conf = config_file_new(game_path);
new_conf = config_file_new_from_path_to_string(game_path);
/* If a game remap file exists, load it. */
if (new_conf)
@ -3474,7 +3474,7 @@ bool config_load_remap(void)
}
/* Create a new config file from content_path */
new_conf = config_file_new(content_path);
new_conf = config_file_new_from_path_to_string(content_path);
/* If a content-dir remap file exists, load it. */
if (new_conf)
@ -3496,7 +3496,7 @@ bool config_load_remap(void)
}
/* Create a new config file from core_path */
new_conf = config_file_new(core_path);
new_conf = config_file_new_from_path_to_string(core_path);
/* If a core remap file exists, load it. */
if (new_conf)
@ -3634,7 +3634,7 @@ bool config_save_autoconf_profile(const char *path, unsigned user)
free(buf);
free(path_new);
conf = config_file_new(autoconf_file);
conf = config_file_new_from_path_to_string(autoconf_file);
if (!conf)
{
@ -3698,7 +3698,7 @@ bool config_save_file(const char *path)
struct config_float_setting *float_settings = NULL;
struct config_array_setting *array_settings = NULL;
struct config_path_setting *path_settings = NULL;
config_file_t *conf = config_file_new(path);
config_file_t *conf = config_file_new_from_path_to_string(path);
settings_t *settings = config_get_ptr();
int bool_settings_size = sizeof(settings->bools) / sizeof(settings->bools.placeholder);
int float_settings_size = sizeof(settings->floats)/ sizeof(settings->floats.placeholder);

View File

@ -225,16 +225,7 @@ static config_file_t *core_info_list_iterate(
info_path_base = NULL;
if (path_is_valid(info_path))
{
int64_t length = 0;
uint8_t *ret_buf = NULL;
if (filestream_read_file(info_path, (void**)&ret_buf, &length))
{
if (length >= 0)
conf = config_file_new_from_string((const char*)ret_buf);
free((void*)ret_buf);
}
}
conf = config_file_new_from_path_to_string(info_path);
free(info_path);
return conf;
@ -293,8 +284,8 @@ static core_info_list_t *core_info_list_new(const char *path,
for (i = 0; i < contents->size; i++)
{
const char *path = contents->elems[i].data;
config_file_t *conf = core_info_list_iterate(path,
const char *base_path = contents->elems[i].data;
config_file_t *conf = core_info_list_iterate(base_path,
path_basedir);
if (conf)
@ -447,8 +438,8 @@ static core_info_list_t *core_info_list_new(const char *path,
core_info[i].config_data = conf;
}
if (!string_is_empty(path))
core_info[i].path = strdup(path);
if (!string_is_empty(base_path))
core_info[i].path = strdup(base_path);
if (!core_info[i].display_name)
core_info[i].display_name =
@ -923,16 +914,8 @@ bool core_info_list_get_display_name(core_info_list_t *core_info_list,
bool core_info_get_display_name(const char *path, char *s, size_t len)
{
int64_t length = 0;
char *tmp = NULL;
config_file_t *conf = NULL;
uint8_t *ret_buf = NULL;
if (filestream_read_file(path, (void**)&ret_buf, &length))
{
if (length >= 0)
conf = config_file_new_from_string((const char*)ret_buf);
free((void*)ret_buf);
}
config_file_t *conf = config_file_new_from_path_to_string(path);
if (!conf)
return false;

View File

@ -163,12 +163,11 @@ void egl_bind_hw_render(egl_ctx_data_t *egl, bool enable)
void egl_swap_buffers(void *data)
{
egl_ctx_data_t *egl = (egl_ctx_data_t*)data;
if (egl->dpy == EGL_NO_DISPLAY)
return;
if (egl->surf == EGL_NO_SURFACE)
return;
eglSwapBuffers(egl->dpy, egl->surf);
if ( egl &&
egl->dpy != EGL_NO_DISPLAY &&
egl->surf != EGL_NO_SURFACE
)
eglSwapBuffers(egl->dpy, egl->surf);
}
void egl_set_swap_interval(egl_ctx_data_t *egl, int interval)

View File

@ -1137,7 +1137,7 @@ typedef struct MTLALIGN(16)
[self _freeVideoShader:_shader];
_shader = nil;
config_file_t *conf = config_file_new(path.UTF8String);
config_file_t *conf = config_file_new_from_path_to_string(path.UTF8String);
struct video_shader *shader = (struct video_shader *)calloc(1, sizeof(*shader));
@try

View File

@ -1140,6 +1140,8 @@ void win32_check_window(bool *quit, bool *resize,
unsigned *width, unsigned *height)
{
#if !defined(_XBOX)
if (video_driver_is_threaded())
ui_companion_win32.application->process_events();
*quit = g_win32_quit;
if (g_win32_resized)

View File

@ -360,9 +360,7 @@ static bool d3d10_gfx_set_shader(void* data, enum rarch_shader_type type, const
return false;
}
conf = config_file_new(path);
if (!conf)
if (!(conf = config_file_new_from_path_to_string(path)))
return false;
d3d10->shader_preset = (struct video_shader*)calloc(1, sizeof(*d3d10->shader_preset));

View File

@ -378,9 +378,7 @@ static bool d3d11_gfx_set_shader(void* data, enum rarch_shader_type type, const
return false;
}
conf = config_file_new(path);
if (!conf)
if (!(conf = config_file_new_from_path_to_string(path)))
return false;
d3d11->shader_preset = (struct video_shader*)calloc(1, sizeof(*d3d11->shader_preset));

View File

@ -359,9 +359,7 @@ static bool d3d12_gfx_set_shader(void* data, enum rarch_shader_type type, const
return false;
}
conf = config_file_new(path);
if (!conf)
if (!(conf = config_file_new_from_path_to_string(path)))
return false;
d3d12->shader_preset = (struct video_shader*)calloc(1, sizeof(*d3d12->shader_preset));

View File

@ -325,7 +325,7 @@ static bool d3d9_init_multipass(d3d9_video_t *d3d, const char *shader_path)
unsigned i;
bool use_extra_pass = false;
struct video_shader_pass *pass = NULL;
config_file_t *conf = config_file_new(shader_path);
config_file_t *conf = config_file_new_from_path_to_string(shader_path);
if (!conf)
{

View File

@ -1453,7 +1453,7 @@ static bool wiiu_gfx_set_shader(void *data,
return false;
}
if (!(conf = config_file_new(path)))
if (!(conf = config_file_new_from_path_to_string(path)))
return false;
wiiu->shader_preset = calloc(1, sizeof(*wiiu->shader_preset));

View File

@ -69,7 +69,11 @@ static void gl_raster_font_free_font(void *data,
if (is_threaded)
video_context_driver_make_current(true);
glDeleteTextures(1, &font->tex);
if (font->tex)
{
glDeleteTextures(1, &font->tex);
font->tex = 0;
}
free(font);
}

View File

@ -21,6 +21,7 @@
#include <retro_miscellaneous.h>
#include <file/file_path.h>
#include <file/config_file.h>
#include <streams/file_stream.h>
#include <lists/string_list.h>
#include <string/stdstring.h>

View File

@ -110,4 +110,6 @@ bool glslang_read_shader_file(const char *path, std::vector<std::string> *output
bool glslang_parse_meta(const std::vector<std::string> &lines, glslang_meta *meta);
#endif
void *config_file_new_wrapper(const char *path);
#endif

View File

@ -678,7 +678,7 @@ static bool gl_cg_load_preset(void *data, const char *path)
return false;
RARCH_LOG("[CG]: Loading Cg meta-shader: %s\n", path);
conf = config_file_new(path);
conf = config_file_new_from_path_to_string(path);
if (!conf)
{
RARCH_ERR("Failed to load preset.\n");

View File

@ -2409,7 +2409,7 @@ gl_core_filter_chain_t *gl_core_filter_chain_create_from_preset(
if (!shader)
return nullptr;
unique_ptr<config_file_t, gl_core::ConfigDeleter> conf{ config_file_new(path) };
unique_ptr<config_file_t, gl_core::ConfigDeleter> conf{ config_file_new_from_path_to_string(path) };
if (!conf)
return nullptr;

View File

@ -682,6 +682,7 @@ static void gl_glsl_destroy_resources(glsl_shader_data_t *glsl)
continue;
glDeleteProgram(glsl->prg[i].id);
glsl->prg[i].id = 0;
}
if (glsl->shader && glsl->shader->luts)
@ -899,7 +900,7 @@ static void *gl_glsl_init(void *data, const char *path)
if (is_preset)
{
conf = config_file_new(path);
conf = config_file_new_from_path_to_string(path);
if (conf)
{
ret = video_shader_read_conf_preset(conf, glsl->shader);

View File

@ -2348,7 +2348,7 @@ void Pass::build_commands(
}
else
{
const VkViewport vp = {
const VkViewport _vp = {
0.0f, 0.0f,
float(current_framebuffer_size.width),
float(current_framebuffer_size.height),
@ -2362,7 +2362,7 @@ void Pass::build_commands(
},
};
vkCmdSetViewport(cmd, 0, 1, &vp);
vkCmdSetViewport(cmd, 0, 1, &_vp);
vkCmdSetScissor(cmd, 0, 1, &sci);
}
@ -2886,7 +2886,7 @@ vulkan_filter_chain_t *vulkan_filter_chain_create_from_preset(
if (!shader)
return nullptr;
unique_ptr<config_file_t, ConfigDeleter> conf{ config_file_new(path) };
unique_ptr<config_file_t, ConfigDeleter> conf{ config_file_new_from_path_to_string(path) };
if (!conf)
return nullptr;

View File

@ -406,8 +406,7 @@ rarch_softfilter_t *rarch_softfilter_new(const char *filter_config,
if (!filt)
return NULL;
filt->conf = config_file_new(filter_config);
if (!filt->conf)
if (!(filt->conf = config_file_new_from_path_to_string(filter_config)))
{
RARCH_ERR("[SoftFilter]: Did not find config: %s\n", filter_config);
goto error;

View File

@ -1359,20 +1359,27 @@ static void android_input_poll_memcpy(android_input_t *android)
static bool android_input_key_pressed(android_input_t *android, int key)
{
uint16_t joykey;
uint32_t joyaxis;
rarch_joypad_info_t joypad_info;
const uint16_t joykey = (input_config_binds[0][key].joykey != NO_BTN)
? input_config_binds[0][key].joykey : joypad_info.auto_binds[key].joykey;
const uint32_t joyaxis = (input_config_binds[0][key].joyaxis != AXIS_NONE)
? input_config_binds[0][key].joyaxis : joypad_info.auto_binds[key].joyaxis;
joypad_info.joy_idx = 0;
joypad_info.auto_binds = input_autoconf_binds[0];
joypad_info.axis_threshold = *
(input_driver_get_float(INPUT_ACTION_AXIS_THRESHOLD));
if((key < RARCH_BIND_LIST_END)
&& android_keyboard_port_input_pressed(input_config_binds[0],
key))
return true;
joypad_info.joy_idx = 0;
joypad_info.auto_binds = input_autoconf_binds[0];
joypad_info.axis_threshold = *(input_driver_get_float(INPUT_ACTION_AXIS_THRESHOLD));
joykey =
(input_config_binds[0][key].joykey != NO_BTN)
? input_config_binds[0][key].joykey
: joypad_info.auto_binds[key].joykey;
joyaxis =
(input_config_binds[0][key].joyaxis != AXIS_NONE)
? input_config_binds[0][key].joyaxis
: joypad_info.auto_binds[key].joyaxis;
if (joykey != NO_BTN && android->joypad->button(joypad_info.joy_idx, joykey))
return true;
@ -1707,79 +1714,88 @@ static void android_input_grab_mouse(void *data, bool state)
(void)state;
}
static void android_input_set_rumble_internal(
uint16_t strength,
uint16_t *last_strength_strong,
uint16_t *last_strength_weak,
uint16_t *last_strength,
int8_t id,
enum retro_rumble_effect effect
)
{
JNIEnv *env = (JNIEnv*)jni_thread_getenv();
uint16_t new_strength = 0;
if (!env)
return;
if (effect == RETRO_RUMBLE_STRONG)
{
new_strength = strength | *last_strength_weak;
*last_strength_strong = strength;
}
else if (effect == RETRO_RUMBLE_WEAK)
{
new_strength = strength | *last_strength_strong;
*last_strength_weak = strength;
}
if (new_strength != *last_strength)
{
/* trying to send this value as a JNI param without
* storing it first was causing 0 to be seen on the other side ?? */
int strength_final = (255.0f / 65535.0f) * (float)new_strength;
CALL_VOID_METHOD_PARAM(env, g_android->activity->clazz,
g_android->doVibrate, (jint)id, (jint)RETRO_RUMBLE_STRONG, (jint)strength_final, (jint)0);
*last_strength = new_strength;
}
}
static bool android_input_set_rumble(void *data, unsigned port,
enum retro_rumble_effect effect, uint16_t strength)
{
android_input_t *android = (android_input_t*)data;
settings_t *settings = config_get_ptr();
JNIEnv *env = (JNIEnv*)jni_thread_getenv();
if (!android || !env || !g_android || !g_android->doVibrate)
if (!g_android || !g_android->doVibrate)
return false;
if (settings->bools.enable_device_vibration)
{
static uint16_t last_strength_strong = 0;
static uint16_t last_strength_weak = 0;
static uint16_t last_strength = 0;
uint16_t new_strength = 0;
static uint16_t last_strength_weak = 0;
static uint16_t last_strength = 0;
if (port != 0)
return false;
if (effect == RETRO_RUMBLE_STRONG)
{
new_strength = strength | last_strength_weak;
last_strength_strong = strength;
}
else if (effect == RETRO_RUMBLE_WEAK)
{
new_strength = strength | last_strength_strong;
last_strength_weak = strength;
}
if (new_strength != last_strength)
{
/* trying to send this value as a JNI param without storing it first was causing 0 to be seen on the other side ?? */
int strength_final = (255.0f / 65535.0f) * (float)new_strength;
CALL_VOID_METHOD_PARAM(env, g_android->activity->clazz,
g_android->doVibrate, (jint)-1, (jint)RETRO_RUMBLE_STRONG, (jint)strength_final, (jint)0);
last_strength = new_strength;
}
android_input_set_rumble_internal(
strength,
&last_strength_strong,
&last_strength_weak,
&last_strength,
-1,
effect);
return true;
}
else
{
uint16_t new_strength = 0;
state_device_t *state = &android->pad_states[port];
android_input_t *android = (android_input_t*)data;
state_device_t *state = android ? &android->pad_states[port] : NULL;
if (effect == RETRO_RUMBLE_STRONG)
if (state)
{
new_strength = strength | state->rumble_last_strength_weak;
state->rumble_last_strength_strong = strength;
android_input_set_rumble_internal(
strength,
&state->rumble_last_strength_strong,
&state->rumble_last_strength_weak,
&state->rumble_last_strength,
state->id,
effect);
return true;
}
else if (effect == RETRO_RUMBLE_WEAK)
{
new_strength = strength | state->rumble_last_strength_strong;
state->rumble_last_strength_weak = strength;
}
if (new_strength != state->rumble_last_strength)
{
/* trying to send this value as a JNI param without storing it first was causing 0 to be seen on the other side ?? */
int strength_final = (255.0f / 65535.0f) * (float)new_strength;
int id = state->id;
CALL_VOID_METHOD_PARAM(env, g_android->activity->clazz,
g_android->doVibrate, (jint)id, (jint)RETRO_RUMBLE_STRONG, (jint)strength_final, (jint)0);
state->rumble_last_strength = new_strength;
}
return true;
}
return false;

View File

@ -204,9 +204,6 @@ void input_overlay_free_overlay(struct overlay *overlay);
bool input_overlay_key_pressed(input_overlay_t *ol, unsigned key);
void input_overlay_loaded(retro_task_t *task,
void *task_data, void *user_data, const char *err);
void input_overlay_set_visibility(int overlay_idx,enum overlay_visibility vis);
RETRO_END_DECLS

View File

@ -166,9 +166,7 @@ bool input_remapping_save_file(const char *path)
free(buf);
conf = config_file_new(remap_file);
if (!conf)
if (!(conf = config_file_new_from_path_to_string(remap_file)))
{
if (!(conf = config_file_new_alloc()))
{

View File

@ -244,8 +244,7 @@ retro_dsp_filter_t *retro_dsp_filter_new(
if (!dsp)
return NULL;
conf = config_file_new(filter_config);
if (!conf) /* Did not find config. */
if (!(conf = config_file_new_from_path_to_string(filter_config)))
goto error;
dsp->conf = conf;

View File

@ -515,7 +515,7 @@ void config_file_free(config_file_t *conf)
bool config_append_file(config_file_t *conf, const char *path)
{
config_file_t *new_conf = config_file_new(path);
config_file_t *new_conf = config_file_new_from_path_to_string(path);
if (!new_conf)
return false;
@ -593,6 +593,23 @@ config_file_t *config_file_new_from_string(const char *from_string)
return conf;
}
config_file_t *config_file_new_from_path_to_string(const char *path)
{
int64_t length = 0;
uint8_t *ret_buf = NULL;
config_file_t *conf = NULL;
if (filestream_read_file(path, (void**)&ret_buf, &length))
{
if (length >= 0)
if ((conf = config_file_new_from_string((const char*)ret_buf)))
conf->path = strdup(path);
free((void*)ret_buf);
}
return conf;
}
config_file_t *config_file_new_with_callback(
const char *path, config_file_cb_t *cb)
{

View File

@ -96,6 +96,8 @@ config_file_t *config_file_new_with_callback(const char *path, config_file_cb_t
/* Load a config file from a string. */
config_file_t *config_file_new_from_string(const char *from_string);
config_file_t *config_file_new_from_path_to_string(const char *path);
/* Frees config file. */
void config_file_free(config_file_t *conf);

View File

@ -165,7 +165,7 @@ bool cheat_manager_save(const char *path, const char *cheat_database, bool overw
}
if (!overwrite)
conf = config_file_new(cheats_file);
conf = config_file_new_from_path_to_string(cheats_file);
if (!conf)
if (!(conf = config_file_new_alloc()))

View File

@ -219,12 +219,11 @@ static int deferred_push_cursor_manager_list_deferred(
int ret = -1;
char *query = NULL;
char *rdb = NULL;
settings_t *settings = config_get_ptr();
const char *path = info->path;
config_file_t *conf = path ? config_file_new(path) : NULL;
if (!conf || !settings)
goto end;
config_file_t *conf = NULL;
if (!(conf = config_file_new_from_path_to_string(path)))
return -1;
if (!config_get_string(conf, "query", &query))
goto end;
@ -234,9 +233,13 @@ static int deferred_push_cursor_manager_list_deferred(
rdb_path[0] = '\0';
fill_pathname_join(rdb_path,
settings->paths.path_content_database,
rdb, sizeof(rdb_path));
{
settings_t *settings = config_get_ptr();
if (settings)
fill_pathname_join(rdb_path,
settings->paths.path_content_database,
rdb, sizeof(rdb_path));
}
if (!string_is_empty(info->path_b))
free(info->path_b);
@ -255,8 +258,7 @@ static int deferred_push_cursor_manager_list_deferred(
ret = deferred_push_dlist(info, DISPLAYLIST_DATABASE_QUERY);
end:
if (conf)
config_file_free(conf);
config_file_free(conf);
free(rdb);
free(query);
return ret;

View File

@ -1551,7 +1551,7 @@ static int generic_action_ok(const char *path,
break;
case ACTION_OK_LOAD_REMAPPING_FILE:
{
config_file_t *conf = config_file_new(action_path);
config_file_t *conf = config_file_new_from_path_to_string(action_path);
flush_char = msg_hash_to_str(flush_id);
if (conf)
@ -4034,9 +4034,7 @@ static int action_ok_option_create(const char *path,
return 0;
}
conf = config_file_new(game_path);
if (!conf)
if (!(conf = config_file_new_from_path_to_string(game_path)))
if (!(conf = config_file_new_alloc()))
return false;

View File

@ -2158,8 +2158,7 @@ static void load_custom_theme(rgui_t *rgui, rgui_theme_t *theme_colors, const ch
goto end;
/* Open config file */
conf = config_file_new(theme_path);
if (!conf)
if (!(conf = config_file_new_from_path_to_string(theme_path)))
goto end;
/* Parse config file */

View File

@ -2850,6 +2850,7 @@ static int xmb_draw_item(
uintptr_t texture_switch = 0;
bool do_draw_text = false;
unsigned ticker_limit = 35 * scale_mod[0];
unsigned line_ticker_width = 45 * scale_mod[3];
xmb_node_t * node = (xmb_node_t*)
file_list_get_userdata_at_offset(list, i);
settings_t *settings = config_get_ptr();
@ -2951,16 +2952,27 @@ static int xmb_draw_item(
&& settings->bools.menu_xmb_vertical_thumbnails)
)
{
ticker_limit = 40 * scale_mod[1];
ticker_limit = 40 * scale_mod[1];
line_ticker_width = 50 * scale_mod[3];
/* Can increase text length if thumbnail is downscaled */
if (settings->uints.menu_xmb_thumbnail_scale_factor < 100)
{
float ticker_scale_factor =
1.0f - ((float)settings->uints.menu_xmb_thumbnail_scale_factor / 100.0f);
ticker_limit +=
(unsigned)((1.0f - ((float)settings->uints.menu_xmb_thumbnail_scale_factor / 100.0f)) *
15.0f * scale_mod[1]);
(unsigned)(ticker_scale_factor * 15.0f * scale_mod[1]);
line_ticker_width +=
(unsigned)(ticker_scale_factor * 10.0f * scale_mod[3]);
}
}
else
ticker_limit = 70 * scale_mod[2];
{
ticker_limit = 70 * scale_mod[2];
line_ticker_width = 60 * scale_mod[3];
}
}
menu_entry_get_rich_label(entry, &ticker_str);
@ -2981,11 +2993,26 @@ static int xmb_draw_item(
if (i == current && width > 320 && height > 240
&& !string_is_empty(entry->sublabel))
{
menu_animation_ctx_line_ticker_t line_ticker;
char entry_sublabel[512] = {0};
label_offset = - xmb->margins_label_top;
line_ticker.type_enum = (enum menu_animation_ticker_type)settings->uints.menu_ticker_type;
line_ticker.idx = menu_animation_get_ticker_idx();
word_wrap(entry_sublabel, entry->sublabel, 50 * scale_mod[3], true, 0);
line_ticker.line_width = (size_t)(line_ticker_width);
/* Note: max_lines should be calculated at runtime,
* but this is a nuisance. There is room for 4 lines
* to be displayed when using all existing XMB themes,
* so leave this value hard coded for now. */
line_ticker.max_lines = 4;
line_ticker.s = entry_sublabel;
line_ticker.len = sizeof(entry_sublabel);
line_ticker.str = entry->sublabel;
menu_animation_line_ticker(&line_ticker);
label_offset = - xmb->margins_label_top;
xmb_draw_text(video_info, xmb, entry_sublabel,
node->x + xmb->margins_screen_left +

View File

@ -23,6 +23,7 @@
#include <retro_miscellaneous.h>
#include <string/stdstring.h>
#include <features/features_cpu.h>
#include <lists/string_list.h>
#define DG_DYNARR_IMPLEMENTATION
#include <stdio.h>
@ -386,6 +387,60 @@ static void menu_animation_ticker_loop(uint64_t idx,
*width3 = width;
}
static size_t get_line_display_ticks(size_t line_width)
{
/* Mean human reading speed for all western languages,
* characters per minute */
float cpm = 1000.0f;
/* Base time for which a line should be shown, in ms */
float line_duration = (line_width * 60.0f * 1000.0f) / cpm;
/* Ticker updates (nominally) once every TICKER_SPEED ms
* > Return base number of ticks for which line should be shown */
return (size_t)(line_duration / (float)TICKER_SPEED);
}
static void menu_animation_line_ticker_generic(uint64_t idx,
size_t line_width, size_t max_lines, size_t num_lines,
size_t *line_offset)
{
size_t line_ticks = get_line_display_ticks(line_width);
/* Note: This function is only called if num_lines > max_lines */
size_t excess_lines = num_lines - max_lines;
/* Ticker will pause for one line duration when the first
* or last line is reached (this is mostly required for the
* case where num_lines == (max_lines + 1), since otherwise
* the text flicks rapidly up and down in disconcerting
* fashion...) */
size_t ticker_period = (excess_lines * 2) + 2;
size_t phase = (idx / line_ticks) % ticker_period;
/* Pause on first line */
if (phase > 0)
phase--;
/* Pause on last line */
if (phase > excess_lines)
phase--;
/* Lines scrolling upwards */
if (phase <= excess_lines)
*line_offset = phase;
/* Lines scrolling downwards */
else
*line_offset = (excess_lines * 2) - phase;
}
static void menu_animation_line_ticker_loop(uint64_t idx,
size_t line_width, size_t num_lines,
size_t *line_offset)
{
size_t line_ticks = get_line_display_ticks(line_width);
size_t ticker_period = num_lines + 1;
size_t phase = (idx / line_ticks) % ticker_period;
/* In this case, line_offset is simply equal to the phase */
*line_offset = phase;
}
static void menu_delayed_animation_cb(void *userdata)
{
menu_delayed_animation_t *delayed_animation = (menu_delayed_animation_t*) userdata;
@ -771,6 +826,125 @@ bool menu_animation_ticker(menu_animation_ctx_ticker_t *ticker)
return true;
}
bool menu_animation_line_ticker(menu_animation_ctx_line_ticker_t *line_ticker)
{
size_t i;
char *wrapped_str = NULL;
struct string_list *lines = NULL;
size_t line_offset = 0;
bool success = false;
bool is_active = false;
/* Sanity check */
if (!line_ticker)
return false;
if (string_is_empty(line_ticker->str) ||
(line_ticker->line_width < 1) ||
(line_ticker->max_lines < 1))
goto end;
/* Line wrap input string */
wrapped_str = (char*)malloc((strlen(line_ticker->str) + 1) * sizeof(char));
if (!wrapped_str)
goto end;
word_wrap(
wrapped_str,
line_ticker->str,
(int)line_ticker->line_width,
true, 0);
if (string_is_empty(wrapped_str))
goto end;
/* Split into component lines */
lines = string_split(wrapped_str, "\n");
if (!lines)
goto end;
/* Check whether total number of lines fits within
* the set limit */
if (lines->size <= line_ticker->max_lines)
{
strlcpy(line_ticker->s, wrapped_str, line_ticker->len);
success = true;
goto end;
}
/* Determine offset of first line in wrapped string */
switch (line_ticker->type_enum)
{
case TICKER_TYPE_LOOP:
{
menu_animation_line_ticker_loop(
line_ticker->idx,
line_ticker->line_width,
lines->size,
&line_offset);
break;
}
case TICKER_TYPE_BOUNCE:
default:
{
menu_animation_line_ticker_generic(
line_ticker->idx,
line_ticker->line_width,
line_ticker->max_lines,
lines->size,
&line_offset);
break;
}
}
/* Build output string from required lines */
for (i = 0; i < line_ticker->max_lines; i++)
{
size_t offset = i + line_offset;
size_t line_index = 0;
bool line_valid = true;
if (offset < lines->size)
line_index = offset;
else if (offset > lines->size)
line_index = (offset - 1) - lines->size;
else
line_valid = false;
if (line_valid)
strlcat(line_ticker->s, lines->elems[line_index].data, line_ticker->len);
if (i < line_ticker->max_lines - 1)
strlcat(line_ticker->s, "\n", line_ticker->len);
}
success = true;
is_active = true;
ticker_is_active = true;
end:
if (wrapped_str)
{
free(wrapped_str);
wrapped_str = NULL;
}
if (lines)
{
string_list_free(lines);
lines = NULL;
}
if (!success)
if (line_ticker->len > 0)
line_ticker->s[0] = '\0';
return is_active;
}
bool menu_animation_is_active(void)
{
return animation_is_active || ticker_is_active;

View File

@ -126,6 +126,17 @@ typedef struct menu_animation_ctx_ticker
const char *spacer;
} menu_animation_ctx_ticker_t;
typedef struct menu_animation_ctx_line_ticker
{
size_t line_width;
size_t max_lines;
uint64_t idx;
enum menu_animation_ticker_type type_enum;
char *s;
size_t len;
const char *str;
} menu_animation_ctx_line_ticker_t;
typedef float menu_timer_t;
typedef struct menu_timer_ctx_entry
@ -149,6 +160,8 @@ bool menu_animation_update(void);
bool menu_animation_ticker(menu_animation_ctx_ticker_t *ticker);
bool menu_animation_line_ticker(menu_animation_ctx_line_ticker_t *line_ticker);
float menu_animation_get_delta_time(void);
bool menu_animation_is_active(void);

View File

@ -78,19 +78,8 @@ bool menu_shader_manager_init(void)
if (is_preset)
{
int64_t length = 0;
uint8_t *ret_buf = NULL;
if (path_is_valid(path_shader))
{
if (filestream_read_file(path_shader, (void**)&ret_buf, &length))
{
if (length >= 0)
if ((conf = config_file_new_from_string((const char*)ret_buf)))
conf->path = strdup(path_shader);
free((void*)ret_buf);
}
}
conf = config_file_new_from_path_to_string(path_shader);
new_path = strdup(path_shader);
}
@ -118,16 +107,7 @@ bool menu_shader_manager_init(void)
"menu.glslp", sizeof(preset_path));
if (path_is_valid(preset_path))
{
int64_t length = 0;
uint8_t *ret_buf = NULL;
if (filestream_read_file(preset_path, (void**)&ret_buf, &length))
{
if (length >= 0)
conf = config_file_new_from_string((const char*)ret_buf);
free((void*)ret_buf);
}
}
conf = config_file_new_from_path_to_string(preset_path);
#endif
#ifdef HAVE_CG
@ -137,16 +117,7 @@ bool menu_shader_manager_init(void)
"menu.cgp", sizeof(preset_path));
if (path_is_valid(preset_path))
{
int64_t length = 0;
uint8_t *ret_buf = NULL;
if (filestream_read_file(preset_path, (void**)&ret_buf, &length))
{
if (length >= 0)
conf = config_file_new_from_string((const char*)ret_buf);
free((void*)ret_buf);
}
}
conf = config_file_new_from_path_to_string(preset_path);
}
#endif
@ -157,16 +128,7 @@ bool menu_shader_manager_init(void)
"menu.slangp", sizeof(preset_path));
if (path_is_valid(preset_path))
{
int64_t length = 0;
uint8_t *ret_buf = NULL;
if (filestream_read_file(preset_path, (void**)&ret_buf, &length))
{
if (length >= 0)
conf = config_file_new_from_string((const char*)ret_buf);
free((void*)ret_buf);
}
}
conf = config_file_new_from_path_to_string(preset_path);
}
#endif
@ -202,8 +164,6 @@ bool menu_shader_manager_init(void)
bool menu_shader_manager_set_preset(void *data,
enum rarch_shader_type type, const char *preset_path)
{
int64_t length = 0;
uint8_t *ret_buf = NULL;
struct video_shader *shader = (struct video_shader*)data;
config_file_t *conf = NULL;
bool refresh = false;
@ -229,17 +189,9 @@ bool menu_shader_manager_set_preset(void *data,
* Used when a preset is directly loaded.
* No point in updating when the Preset was
* created from the menu itself. */
if (filestream_read_file(preset_path, (void**)&ret_buf, &length))
{
if (length >= 0)
conf = config_file_new_from_string((const char*)ret_buf);
free((void*)ret_buf);
}
if (!conf)
if (!(conf = config_file_new_from_path_to_string(preset_path)))
return false;
conf->path = strdup(preset_path);
RARCH_LOG("Setting Menu shader: %s.\n", preset_path);
if (video_shader_read_conf_preset(conf, shader))

View File

@ -18,6 +18,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <libretro.h>
#include <boolean.h>
@ -1843,21 +1844,18 @@ static bool playlist_read_file(
/* Detect format of playlist */
{
char test_char = 0;
int test_char;
/* Read file until we find the first non-whitespace
/* Read file until we find the first printable non-whitespace
* ASCII character */
while ((test_char <= 0x20) || (test_char >= 0x7F))
do
{
test_char = filestream_getc(file);
/* Sanity check:
* - If filestream_getc() returns 0, stream is invalid
* - If filestream_getc() returns EOF, then no non-whitespace
* ASCII characters were found */
if ((test_char == 0) || (test_char == EOF))
if (test_char == EOF) /* read error or end of file */
goto end;
}
while (!isgraph(test_char) || test_char > 0x7F);
if (test_char == '{')
{
@ -1989,7 +1987,7 @@ static bool playlist_read_file(
}
/* Search backwards for the next two newlines */
while(metadata_counter < 2)
while (metadata_counter < 2)
{
filestream_seek(file, -2, SEEK_CUR);
if (filestream_error(file))

View File

@ -800,9 +800,9 @@ static bool ffmpeg_init_config(struct ff_config_param *params,
if (!config)
return true;
params->conf = config_file_new(config);
RARCH_LOG("[FFmpeg] Loading FFmpeg config \"%s\".\n", config);
if (!params->conf)
if (!(params->conf = config_file_new_from_path_to_string(config)))
{
RARCH_ERR("[FFmpeg] Failed to load FFmpeg config \"%s\".\n", config);
return false;

View File

@ -2072,22 +2072,9 @@ static core_option_manager_t *core_option_manager_new_vars(const char *conf_path
return NULL;
if (!string_is_empty(conf_path))
{
int64_t length = 0;
uint8_t *ret_buf = NULL;
if (filestream_read_file(conf_path, (void**)&ret_buf, &length))
{
if (length >= 0)
if ((opt->conf = config_file_new_from_string((const char*)ret_buf)))
opt->conf->path = strdup(conf_path);
free((void*)ret_buf);
}
}
if (!opt->conf)
if (!(opt->conf = config_file_new_alloc()))
goto error;
if (!(opt->conf = config_file_new_from_path_to_string(conf_path)))
if (!(opt->conf = config_file_new_alloc()))
goto error;
strlcpy(opt->conf_path, conf_path, sizeof(opt->conf_path));
@ -2138,22 +2125,9 @@ static core_option_manager_t *core_option_manager_new(const char *conf_path,
return NULL;
if (!string_is_empty(conf_path))
{
int64_t length = 0;
uint8_t *ret_buf = NULL;
if (filestream_read_file(conf_path, (void**)&ret_buf, &length))
{
if (length >= 0)
if ((opt->conf = config_file_new_from_string((const char*)ret_buf)))
opt->conf->path = strdup(conf_path);
free((void*)ret_buf);
}
}
if (!opt->conf)
if (!(opt->conf = config_file_new_alloc()))
goto error;
if (!(opt->conf = config_file_new_from_path_to_string(conf_path)))
if (!(opt->conf = config_file_new_alloc()))
goto error;
strlcpy(opt->conf_path, conf_path, sizeof(opt->conf_path));
@ -6736,7 +6710,7 @@ static void input_overlay_free(input_overlay_t *ol)
}
/* task_data = overlay_task_data_t* */
void input_overlay_loaded(retro_task_t *task,
static void input_overlay_loaded(retro_task_t *task,
void *task_data, void *user_data, const char *err)
{
size_t i;

View File

@ -360,22 +360,8 @@ static bool input_autoconfigure_joypad_from_conf_dir(
for (i = 0; i < list->size; i++)
{
int res;
int64_t length = 0;
uint8_t *ret_buf = NULL;
config_file_t *conf = NULL;
config_file_t *conf = config_file_new_from_path_to_string(list->elems[i].data);
if (!filestream_read_file(list->elems[i].data, (void**)&ret_buf, &length))
continue;
if (length < 0)
{
free((void*)ret_buf);
continue;
}
conf = config_file_new_from_string((const char*)ret_buf);
free((void*)ret_buf);
if (!conf)
continue;

View File

@ -1693,6 +1693,11 @@ bool task_push_load_content_from_playlist_from_menu(
/* Load core */
#ifdef HAVE_DYNAMIC
command_event(CMD_EVENT_LOAD_CORE, NULL);
#ifdef HAVE_COCOATOUCH
// this seems to needed for iOS for some reason to show the quick menu after the menu is shown
menu_entries_flush_stack(NULL, MENU_SETTINGS);
menu_driver_ctl(RARCH_MENU_CTL_SET_PENDING_QUICK_MENU, NULL);
#endif
#else
rarch_ctl(RARCH_CTL_SET_SHUTDOWN, NULL);
rarch_menu_running_finished(true);

View File

@ -735,8 +735,6 @@ bool task_push_overlay_load_default(
void *user_data)
{
task_finder_data_t find_data;
int64_t length = 0;
uint8_t *ret_buf = NULL;
retro_task_t *t = NULL;
config_file_t *conf = NULL;
overlay_loader_t *loader = NULL;
@ -756,14 +754,7 @@ bool task_push_overlay_load_default(
if (!loader)
return false;
if (filestream_read_file(overlay_path, (void**)&ret_buf, &length))
{
if (length >= 0)
conf = config_file_new_from_string((const char*)ret_buf);
free((void*)ret_buf);
}
if (!conf)
if (!(conf = config_file_new_from_path_to_string(overlay_path)))
{
free(loader);
return false;

View File

@ -133,9 +133,7 @@ void CoreOptionsDialog::onSaveGameSpecificOptions()
return;
}
conf = config_file_new(game_path);
if (!conf)
if (!(conf = config_file_new_from_path_to_string(game_path)))
{
if (!(conf = config_file_new_alloc()))
{