diff --git a/Makefile.common b/Makefile.common index 01bae782ee5a..e9e2afdd225d 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1295,6 +1295,11 @@ ifeq ($(HAVE_WAYLAND), 1) endif +ifeq ($(HAVE_GLIB), 1) + DEF_FLAGS += $(GLIB_CFLAGS) + LIBS += $(GLIB_LIBS) +endif + # XML OBJ += \ $(LIBRETRO_COMM_DIR)/formats/xml/rxml.o \ diff --git a/input/common/wayland_common.c b/input/common/wayland_common.c index 9f5d27373580..1f4dbb7fb48e 100644 --- a/input/common/wayland_common.c +++ b/input/common/wayland_common.c @@ -18,6 +18,17 @@ #define _GNU_SOURCE /* See feature_test_macros(7) */ #endif +#ifdef HAVE_CONFIG_H +#include "../config.h" +#endif + +#ifdef HAVE_GLIB +#include +#endif + +#include "../../tasks/task_content.h" +#include "../../paths.h" + #include #include @@ -1037,9 +1048,8 @@ static void wl_data_device_handle_drop(void *data, /* TODO/FIXME: Convert from file:// URI, Implement file loading * Drag and Drop */ -#if 0 - if (wayland_load_content_from_drop(g_filename_from_uri(line, NULL, NULL))) - RARCH_WARN("----- wayland_load_content_from_drop success\n"); +#ifdef HAVE_GLIB + path_set(RARCH_PATH_NEXT_CONTENT, g_filename_from_uri(line, NULL, NULL)); #endif } diff --git a/paths.h b/paths.h index cd223641db06..fc0d0e4abf64 100644 --- a/paths.h +++ b/paths.h @@ -50,6 +50,7 @@ enum rarch_path_type RARCH_PATH_NAMES, RARCH_PATH_CONFIG, RARCH_PATH_CONTENT, + RARCH_PATH_NEXT_CONTENT, RARCH_PATH_CONFIG_APPEND, RARCH_PATH_CONFIG_OVERRIDE, RARCH_PATH_CORE_OPTIONS, diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 2c9d020b419f..81db6827a1af 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -265,6 +265,7 @@ else check_lib '' AL -lopenal alcOpenDevice fi +check_pkgconf GLIB glib-2.0 2.78.0 check_pkgconf RSOUND rsound 1.1 check_pkgconf ROAR libroar 1.0.12 check_val '' JACK -ljack '' jack 0.120.1 '' false diff --git a/qb/config.params.sh b/qb/config.params.sh index 963a755ec395..4bf2c2ff0b6b 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -105,6 +105,7 @@ HAVE_WAYLAND=auto # Wayland support HAVE_LIBDECOR=auto # libdecor support C89_WAYLAND=no CXX_WAYLAND=no +HAVE_GLIB=auto # GLib support HAVE_DYNAMIC_EGL=no # Dynamic library EGL support HAVE_EGL=auto # EGL context support HAVE_VG=auto # OpenVG support diff --git a/retroarch.c b/retroarch.c index a7e5f5299fad..7425163ad89c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -315,6 +315,7 @@ struct rarch_state char launch_arguments[4096]; char path_default_shader_preset[PATH_MAX_LENGTH]; char path_content[PATH_MAX_LENGTH]; + char path_next_content[PATH_MAX_LENGTH]; char path_libretro[PATH_MAX_LENGTH]; char path_config_file[PATH_MAX_LENGTH]; char path_config_append_file[PATH_MAX_LENGTH]; @@ -2400,6 +2401,8 @@ char *path_get_ptr(enum rarch_path_type type) { case RARCH_PATH_CONTENT: return p_rarch->path_content; + case RARCH_PATH_NEXT_CONTENT: + return p_rarch->path_next_content; case RARCH_PATH_DEFAULT_SHADER_PRESET: return p_rarch->path_default_shader_preset; case RARCH_PATH_BASENAME: @@ -2440,6 +2443,8 @@ const char *path_get(enum rarch_path_type type) { case RARCH_PATH_CONTENT: return p_rarch->path_content; + case RARCH_PATH_NEXT_CONTENT: + return p_rarch->path_next_content; case RARCH_PATH_DEFAULT_SHADER_PRESET: return p_rarch->path_default_shader_preset; case RARCH_PATH_CORE_OPTIONS: @@ -2480,6 +2485,8 @@ size_t path_get_realsize(enum rarch_path_type type) { case RARCH_PATH_CONTENT: return sizeof(p_rarch->path_content); + case RARCH_PATH_NEXT_CONTENT: + return sizeof(p_rarch->path_next_content); case RARCH_PATH_DEFAULT_SHADER_PRESET: return sizeof(p_rarch->path_default_shader_preset); case RARCH_PATH_CORE_OPTIONS: @@ -2548,6 +2555,10 @@ bool path_set(enum rarch_path_type type, const char *path) strlcpy(p_rarch->path_content, path, sizeof(p_rarch->path_content)); break; + case RARCH_PATH_NEXT_CONTENT: + strlcpy(p_rarch->path_next_content, path, + sizeof(p_rarch->path_next_content)); + break; case RARCH_PATH_NONE: break; case RARCH_PATH_BASENAME: @@ -2595,6 +2606,10 @@ bool path_is_empty(enum rarch_path_type type) if (string_is_empty(p_rarch->path_content)) return true; break; + case RARCH_PATH_NEXT_CONTENT: + if (string_is_empty(p_rarch->path_next_content)) + return true; + break; case RARCH_PATH_CORE: if (string_is_empty(p_rarch->path_libretro)) return true; @@ -2631,6 +2646,9 @@ void path_clear(enum rarch_path_type type) case RARCH_PATH_CONTENT: *p_rarch->path_content = '\0'; break; + case RARCH_PATH_NEXT_CONTENT: + *p_rarch->path_next_content = '\0'; + break; case RARCH_PATH_CORE_OPTIONS: *p_rarch->path_core_options_file = '\0'; break; @@ -2660,6 +2678,7 @@ void path_clear(enum rarch_path_type type) static void path_clear_all(void) { path_clear(RARCH_PATH_CONTENT); + path_clear(RARCH_PATH_NEXT_CONTENT); path_clear(RARCH_PATH_CONFIG); path_clear(RARCH_PATH_CONFIG_APPEND); path_clear(RARCH_PATH_CONFIG_OVERRIDE); @@ -5785,6 +5804,68 @@ void main_exit(void *args) #endif } + +static bool load_next_content(const char* path) +{ + core_info_list_t *core_info_list = NULL; + core_info_get_list(&core_info_list); + if (core_info_list) + { + size_t list_size; + content_ctx_info_t content_info = { 0 }; + const core_info_t *core_info = NULL; + core_info_list_get_supported_cores(core_info_list, + (const char*)path, &core_info, &list_size); + if (list_size) + { + path_set(RARCH_PATH_CONTENT, path); + + if (!path_is_empty(RARCH_PATH_CONTENT)) + { + unsigned i; + core_info_t *current_core = NULL; + core_info_get_current_core(¤t_core); + + /*we already have path for libretro core */ + for (i = 0; i < list_size; i++) + { + const core_info_t *info = (const core_info_t*)&core_info[i]; + + if (string_is_equal(path_get(RARCH_PATH_CORE), info->path)) + { + /* Our previous core supports the current rom */ + task_push_load_content_with_current_core_from_companion_ui( + NULL, + &content_info, + CORE_TYPE_PLAIN, + NULL, NULL); + return true; + } + } + } + } + + if (list_size >= 1) + { + /*pick core that only exists and is bound to work. Ish. */ + const core_info_t *info = (const core_info_t*)&core_info[0]; + + if (info) + { + task_push_load_content_with_new_core_from_companion_ui( + info->path, NULL, NULL, NULL, NULL, &content_info, NULL, NULL); + return true; + } + } + else + { + RARCH_WARN("There are no core to open %s\n", path); + } + } + + return false; +} + /** * main_entry: * @@ -5888,6 +5969,11 @@ int rarch_main(int argc, char *argv[], void *data) { int ret; bool app_exit = false; + + if (!path_is_empty(RARCH_PATH_NEXT_CONTENT) && !string_is_equal(path_get(RARCH_PATH_CONTENT), path_get(RARCH_PATH_NEXT_CONTENT))) { + load_next_content(path_get(RARCH_PATH_NEXT_CONTENT)); + } + #ifdef HAVE_QT ui_companion_qt.application->process_events(); #endif