From 9505602675172c7126687d8e695a984697d13844 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 27 Nov 2016 19:25:38 -0500 Subject: [PATCH 1/3] Prevent loading content when firmware is missing --- core_info.c | 10 ++++++++-- intl/msg_hash_us.h | 2 ++ menu/cbs/menu_cbs_ok.c | 8 ++++++-- msg_hash.h | 1 + runloop.c | 28 ++++++++++++++++++++++++++++ runloop.h | 4 ++++ 6 files changed, 49 insertions(+), 4 deletions(-) diff --git a/core_info.c b/core_info.c index 4dc70f6d69..b2e71714e0 100644 --- a/core_info.c +++ b/core_info.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #ifdef HAVE_CONFIG_H #include "config.h" @@ -410,7 +412,7 @@ static bool core_info_list_update_missing_firmware_internal( if (!info) return false; - + runloop_ctl(RUNLOOP_CTL_UNSET_MISSING_BIOS, NULL); for (i = 0; i < info->firmware_count; i++) { if (!info->firmware[i].path) @@ -419,6 +421,11 @@ static bool core_info_list_update_missing_firmware_internal( fill_pathname_join(path, systemdir, info->firmware[i].path, sizeof(path)); info->firmware[i].missing = !path_file_exists(path); + if (info->firmware[i].missing) + { + runloop_ctl(RUNLOOP_CTL_SET_MISSING_BIOS, NULL); + RARCH_WARN("Firmware missing: %s\n", info->firmware[i].path); + } } return true; @@ -522,7 +529,6 @@ bool core_info_list_update_missing_firmware(core_info_ctx_firmware_t *info) { if (!info) return false; - return core_info_list_update_missing_firmware_internal( core_info_curr_list, info->path, info->directory.system); diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 80454c295a..8240988031 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -1936,6 +1936,8 @@ MSG_HASH(MSG_LOADED_STATE_FROM_SLOT_AUTO, "Loaded state from slot #-1 (auto).") MSG_HASH(MSG_LOADING, "Loading") +MSG_HASH(MSG_FIRMWARE, + "One or more firmware files are missing") MSG_HASH(MSG_LOADING_CONTENT_FILE, "Loading content file") MSG_HASH(MSG_LOADING_HISTORY_FILE, diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index f34468abb3..abeacb5009 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -854,7 +854,12 @@ static int generic_action_ok_file_load(const char *corepath, const char *fullpat enum rarch_core_type action_type, enum content_mode_load content_enum_idx) { content_ctx_info_t content_info = {0}; - + if(runloop_ctl(RUNLOOP_CTL_IS_MISSING_BIOS, NULL)) + { + runloop_msg_queue_push(msg_hash_to_str(MSG_FIRMWARE), 200, 100, true); + RARCH_LOG(msg_hash_to_str(MSG_FIRMWARE)); + return 0; + } if (!task_push_content_load_default( corepath, fullpath, &content_info, @@ -1877,7 +1882,6 @@ static int action_ok_load_core_deferred(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { menu_handle_t *menu = NULL; - if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return menu_cbs_exit(); diff --git a/msg_hash.h b/msg_hash.h index b079fc668e..8e5477a7c0 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -155,6 +155,7 @@ enum msg_hash_enums MSG_FAILED, MSG_SUCCEEDED, MSG_LOADING, + MSG_FIRMWARE, MSG_CONNECTING_TO_PORT, MSG_CONNECTED_TO, MSG_FAILED_TO_LOAD, diff --git a/runloop.c b/runloop.c index f73e69949e..721aeed46d 100644 --- a/runloop.c +++ b/runloop.c @@ -127,6 +127,7 @@ static bool runloop_core_shutdown_initiated = false; static bool runloop_perfcnt_enable = false; static bool runloop_overrides_active = false; static bool runloop_game_options_active = false; +static bool runloop_missing_bios = false; global_t *global_get_ptr(void) { @@ -134,6 +135,18 @@ global_t *global_get_ptr(void) return &g_extern; } +void update_firmware_status() +{ + core_info_t *core_info = NULL; + settings_t *settings = config_get_ptr(); + core_info_ctx_firmware_t firmware_info; + + core_info_get_current_core(&core_info); + firmware_info.path = core_info->path; + firmware_info.directory.system = settings->directory.system; + core_info_list_update_missing_firmware(&firmware_info); +} + void runloop_msg_queue_push(const char *msg, unsigned prio, unsigned duration, bool flush) @@ -341,6 +354,14 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) break; case RUNLOOP_CTL_IS_OVERRIDES_ACTIVE: return runloop_overrides_active; + case RUNLOOP_CTL_SET_MISSING_BIOS: + runloop_missing_bios = true; + break; + case RUNLOOP_CTL_UNSET_MISSING_BIOS: + runloop_missing_bios = false; + break; + case RUNLOOP_CTL_IS_MISSING_BIOS: + return runloop_missing_bios; case RUNLOOP_CTL_SET_GAME_OPTIONS_ACTIVE: runloop_game_options_active = true; break; @@ -1109,6 +1130,13 @@ int runloop_iterate(unsigned *sleep_ms) settings_t *settings = config_get_ptr(); uint64_t current_input = menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL) ? input_menu_keys_pressed() : input_keys_pressed(); uint64_t old_input = last_input; + static char old_core[PATH_MAX_LENGTH] = ""; + + if (!string_is_equal(old_core, path_get(RARCH_PATH_CORE))) + { + update_firmware_status(); + strlcpy (old_core, path_get(RARCH_PATH_CORE), sizeof(old_core)); + } last_input = current_input; diff --git a/runloop.h b/runloop.h index a8cdb8851b..35fada6eb1 100644 --- a/runloop.h +++ b/runloop.h @@ -54,6 +54,10 @@ enum runloop_ctl_state RUNLOOP_CTL_SET_OVERRIDES_ACTIVE, RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE, + RUNLOOP_CTL_IS_MISSING_BIOS, + RUNLOOP_CTL_SET_MISSING_BIOS, + RUNLOOP_CTL_UNSET_MISSING_BIOS, + RUNLOOP_CTL_IS_GAME_OPTIONS_ACTIVE, RUNLOOP_CTL_SET_GAME_OPTIONS_ACTIVE, RUNLOOP_CTL_UNSET_GAME_OPTIONS_ACTIVE, From 8f4d6b8784853dbc88483bfdbd490ff77d0b4187 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 27 Nov 2016 19:50:41 -0500 Subject: [PATCH 2/3] only block loading when firmware is required --- core_info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core_info.c b/core_info.c index b2e71714e0..be7d191a26 100644 --- a/core_info.c +++ b/core_info.c @@ -421,7 +421,7 @@ static bool core_info_list_update_missing_firmware_internal( fill_pathname_join(path, systemdir, info->firmware[i].path, sizeof(path)); info->firmware[i].missing = !path_file_exists(path); - if (info->firmware[i].missing) + if (info->firmware[i].missing && !info->firmware[i].optional) { runloop_ctl(RUNLOOP_CTL_SET_MISSING_BIOS, NULL); RARCH_WARN("Firmware missing: %s\n", info->firmware[i].path); From 7b7a107e45dc731f95e013ffe07c1e67d2269268 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 27 Nov 2016 19:56:44 -0500 Subject: [PATCH 3/3] add english string to localization files --- intl/msg_hash_eo.h | 2 ++ intl/msg_hash_fr.h | 2 ++ intl/msg_hash_ja.h | 2 ++ intl/msg_hash_nl.h | 2 ++ intl/msg_hash_ru.h | 2 ++ 5 files changed, 10 insertions(+) diff --git a/intl/msg_hash_eo.h b/intl/msg_hash_eo.h index 3993cacca5..62fd137dae 100644 --- a/intl/msg_hash_eo.h +++ b/intl/msg_hash_eo.h @@ -1936,6 +1936,8 @@ MSG_HASH(MSG_LOADED_STATE_FROM_SLOT_AUTO, "Loaded state from slot #-1 (auto).") MSG_HASH(MSG_LOADING, "Loading") +MSG_HASH(MSG_FIRMWARE, + "One or more firmware files are missing") MSG_HASH(MSG_LOADING_CONTENT_FILE, "Loading content file") MSG_HASH(MSG_LOADING_HISTORY_FILE, diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index 7f81159d68..625dd77a9c 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -1902,6 +1902,8 @@ MSG_HASH(MSG_LOADED_STATE_FROM_SLOT_AUTO, "Chargement du savestate à partir du slot #-1 (auto).") MSG_HASH(MSG_LOADING, "Loading") +MSG_HASH(MSG_FIRMWARE, + "One or more firmware files are missing") MSG_HASH(MSG_LOADING_CONTENT_FILE, "Chargement du contenu") MSG_HASH(MSG_LOADING_HISTORY_FILE, diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index d1cd29c607..415149f4bd 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -1938,6 +1938,8 @@ MSG_HASH(MSG_LOADED_STATE_FROM_SLOT_AUTO, "スロット-1 (自動)から保存状態をロードしました。") MSG_HASH(MSG_LOADING, "ロード中") +MSG_HASH(MSG_FIRMWARE, + "One or more firmware files are missing") MSG_HASH(MSG_LOADING_CONTENT_FILE, "コンテンツをロード中") MSG_HASH(MSG_LOADING_HISTORY_FILE, diff --git a/intl/msg_hash_nl.h b/intl/msg_hash_nl.h index 3e17063c37..519801657e 100644 --- a/intl/msg_hash_nl.h +++ b/intl/msg_hash_nl.h @@ -1936,6 +1936,8 @@ MSG_HASH(MSG_LOADED_STATE_FROM_SLOT_AUTO, "Loaded state from slot #-1 (auto).") MSG_HASH(MSG_LOADING, "Loading") +MSG_HASH(MSG_FIRMWARE, + "One or more firmware files are missing") MSG_HASH(MSG_LOADING_CONTENT_FILE, "Loading content file") MSG_HASH(MSG_LOADING_HISTORY_FILE, diff --git a/intl/msg_hash_ru.h b/intl/msg_hash_ru.h index 5f8ee71c36..f88ddda2c6 100644 --- a/intl/msg_hash_ru.h +++ b/intl/msg_hash_ru.h @@ -1930,6 +1930,8 @@ MSG_HASH(MSG_LOADED_STATE_FROM_SLOT_AUTO, "Загружено сохранение из слота #-1 (auto).") MSG_HASH(MSG_LOADING, "Loading") +MSG_HASH(MSG_FIRMWARE, + "One or more firmware files are missing") MSG_HASH(MSG_LOADING_CONTENT_FILE, "Загружен файл контента") MSG_HASH(MSG_LOADING_HISTORY_FILE,