From 57ae359e6247aee97633bb38807856fdb204f956 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 28 Jun 2015 17:21:32 +0200 Subject: [PATCH] Builtin image viewer should now work --- command_event.c | 3 +++ command_event.h | 1 + configuration.c | 16 ++++++----- configuration.h | 7 +++-- menu/cbs/menu_cbs_deferred_push.c | 44 ++++++++++++++++++++++--------- menu/cbs/menu_cbs_get_value.c | 17 ++++++++++++ menu/cbs/menu_cbs_left.c | 1 + menu/cbs/menu_cbs_ok.c | 24 +++++++++++++++++ menu/cbs/menu_cbs_right.c | 1 + menu/intl/menu_hash_us.c | 4 +++ menu/menu.c | 2 +- menu/menu.h | 1 + menu/menu_displaylist.c | 18 ++++++++----- menu/menu_hash.h | 3 +++ menu/menu_setting.c | 15 ++++++++++- retroarch.c | 30 ++++++++++++++++----- retroarch.h | 1 + 17 files changed, 150 insertions(+), 38 deletions(-) diff --git a/command_event.c b/command_event.c index 143fd67b57..51c2a7f32a 100644 --- a/command_event.c +++ b/command_event.c @@ -1011,6 +1011,9 @@ bool event_command(enum event_command cmd) rarch_main_set_state(RARCH_ACTION_STATE_LOAD_CONTENT_FFMPEG); break; #endif + case EVENT_CMD_LOAD_CONTENT_IMAGEVIEWER: + rarch_main_set_state(RARCH_ACTION_STATE_LOAD_CONTENT_IMAGEVIEWER); + break; case EVENT_CMD_LOAD_CONTENT: #ifdef HAVE_DYNAMIC event_command(EVENT_CMD_LOAD_CONTENT_PERSIST); diff --git a/command_event.h b/command_event.h index ecf5506b1c..535746490b 100644 --- a/command_event.h +++ b/command_event.h @@ -33,6 +33,7 @@ enum event_command #ifdef HAVE_FFMPEG EVENT_CMD_LOAD_CONTENT_FFMPEG, #endif + EVENT_CMD_LOAD_CONTENT_IMAGEVIEWER, /* Loads core. */ EVENT_CMD_LOAD_CORE_DEINIT, EVENT_CMD_LOAD_CORE, diff --git a/configuration.c b/configuration.c index 3710a62a71..5304e469c1 100644 --- a/configuration.c +++ b/configuration.c @@ -449,8 +449,11 @@ static void config_set_defaults(void) settings->load_dummy_on_core_shutdown = load_dummy_on_core_shutdown; #ifdef HAVE_FFMPEG - settings->mediaplayer.builtin_enable = true; + settings->multimedia.builtin_mediaplayer_enable = true; +#else + settings->multimedia.builtin_mediaplayer_enable = false; #endif + settings->multimedia.builtin_imageviewer_enable = true; settings->video.scale = scale; settings->video.fullscreen = global->force_fullscreen ? true : fullscreen; settings->video.windowed_fullscreen = windowed_fullscreen; @@ -1442,9 +1445,8 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_BOOL_BASE(conf, settings, ui.suspend_screensaver_enable, "suspend_screensaver_enable"); CONFIG_GET_BOOL_BASE(conf, settings, fps_show, "fps_show"); CONFIG_GET_BOOL_BASE(conf, settings, load_dummy_on_core_shutdown, "load_dummy_on_core_shutdown"); -#ifdef HAVE_FFMPEG - CONFIG_GET_BOOL_BASE(conf, settings, mediaplayer.builtin_enable, "builtin_mediaplayer_enable"); -#endif + CONFIG_GET_BOOL_BASE(conf, settings, multimedia.builtin_mediaplayer_enable, "builtin_mediaplayer_enable"); + CONFIG_GET_BOOL_BASE(conf, settings, multimedia.builtin_imageviewer_enable, "builtin_imageviewer_enable"); config_get_path(conf, "libretro_info_path", settings->libretro_info_path, sizeof(settings->libretro_info_path)); @@ -2307,10 +2309,10 @@ bool config_save_file(const char *path) settings->input.input_descriptor_hide_unbound); config_set_bool(conf, "load_dummy_on_core_shutdown", settings->load_dummy_on_core_shutdown); -#ifdef HAVE_FFMPEG config_set_bool(conf, "builtin_mediaplayer_enable", - settings->mediaplayer.builtin_enable); -#endif + settings->multimedia.builtin_mediaplayer_enable); + config_set_bool(conf, "builtin_imageviewer_enable", + settings->multimedia.builtin_imageviewer_enable); config_set_bool(conf, "fps_show", settings->fps_show); config_set_bool(conf, "ui_menubar_enable", settings->ui.menubar_enable); config_set_path(conf, "libretro_path", settings->libretro); diff --git a/configuration.h b/configuration.h index 0e421bb961..24409aae58 100644 --- a/configuration.h +++ b/configuration.h @@ -266,12 +266,11 @@ typedef struct settings bool set_supports_no_game_enable; } core; -#ifdef HAVE_FFMPEG struct { - bool builtin_enable; - } mediaplayer; -#endif + bool builtin_mediaplayer_enable; + bool builtin_imageviewer_enable; + } multimedia; int state_slot; diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 759319adfb..e0bb71b886 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -444,15 +444,25 @@ static int deferred_push_detect_core_list(menu_displaylist_info_t *info) (void)settings; -#ifdef HAVE_FFMPEG - if (settings->mediaplayer.builtin_enable) + if (settings->multimedia.builtin_mediaplayer_enable || + settings->multimedia.builtin_imageviewer_enable) { struct retro_system_info sysinfo = {0}; - libretro_ffmpeg_retro_get_system_info(&sysinfo); - strlcat(info->exts, "|", sizeof(info->exts)); - strlcat(info->exts, sysinfo.valid_extensions, sizeof(info->exts)); - } +#ifdef HAVE_FFMPEG + if (settings->multimedia.builtin_mediaplayer_enable) + { + libretro_ffmpeg_retro_get_system_info(&sysinfo); + strlcat(info->exts, "|", sizeof(info->exts)); + strlcat(info->exts, sysinfo.valid_extensions, sizeof(info->exts)); + } + if (settings->multimedia.builtin_imageviewer_enable) + { + libretro_imageviewer_retro_get_system_info(&sysinfo); + strlcat(info->exts, "|", sizeof(info->exts)); + strlcat(info->exts, sysinfo.valid_extensions, sizeof(info->exts)); + } #endif + } return menu_displaylist_push_list(info, DISPLAYLIST_CORES_DETECTED); } @@ -478,15 +488,25 @@ static int deferred_push_default(menu_displaylist_info_t *info) (void)settings; -#ifdef HAVE_FFMPEG - if (settings->mediaplayer.builtin_enable) + if (settings->multimedia.builtin_mediaplayer_enable || + settings->multimedia.builtin_imageviewer_enable) { struct retro_system_info sysinfo = {0}; - libretro_ffmpeg_retro_get_system_info(&sysinfo); - strlcat(info->exts, "|", sizeof(info->exts)); - strlcat(info->exts, sysinfo.valid_extensions, sizeof(info->exts)); - } +#ifdef HAVE_FFMPEG + if (settings->multimedia.builtin_mediaplayer_enable) + { + libretro_ffmpeg_retro_get_system_info(&sysinfo); + strlcat(info->exts, "|", sizeof(info->exts)); + strlcat(info->exts, sysinfo.valid_extensions, sizeof(info->exts)); + } #endif + if (settings->multimedia.builtin_imageviewer_enable) + { + libretro_imageviewer_retro_get_system_info(&sysinfo); + strlcat(info->exts, "|", sizeof(info->exts)); + strlcat(info->exts, sysinfo.valid_extensions, sizeof(info->exts)); + } + } return menu_displaylist_push_list(info, DISPLAYLIST_DEFAULT); } diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 9d5a3c565c..6849d4559b 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -633,6 +633,19 @@ static void menu_action_setting_disp_set_label_menu_file_image( path, "(IMG)", s2, len2); } +static void menu_action_setting_disp_set_label_menu_file_imageviewer( + file_list_t* list, + unsigned *w, unsigned type, unsigned i, + const char *label, + char *s, size_t len, + const char *entry_label, + const char *path, + char *s2, size_t len2) +{ + menu_action_setting_generic_disp_set_label(w, s, len, + path, "(IMAGE)", s2, len2); +} + static void menu_action_setting_disp_set_label_movie( file_list_t* list, unsigned *w, unsigned type, unsigned i, @@ -1005,6 +1018,10 @@ static int menu_cbs_init_bind_get_string_representation_compare_type( cbs->action_get_value = menu_action_setting_disp_set_label_menu_file_image; break; + case MENU_FILE_IMAGEVIEWER: + cbs->action_get_value = + menu_action_setting_disp_set_label_menu_file_imageviewer; + break; case MENU_FILE_USE_DIRECTORY: cbs->action_get_value = menu_action_setting_disp_set_label_menu_file_use_directory; diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 855ed56505..a9d1cffb4b 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -455,6 +455,7 @@ static int menu_cbs_init_bind_left_compare_type(menu_file_list_cbs_t *cbs, case MENU_FILE_REMAP: case MENU_FILE_MOVIE: case MENU_FILE_MUSIC: + case MENU_FILE_IMAGEVIEWER: case MENU_FILE_PLAYLIST_COLLECTION: case MENU_SETTING_GROUP: switch (menu_label_hash) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 4e9d368c91..d7d8d73d19 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1127,6 +1127,27 @@ static int action_ok_file_load_ffmpeg(const char *path, } #endif +static int action_ok_file_load_imageviewer(const char *path, + const char *label, unsigned type, size_t idx, size_t entry_idx) +{ + const char *menu_path = NULL; + global_t *global = global_get_ptr(); + menu_list_t *menu_list = menu_list_get_ptr(); + + if (!menu_list) + return -1; + + menu_list_get_last(menu_list->menu_stack, + &menu_path, NULL, NULL, NULL); + + fill_pathname_join(global->fullpath, menu_path, path, + sizeof(global->fullpath)); + + menu_common_load_content(true, CORE_TYPE_IMAGEVIEWER); + + return 0; +} + static int action_ok_file_load(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { @@ -1917,6 +1938,9 @@ static int menu_cbs_init_bind_ok_compare_type(menu_file_list_cbs_t *cbs, cbs->action_ok = action_ok_file_load_ffmpeg; #endif break; + case MENU_FILE_IMAGEVIEWER: + cbs->action_ok = action_ok_file_load_imageviewer; + break; case MENU_SETTINGS: case MENU_SETTING_GROUP: case MENU_SETTING_SUBGROUP: diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 4df547a22a..50b4d9af65 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -386,6 +386,7 @@ static int menu_cbs_init_bind_right_compare_type(menu_file_list_cbs_t *cbs, case MENU_FILE_REMAP: case MENU_FILE_MOVIE: case MENU_FILE_MUSIC: + case MENU_FILE_IMAGEVIEWER: case MENU_FILE_PLAYLIST_COLLECTION: case MENU_SETTING_GROUP: switch (menu_label_hash) diff --git a/menu/intl/menu_hash_us.c b/menu/intl/menu_hash_us.c index c5d22be986..97a087e6a5 100644 --- a/menu/intl/menu_hash_us.c +++ b/menu/intl/menu_hash_us.c @@ -574,6 +574,8 @@ static const char *menu_hash_to_str_us_label(uint32_t hash) return "update_glsl_shaders"; case MENU_LABEL_SCREEN_RESOLUTION: return "screen_resolution"; + case MENU_LABEL_USE_BUILTIN_IMAGE_VIEWER: + return "use_builtin_image_viewer"; default: break; } @@ -1404,6 +1406,8 @@ const char *menu_hash_to_str_us(uint32_t hash) return "Frame Throttle Settings"; case MENU_VALUE_SEARCH: return "Search:"; + case MENU_LABEL_VALUE_USE_BUILTIN_IMAGE_VIEWER: + return "Use Builtin Image Viewer"; default: break; } diff --git a/menu/menu.c b/menu/menu.c index cd00b2fa02..636aee45ae 100644 --- a/menu/menu.c +++ b/menu/menu.c @@ -168,7 +168,7 @@ void menu_common_load_content(bool persist, enum rarch_core_type type) break; #endif case CORE_TYPE_IMAGEVIEWER: - /* TODO/FIXME */ + event_command(EVENT_CMD_LOAD_CONTENT_IMAGEVIEWER); break; } diff --git a/menu/menu.h b/menu/menu.h index f895a7eec1..c41021436b 100644 --- a/menu/menu.h +++ b/menu/menu.h @@ -81,6 +81,7 @@ typedef enum MENU_FILE_CARCHIVE, MENU_FILE_IN_CARCHIVE, MENU_FILE_IMAGE, + MENU_FILE_IMAGEVIEWER, MENU_FILE_REMAP, MENU_FILE_DOWNLOAD_CORE, MENU_FILE_DOWNLOAD_CORE_INFO, diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 4ddaa8a670..01b660ba16 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -1980,24 +1980,30 @@ static int menu_displaylist_parse_generic(menu_displaylist_info_t *info, bool *n break; } -#ifdef HAVE_FFMPEG - if (settings->mediaplayer.builtin_enable) + if (settings->multimedia.builtin_mediaplayer_enable || + settings->multimedia.builtin_imageviewer_enable) { switch (rarch_path_is_media_type(path)) { case RARCH_CONTENT_MOVIE: - file_type = MENU_FILE_MOVIE; +#ifdef HAVE_FFMPEG + if (settings->multimedia.builtin_mediaplayer_enable) + file_type = MENU_FILE_MOVIE; +#endif break; case RARCH_CONTENT_MUSIC: - file_type = MENU_FILE_MUSIC; +#ifdef HAVE_FFMPEG + if (settings->multimedia.builtin_mediaplayer_enable) + file_type = MENU_FILE_MUSIC; +#endif break; case RARCH_CONTENT_IMAGE: - file_type = MENU_FILE_IMAGE; + if (settings->multimedia.builtin_imageviewer_enable) + file_type = MENU_FILE_IMAGEVIEWER; default: break; } } -#endif menu_list_push(info->list, path, label, file_type, 0, 0); diff --git a/menu/menu_hash.h b/menu/menu_hash.h index 888ad476e7..12f535bda3 100644 --- a/menu/menu_hash.h +++ b/menu/menu_hash.h @@ -944,6 +944,9 @@ extern "C" { #define MENU_LABEL_VALUE_INPUT_USER_BINDS 0x75fda711U +#define MENU_LABEL_USE_BUILTIN_IMAGE_VIEWER 0x5203b5bbU +#define MENU_LABEL_VALUE_USE_BUILTIN_IMAGE_VIEWER 0x1ab45d3eU + const char *menu_hash_to_str_de(uint32_t hash); int menu_hash_get_help_de(uint32_t hash, char *s, size_t len); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index baaff9d954..d51709098b 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -4862,7 +4862,7 @@ static bool setting_append_list_multimedia_options( #ifdef HAVE_FFMPEG CONFIG_BOOL( - settings->mediaplayer.builtin_enable, + settings->multimedia.builtin_mediaplayer_enable, menu_hash_to_str(MENU_LABEL_USE_BUILTIN_PLAYER), menu_hash_to_str(MENU_LABEL_VALUE_USE_BUILTIN_PLAYER), true, @@ -4875,6 +4875,19 @@ static bool setting_append_list_multimedia_options( general_read_handler); #endif + CONFIG_BOOL( + settings->multimedia.builtin_imageviewer_enable, + menu_hash_to_str(MENU_LABEL_USE_BUILTIN_IMAGE_VIEWER), + menu_hash_to_str(MENU_LABEL_VALUE_USE_BUILTIN_IMAGE_VIEWER), + true, + menu_hash_to_str(MENU_VALUE_OFF), + menu_hash_to_str(MENU_VALUE_ON), + group_info.name, + subgroup_info.name, + parent_group, + general_write_handler, + general_read_handler); + END_SUB_GROUP(list, list_info, parent_group); END_GROUP(list, list_info, parent_group); diff --git a/retroarch.c b/retroarch.c index 44bc14d855..bef132a932 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1204,29 +1204,36 @@ int rarch_main_init(int argc, char *argv[]) validate_cpu_features(); config_load(); -#ifdef HAVE_FFMPEG { settings_t *settings = config_get_ptr(); - if (settings && settings->mediaplayer.builtin_enable) + if (settings && (settings->multimedia.builtin_mediaplayer_enable || + settings->multimedia.builtin_imageviewer_enable)) { switch (rarch_path_is_media_type(global->fullpath)) { case RARCH_CONTENT_MOVIE: case RARCH_CONTENT_MUSIC: - global->has_set_libretro = false; - global->core_type = CORE_TYPE_FFMPEG; + if (settings->multimedia.builtin_mediaplayer_enable) + { +#ifdef HAVE_FFMPEG + global->has_set_libretro = false; + global->core_type = CORE_TYPE_FFMPEG; +#endif + } break; case RARCH_CONTENT_IMAGE: - global->has_set_libretro = false; - global->core_type = CORE_TYPE_IMAGEVIEWER; + if (settings->multimedia.builtin_imageviewer_enable) + { + global->has_set_libretro = false; + global->core_type = CORE_TYPE_IMAGEVIEWER; + } break; default: break; } } } -#endif init_libretro_sym(global->core_type); rarch_system_info_init(); @@ -1397,6 +1404,15 @@ void rarch_main_set_state(unsigned cmd) driver->frontend_ctx->content_loaded(); break; #endif + case RARCH_ACTION_STATE_LOAD_CONTENT_IMAGEVIEWER: +#ifdef HAVE_MENU + /* If content loading fails, we go back to menu. */ + if (!menu_load_content(CORE_TYPE_IMAGEVIEWER)) + rarch_main_set_state(RARCH_ACTION_STATE_MENU_RUNNING); +#endif + if (driver->frontend_ctx && driver->frontend_ctx->content_loaded) + driver->frontend_ctx->content_loaded(); + break; case RARCH_ACTION_STATE_MENU_RUNNING_FINISHED: #ifdef HAVE_MENU menu_setting_apply_deferred(); diff --git a/retroarch.h b/retroarch.h index 783e297777..f954795693 100644 --- a/retroarch.h +++ b/retroarch.h @@ -34,6 +34,7 @@ enum action_state #ifdef HAVE_FFMPEG RARCH_ACTION_STATE_LOAD_CONTENT_FFMPEG, #endif + RARCH_ACTION_STATE_LOAD_CONTENT_IMAGEVIEWER, RARCH_ACTION_STATE_MENU_RUNNING, RARCH_ACTION_STATE_MENU_RUNNING_FINISHED, RARCH_ACTION_STATE_QUIT,