Show a dialog when firmware is missing when it is required for launching a core

This commit is contained in:
Craig Carnell authored and libretroadmin committed 2026-11-16 11:25:36 +01:00
1 parent 9b6b5f6ded
commit 881b1d41d1
23 files changed
+584 -7

No files matched your search

+1
View File
@@ -192,6 +192,7 @@ enum event_command
CMD_EVENT_MENU_FIRST_RUN_DOWNLOAD,
/* Turns the core signature checks off, after the confirm */
CMD_EVENT_CORE_SIGNATURE_CHECK_OFF,
CMD_EVENT_CORE_FIRMWARE_DOWNLOAD,
CMD_EVENT_MENU_SAVE_AS_CONFIG,
CMD_EVENT_MENU_SAVE_MAIN_CONFIG,
CMD_EVENT_MENU_SAVE_CURRENT_CONFIG,
+1
View File
@@ -2971,6 +2971,7 @@ static struct config_bool_setting *populate_settings_bool(
#else
SETTING_BOOL("core_info_cache_enable", &settings->bools.core_info_cache_enable, true, DEFAULT_CORE_INFO_CACHE_ENABLE, false);
#endif
SETTING_BOOL("core_firmware_notification_enable", &settings->bools.core_firmware_notification_enable, true, true, false);
SETTING_BOOL("core_set_supports_no_game_enable", &settings->bools.set_supports_no_game_enable, true, true, false);
#ifndef HAVE_DYNAMIC
SETTING_BOOL("always_reload_core_on_run_content", &settings->bools.always_reload_core_on_run_content, true, DEFAULT_ALWAYS_RELOAD_CORE_ON_RUN_CONTENT, false);
+1
View File
@@ -1205,6 +1205,7 @@ typedef struct settings
bool load_dummy_on_core_shutdown;
bool core_option_category_enable;
bool core_info_cache_enable;
bool core_firmware_notification_enable;
bool core_info_savestate_bypass;
#ifndef HAVE_DYNAMIC
bool always_reload_core_on_run_content;
+15 -1
View File
@@ -61,7 +61,7 @@
/* Core Info Cache START */
/*************************/
#define CORE_INFO_CACHE_VERSION "1.2"
#define CORE_INFO_CACHE_VERSION "1.3"
#define CORE_INFO_CACHE_DEFAULT_CAPACITY 8
/* TODO/FIXME: Apparently rzip compression is an issue on UWP */
@@ -351,6 +351,9 @@ static bool CCJSONObjectMemberHandler(void *context,
else if (len == sizeof("desc") - 1
&& !memcmp(pValue, "desc", sizeof("desc") - 1))
pCtx->current_string_val = &pCtx->core_info->firmware[firmware_idx].desc;
else if (len == sizeof("url") - 1
&& !memcmp(pValue, "url", sizeof("url") - 1))
pCtx->current_string_val = &pCtx->core_info->firmware[firmware_idx].url;
else if (len == sizeof("optional") - 1
&& !memcmp(pValue, "optional", sizeof("optional") - 1))
pCtx->current_entry_bool_val = &pCtx->core_info->firmware[firmware_idx].optional;
@@ -485,6 +488,7 @@ static bool CCJSONStartObjectHandler(void *context)
tmp[new_idx].path = NULL;
tmp[new_idx].desc = NULL;
tmp[new_idx].url = NULL;
tmp[new_idx].missing = false;
tmp[new_idx].optional = false;
@@ -1095,6 +1099,11 @@ static bool core_info_cache_write(const core_info_t *items, size_t count,
rjsonwriter_raw(writer, ",", 1);
rjsonwriter_raw(writer, "\n", 1);
rjsonwriter_add_spaces(writer, 10);
rjsonwriter_add_string(writer, "url");
rjsonwriter_raw(writer, ": ", 2);
rjsonwriter_add_string(writer, info->firmware[j].url);
rjsonwriter_raw(writer, ",\n", 2);
rjsonwriter_add_spaces(writer, 10);
rjsonwriter_add_string(writer, "optional");
rjsonwriter_raw(writer, ":", 1);
rjsonwriter_raw(writer, " ", 1);
@@ -1680,6 +1689,9 @@ static void core_info_resolve_firmware(
strlcpy_lit(key + _len2, "desc", sizeof(key) - _len2);
firmware[i].desc = config_take_string(conf, key);
strlcpy_lit(key + _len2, "url", sizeof(key) - _len2);
firmware[i].url = config_take_string(conf, key);
}
info->firmware_count = firmware_count;
@@ -2096,6 +2108,8 @@ static void core_info_free(core_info_t* info)
free(info->firmware[i].path);
if (info->firmware[i].desc)
free(info->firmware[i].desc);
free(info->firmware[i].url);
info->firmware[i].url = NULL;
info->firmware[i].path = NULL;
info->firmware[i].desc = NULL;
}
+1
View File
@@ -64,6 +64,7 @@ typedef struct
{
char *path;
char *desc;
char *url;
/* Set missing once to avoid opening
* the same file several times. */
bool missing;
+4
View File
@@ -1287,6 +1287,10 @@ MSG_HASH(
MENU_ENUM_LABEL_CORE_OPTION_CATEGORY_ENABLE,
"core_option_category_enable"
)
MSG_HASH(
MENU_ENUM_LABEL_CORE_FIRMWARE_NOTIFICATION_ENABLE,
"core_firmware_notification_enable"
)
MSG_HASH(
MENU_ENUM_LABEL_CORE_INFO_CACHE_ENABLE,
"core_info_cache_enable"
+34
View File
@@ -39968,3 +39968,37 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_##T, us)
#undef S_UINT_AT_EX_H
#undef S_UINT_AT_EX_NS_H
#undef SETTINGS_DEF_STRINGS_PASS
MSG_HASH(
MENU_ENUM_LABEL_VALUE_CORE_FIRMWARE_NOTIFICATION_ENABLE,
"Missing Firmware Notifications"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_CORE_FIRMWARE_NOTIFICATION_ENABLE,
"Show a dialog when launching a core with missing required firmware. Offer to download firmware when its core info file provides a URL."
)
MSG_HASH(
MSG_CORE_FIRMWARE_MISSING,
"Required firmware is missing:"
)
MSG_HASH(
MSG_CORE_FIRMWARE_DOWNLOAD_PROMPT,
"Selecting OK will download and install the firmware indicated with \"This is firmware is available for download.\".\nAny other missing firmware must be provided as per your local laws.\n\nSelect Cancel to continue without downloading.\n\nNote: These notifications can be disabled in Settings->Core->Missing Firmware Notifications."
)
MSG_HASH(
MSG_CORE_FIRMWARE_CONTINUE_PROMPT,
"Select OK to launch without this firmware, or Cancel to abort core launch.\n\nNote: These notifications can be disabled in Settings->Core->Missing Firmware Notifications."
)
MSG_HASH(
MSG_CORE_FIRMWARE_DOWNLOAD_FAILED,
"Required firmware could not be installed."
)
MSG_HASH(
MSG_CORE_FIRMWARE_DOWNLOAD_AVAILABLE,
"This firmware is available for download."
)
MSG_HASH(
MSG_CORE_FIRMWARE_SUPPLY_MANUALLY,
"This firmware must be supplied manually."
)
+1
View File
@@ -2747,6 +2747,7 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
{ MENU_ENUM_LABEL_CORE_INFO_SAVESTATE_BYPASS, MENU_ENUM_SUBLABEL_CORE_INFO_SAVESTATE_BYPASS },
{ MENU_ENUM_LABEL_CORE_OPTION_CATEGORY_ENABLE, MENU_ENUM_SUBLABEL_CORE_OPTION_CATEGORY_ENABLE },
{ MENU_ENUM_LABEL_CORE_INFO_CACHE_ENABLE, MENU_ENUM_SUBLABEL_CORE_INFO_CACHE_ENABLE },
{ MENU_ENUM_LABEL_CORE_FIRMWARE_NOTIFICATION_ENABLE, MENU_ENUM_SUBLABEL_CORE_FIRMWARE_NOTIFICATION_ENABLE },
{ MENU_ENUM_LABEL_CORE_UPDATER_LIST, MENU_ENUM_SUBLABEL_DOWNLOAD_CORE },
{ MENU_ENUM_LABEL_CORE_MANAGER_LIST, MENU_ENUM_SUBLABEL_CORE_MANAGER_LIST },
{ MENU_ENUM_LABEL_CORE_UPDATER_AUTO_EXTRACT_ARCHIVE, MENU_ENUM_SUBLABEL_CORE_UPDATER_AUTO_EXTRACT_ARCHIVE },
+13
View File
@@ -2867,6 +2867,7 @@ static void materialui_render_messagebox(
int *lengths = lengths_buf;
bool keep_wrap = false;
struct menu_state *menu_st = menu_state_get_ptr();
bool confirm_dialog = (menu_st->dialog_st.confirm_cmd) ? true : false;
bool landscape = video_width >= video_height;
menu_dialog_buttons_t buttons;
int button_w[MENU_DIALOG_BUTTONS_MAX];
@@ -2877,6 +2878,7 @@ static void materialui_render_messagebox(
int stack_h = 0;
bool text_only = false;
bool stacked = false;
unsigned firmware_line_state = 0;
wrapped_buf[0] = '\0';
menu_dialog_get_buttons(menu_st, &buttons);
@@ -3159,6 +3161,10 @@ static void materialui_render_messagebox(
}
}
if (confirm_dialog)
slice_h += 70 * mui->last_scale_factor + mui->margin * 2.0
- (mui->font_data.list.line_height - mui->font_data.list.line_ascender);
if (draw_focus)
{
mui->osk_textbox_pos = VIDEO_POS_PACK(slice_x, slice_y);
@@ -3225,6 +3231,13 @@ static void materialui_render_messagebox(
+ mui->font_data.list.line_ascender,
video_dims, mui->colors.list_text,
TEXT_ALIGN_LEFT, 1.0f, false, 0.0f, true);
menu_dialog_draw_path_underline(menu_st, &firmware_line_state,
lines[i], mui->font_data.list.font, p_disp, userdata, video_dims,
x - longest_width / 2.0f,
y + (i * mui->font_data.list.line_height)
+ mui->font_data.list.line_ascender,
mui->colors.list_text);
}
if (draw_caret && (cursor_line < (unsigned)line_count))
+21
View File
@@ -7918,13 +7918,16 @@ OZONE_NOINLINE static void ozone_draw_messagebox(
int usable_width = 0;
float scale_factor = 0.0f;
float line_height = 0;
float button_spacing = 0;
unsigned i = 0;
unsigned line_count = 0;
unsigned y_position = 0;
unsigned margin = 0;
unsigned width = video_width;
unsigned height = video_height;
font_data_impl_t font_data = ozone->fonts.entries_label;
struct menu_state *menu_st = menu_state_get_ptr();
bool confirm_dialog = (menu_st->dialog_st.confirm_cmd) ? true : false;
bool landscape = video_width >= video_height;
menu_dialog_buttons_t buttons;
int button_w[MENU_DIALOG_BUTTONS_MAX];
@@ -7934,6 +7937,7 @@ OZONE_NOINLINE static void ozone_draw_messagebox(
int stack_h = 0;
bool text_only = false;
bool stacked = false;
unsigned firmware_line_state = 0;
gfx_display_ctx_driver_t
*dispctx = p_disp->dispctx;
char *lines_buf[256];
@@ -8187,6 +8191,16 @@ OZONE_NOINLINE static void ozone_draw_messagebox(
}
}
if (confirm_dialog)
{
button_spacing = slice_y + slice_new_h
- (y + line_count * line_height)
- (line_height - font_data.line_ascender);
slice_new_h += 70 * scale_factor + button_spacing;
}
width = slice_new_w;
margin = slice_margin;
gfx_display_blend_begin(dispctx, userdata);
gfx_display_draw_texture_slice(
@@ -8229,6 +8243,13 @@ OZONE_NOINLINE static void ozone_draw_messagebox(
false,
1.0f,
false);
menu_dialog_draw_path_underline(menu_st, &firmware_line_state,
msg, font_data.font, p_disp, userdata, video_dims,
x - (longest_width / 2),
y + (i * line_height) + font_data.line_ascender,
COLOR_TEXT_ALPHA(ozone->theme->text_rgba,
(uint32_t)(ozone->animations.messagebox_alpha * 255.0f)));
}
if (buttons.count)
+11
View File
@@ -5292,6 +5292,8 @@ static void rgui_render_messagebox(
unsigned button_rows = 0;
int row_step = 0;
int rows_y = 0;
bool confirm_dialog = (menu_st->dialog_st.confirm_cmd) ? true : false;
unsigned firmware_line_state = 0;
wrapped_message[0] = '\0';
menu_dialog_get_buttons(menu_st, &buttons);
@@ -5440,6 +5442,8 @@ static void rgui_render_messagebox(
for (i = 0; i < line_count; i++)
{
const char *msg = lines[i];
const char *path = menu_dialog_firmware_path_line(menu_st,
msg, &firmware_line_state);
int offset_x = (int)(rgui->font_width_stride * (glyphs_width - glyphs[i]) / 2);
int offset_y = (int)(rgui->font_height_stride * i);
int text_x = x + 8 + offset_x;
@@ -5455,6 +5459,13 @@ static void rgui_render_messagebox(
rgui_blit_line(rgui, fb_width, text_x, text_y, msg,
rgui->colors.normal_color, rgui->colors.shadow_color);
if (path)
rgui_color_rect(frame_buf_data, fb_dims,
text_x + (path - msg) * rgui->font_width_stride,
text_y + VIDEO_SCALE_H(rgui->font_dims),
utf8len(path) * rgui->font_width_stride - 1, 1,
rgui->colors.normal_color);
}
if (buttons.count)
+12
View File
@@ -1377,6 +1377,7 @@ XMB_NOINLINE static void xmb_render_messagebox_internal(
unsigned cursor_line = 0;
int cursor_x = 0;
struct menu_state *menu_st = menu_state_get_ptr();
bool confirm_dialog = (menu_st->dialog_st.confirm_cmd) ? true : false;
bool landscape = video_width >= video_height;
menu_dialog_buttons_t buttons;
int button_w[MENU_DIALOG_BUTTONS_MAX];
@@ -1389,6 +1390,7 @@ XMB_NOINLINE static void xmb_render_messagebox_internal(
bool text_only = false;
bool stacked = false;
bool input_dialog_display_kb = false;
unsigned firmware_line_state = 0;
size_t wrapped_len = 0;
size_t msg_len = strlen(message);
char wrapped_buf[MENU_LABEL_MAX_LENGTH];
@@ -1695,6 +1697,11 @@ XMB_NOINLINE static void xmb_render_messagebox_internal(
}
}
if (confirm_dialog)
slice_h += 70 * xmb->last_scale_factor
+ xmb->margins_slice + xmb->margins_dialog
- 0.15f * line_height;
if (input_dialog_display_kb)
{
xmb->osk_textbox_x = slice_x;
@@ -1792,6 +1799,11 @@ XMB_NOINLINE static void xmb_render_messagebox_internal(
y + ((i + 0.85) * line_height),
video_dims, 0x444444ff,
TEXT_ALIGN_LEFT, 1.0f, false, 0.0f, false);
menu_dialog_draw_path_underline(menu_st, &firmware_line_state,
msg, xmb->font, p_disp, userdata, video_dims,
x - (longest_width / 2.0), y + ((i + 0.85) * line_height),
0x444444ff);
}
if (draw_caret && (cursor_line < line_count))
+1
View File
@@ -601,6 +601,7 @@ enum menu_input_binds_ctl_state
struct menu_dialog
{
const char *confirm_text; /* borrowed until the dialog closes */
unsigned current_id;
enum menu_dialog_type current_type;
unsigned confirm_msg;
+1
View File
@@ -14872,6 +14872,7 @@ unsigned menu_displaylist_build_list(
#ifdef HAVE_ONLINE_UPDATER
{MENU_ENUM_LABEL_UPDATER_SETTINGS, PARSE_ACTION},
#endif
{MENU_ENUM_LABEL_CORE_FIRMWARE_NOTIFICATION_ENABLE, PARSE_ONLY_BOOL},
{MENU_ENUM_LABEL_CORE_INFO_CACHE_ENABLE, PARSE_ONLY_BOOL},
{MENU_ENUM_LABEL_CORE_INFO_SAVESTATE_BYPASS, PARSE_ONLY_BOOL},
{MENU_ENUM_LABEL_SYSTEMFILES_IN_CONTENT_DIR_ENABLE, PARSE_ONLY_BOOL},
+79 -2
View File
@@ -8581,8 +8581,10 @@ static int generic_menu_iterate(
sizeof(menu->menu_state_msg));
else
#endif
menu->menu_state_text = msg_hash_to_str(
(enum msg_hash_enums)menu_st->dialog_st.confirm_msg);
strlcpy(menu->menu_state_msg,
menu_st->dialog_st.confirm_text ? menu_st->dialog_st.confirm_text
: msg_hash_to_str((enum msg_hash_enums)menu_st->dialog_st.confirm_msg),
sizeof(menu->menu_state_msg));
#ifdef HAVE_ACCESSIBILITY
/* Also when the warning comes up after a confirm or a newer
@@ -9994,8 +9996,82 @@ size_t menu_playlists_tab_random_selection(size_t selection)
}
/* Modal dialog handling */
/* Wrapped path lines precede the bracketed availability badge. */
const char *menu_dialog_firmware_path_line(const struct menu_state *menu_st,
const char *line, unsigned *state)
{
const char *path = line;
if (menu_st->dialog_st.confirm_msg != MSG_CORE_FIRMWARE_MISSING || !line)
return NULL;
if (!*line)
{
*state = 0;
return NULL;
}
if (*state == 0)
{
while (*path >= '0' && *path <= '9')
path++;
if (path != line && *path == '.' && (path[1] == ' ' || !path[1]))
{
path++;
if (*path == ' ')
path++;
*state = 1;
return *path ? path : NULL;
}
*state = 2;
}
else if (*state == 1)
{
if (*line != '[')
return line;
*state = 2;
}
return NULL;
}
void menu_dialog_draw_path_underline(const struct menu_state *menu_st,
unsigned *state, const char *line, font_data_t *font,
gfx_display_t *p_disp, void *userdata, unsigned video_dims,
float x, float baseline, uint32_t color)
{
unsigned i;
float rgba[16];
int width;
const char *path = menu_dialog_firmware_path_line(menu_st, line, state);
if (!path)
return;
width = font_driver_get_message_width(font, path, strlen(path), 1.0f);
if (width <= 0)
return;
x += font_driver_get_message_width(font, line, path - line, 1.0f);
for (i = 0; i < 4; i++)
{
rgba[i * 4] = FONT_COLOR_GET_RED(color) / 255.0f;
rgba[i * 4 + 1] = FONT_COLOR_GET_GREEN(color) / 255.0f;
rgba[i * 4 + 2] = FONT_COLOR_GET_BLUE(color) / 255.0f;
rgba[i * 4 + 3] = FONT_COLOR_GET_ALPHA(color) / 255.0f;
}
gfx_display_blend_begin(p_disp->dispctx, userdata);
gfx_display_draw_quad(p_disp, userdata, video_dims, x, baseline + 1,
VIDEO_SCALE_PACK(width, 1), video_dims, rgba, NULL);
gfx_display_blend_end(p_disp->dispctx, userdata);
}
static void menu_dialog_confirm_reset(struct menu_state *menu_st)
{
menu_st->dialog_st.confirm_text = NULL;
menu_st->dialog_st.confirm_msg = MSG_UNKNOWN;
menu_st->dialog_st.confirm_cmd = CMD_EVENT_NONE;
@@ -10019,6 +10095,7 @@ void menu_dialog_confirm_set(struct menu_state *menu_st, unsigned msg, unsigned
menu_st->dialog_st.button_hover = -1;
menu_st->dialog_st.confirm_hover_ok = false;
menu_st->dialog_st.confirm_hover_back = false;
menu_st->dialog_st.confirm_text = NULL;
menu_st->dialog_st.button_epoch++;
menu_st->dialog_st.confirm_msg = msg;
menu_st->dialog_st.confirm_cmd = cmd;
+7
View File
@@ -895,6 +895,13 @@ size_t menu_playlist_random_selection(
* inside an open playlist or Explore list. */
size_t menu_playlists_tab_random_selection(size_t selection);
const char *menu_dialog_firmware_path_line(const struct menu_state *menu_st,
const char *line, unsigned *state);
void menu_dialog_draw_path_underline(const struct menu_state *menu_st,
unsigned *state, const char *line, font_data_t *font,
gfx_display_t *p_disp, void *userdata, unsigned video_dims,
float x, float baseline, uint32_t color);
void menu_dialog_confirm_set(struct menu_state *menu_st,
unsigned msg, unsigned cmd);
void menu_dialog_confirm_clear(struct menu_state *menu_st);
+8 -2
View File
@@ -15905,9 +15905,9 @@ static void settings_build_core(
unsigned i, listing = 0;
#ifndef HAVE_DYNAMIC
struct bool_entry bool_entries[11];
struct bool_entry bool_entries[12];
#else
struct bool_entry bool_entries[10];
struct bool_entry bool_entries[11];
#endif
START_GROUP(list, list_info, &group_info,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_CORE_SETTINGS), parent_group);
@@ -15998,6 +15998,12 @@ static void settings_build_core(
bool_entries[listing].flags |= SD_FLAG_DEFAULT_VALUE;
listing++;
#endif
bool_entries[listing].target = &settings->bools.core_firmware_notification_enable;
bool_entries[listing].name_enum_idx = MENU_ENUM_LABEL_CORE_FIRMWARE_NOTIFICATION_ENABLE;
bool_entries[listing].SHORT_enum_idx = MENU_ENUM_LABEL_VALUE_CORE_FIRMWARE_NOTIFICATION_ENABLE;
bool_entries[listing].flags = SD_FLAG_DEFAULT_VALUE;
listing++;
/* Iterate the filled count, not the array capacity:
* the capacities above are upper bounds and iterating
* ARRAY_SIZE registered one setting from uninitialized
+7
View File
@@ -395,6 +395,12 @@ enum msg_hash_enums
MSG_AUTOLOADING_SAVESTATE_SUCCEEDED,
MSG_LOADING,
MSG_FIRMWARE,
MSG_CORE_FIRMWARE_MISSING,
MSG_CORE_FIRMWARE_DOWNLOAD_PROMPT,
MSG_CORE_FIRMWARE_CONTINUE_PROMPT,
MSG_CORE_FIRMWARE_DOWNLOAD_FAILED,
MSG_CORE_FIRMWARE_DOWNLOAD_AVAILABLE,
MSG_CORE_FIRMWARE_SUPPLY_MANUALLY,
MSG_CONNECTING_TO_PORT,
MSG_CONNECTED_TO,
MSG_FAILED_TO_LOAD,
@@ -26503,6 +26509,7 @@ enum msg_hash_enums
MENU_LABEL(CORE_INFO_SAVESTATE_BYPASS),
MENU_LABEL(CORE_OPTION_CATEGORY_ENABLE),
MENU_LABEL(CORE_INFO_CACHE_ENABLE),
MENU_LABEL(CORE_FIRMWARE_NOTIFICATION_ENABLE),
#ifndef HAVE_DYNAMIC
MENU_LABEL(ALWAYS_RELOAD_CORE_ON_RUN_CONTENT),
#endif
+2
View File
@@ -330,6 +330,7 @@ extern const struct msg_hash_us_lbl_blob_s msg_hash_us_lbl_blob;
#define MENU_ENUM_LABEL_UPDATE_INSTALLED_CORES_STR (msg_hash_us_lbl_blob.m_MENU_ENUM_LABEL_UPDATE_INSTALLED_CORES)
#define MENU_ENUM_LABEL_SWITCH_INSTALLED_CORES_PFD_STR (msg_hash_us_lbl_blob.m_MENU_ENUM_LABEL_SWITCH_INSTALLED_CORES_PFD)
#define MENU_ENUM_LABEL_CORE_OPTION_CATEGORY_ENABLE_STR (msg_hash_us_lbl_blob.m_MENU_ENUM_LABEL_CORE_OPTION_CATEGORY_ENABLE)
#define MENU_ENUM_LABEL_CORE_FIRMWARE_NOTIFICATION_ENABLE_STR (msg_hash_us_lbl_blob.m_MENU_ENUM_LABEL_CORE_FIRMWARE_NOTIFICATION_ENABLE)
#define MENU_ENUM_LABEL_CORE_INFO_CACHE_ENABLE_STR (msg_hash_us_lbl_blob.m_MENU_ENUM_LABEL_CORE_INFO_CACHE_ENABLE)
#define MENU_ENUM_LABEL_CORE_INFO_SAVESTATE_BYPASS_STR (msg_hash_us_lbl_blob.m_MENU_ENUM_LABEL_CORE_INFO_SAVESTATE_BYPASS)
#define MENU_ENUM_LABEL_DUMMY_ON_CORE_SHUTDOWN_STR (msg_hash_us_lbl_blob.m_MENU_ENUM_LABEL_DUMMY_ON_CORE_SHUTDOWN)
@@ -2111,6 +2112,7 @@ extern const struct msg_hash_us_lbl_blob_s msg_hash_us_lbl_blob;
#define MENU_ENUM_LABEL_UPDATE_INSTALLED_CORES_STR "update_installed_cores"
#define MENU_ENUM_LABEL_SWITCH_INSTALLED_CORES_PFD_STR "switch_installed_cores_pfd"
#define MENU_ENUM_LABEL_CORE_OPTION_CATEGORY_ENABLE_STR "core_option_category_enable"
#define MENU_ENUM_LABEL_CORE_FIRMWARE_NOTIFICATION_ENABLE_STR "core_firmware_notification_enable"
#define MENU_ENUM_LABEL_CORE_INFO_CACHE_ENABLE_STR "core_info_cache_enable"
#define MENU_ENUM_LABEL_CORE_INFO_SAVESTATE_BYPASS_STR "core_info_savestate_bypass"
#define MENU_ENUM_LABEL_DUMMY_ON_CORE_SHUTDOWN_STR "dummy_on_core_shutdown"
+5
View File
@@ -5698,6 +5698,11 @@ bool command_event(enum event_command cmd, void *data)
input_config_forget_controllers();
input_driver_restart_with_next_video_restart();
break;
case CMD_EVENT_CORE_FIRMWARE_DOWNLOAD:
#ifdef HAVE_MENU
task_content_firmware_download();
#endif
break;
case CMD_EVENT_MENU_FIRST_RUN_DOWNLOAD:
#if defined(HAVE_MENU) && defined(HAVE_ONLINE_UPDATER) && defined(HAVE_NETWORKING) && defined(HAVE_COMPRESSION) && defined(HAVE_CONFIGFILE)
menu_first_run_download_start();
+3
View File
@@ -1068,3 +1068,6 @@
# through power-profiles-daemon or tuned-ppd while plugged in.
#
# gamemode_enable = true
# Warn about missing required firmware when launching a core.
# core_firmware_notification_enable = true
+352 -2
View File
@@ -107,6 +107,7 @@ void win32_window_release_kept(void);
#include "patch_stream.h"
#include "tasks_internal.h"
#include "task_content_prefetch.h"
#include "task_file_transfer.h"
#include "../command.h"
#include "../core_info.h"
@@ -117,6 +118,7 @@ void win32_window_release_kept(void);
#include "../content.h"
#include "../core.h"
#include "../configuration.h"
#include "../config.def.h"
#include "../defaults.h"
#include "../dynamic.h"
#include "../file_path_special.h"
@@ -2040,7 +2042,8 @@ enum content_load_stage
CONTENT_LOAD_STAGE_CORE,
/* One driver reinit against the new core, then the session tail
* and whatever the entry point asked for after the load. */
CONTENT_LOAD_STAGE_DRIVERS
CONTENT_LOAD_STAGE_DRIVERS,
CONTENT_LOAD_STAGE_FIRMWARE
};
/* What an entry point wants done once the load is through. */
@@ -2061,8 +2064,104 @@ enum content_load_after
struct content_load_parked;
#endif
#ifdef HAVE_MENU
struct content_firmware
{
size_t index;
unsigned missing_count;
char system_dir[DIR_MAX_LENGTH];
char target[PATH_MAX_LENGTH];
char download[PATH_MAX_LENGTH];
#ifdef HAVE_NETWORKING
char url[PATH_MAX_LENGTH];
#endif
char message[1024];
bool shown;
bool downloading;
bool failed;
bool archive;
bool confirmed;
bool cancelled;
bool has_download;
bool download_requested;
};
#if defined(HAVE_NETWORKING)
static bool content_firmware_path_valid(const char *path)
{
const char *part = path;
const char *end;
if (string_is_empty(path) || *path == '/' || *path == '\\')
return false;
do
{
end = part + strcspn(part, "/\\");
if (end == part || (end - part == 2 && !memcmp(part, "..", 2))
|| memchr(part, ':', end - part))
return false;
part = end + 1;
} while (*end);
return true;
}
static void content_firmware_download_finish(struct content_firmware *firmware,
bool success)
{
filestream_delete(firmware->download);
firmware->downloading = false;
if (!success || !path_is_valid(firmware->target))
firmware->failed = true;
}
#ifdef HAVE_COMPRESSION
static void content_firmware_extracted(retro_task_t *task,
void *task_data, void *user_data, const char *err)
{
decompress_task_data_t *data = (decompress_task_data_t*)task_data;
struct content_firmware *firmware = (struct content_firmware*)user_data;
content_firmware_download_finish(firmware, !err);
if (data)
{
free(data->source_file);
free(data);
}
}
#endif
static void content_firmware_downloaded(retro_task_t *task,
void *task_data, void *user_data, const char *err)
{
http_transfer_data_t *data = (http_transfer_data_t*)task_data;
struct content_firmware *firmware = (struct content_firmware*)user_data;
bool success = !err && data && data->status >= 200 && data->status < 300;
#ifdef HAVE_COMPRESSION
if (success && firmware->archive)
{
if (task_push_decompress(firmware->download, firmware->system_dir,
NULL, NULL, NULL, content_firmware_extracted, firmware,
NULL, false))
return;
success = false;
}
else
#endif
if (success)
success = filestream_rename(firmware->download, firmware->target) == 0;
content_firmware_download_finish(firmware, success);
}
#endif
#endif
struct content_load_job
{
#ifdef HAVE_MENU
struct content_firmware *firmware;
#endif
struct rarch_main_wrap *wrap_args;
char **argv_ptr;
int *argc_ptr;
@@ -2092,6 +2191,226 @@ static bool content_load_job_result;
static void content_load_parked_free(void *ud);
#endif
#ifdef HAVE_MENU
void task_content_firmware_download(void)
{
struct content_firmware *firmware = content_load_job.firmware;
if (firmware)
{
firmware->confirmed = true;
firmware->download_requested = firmware->has_download;
}
}
#if defined(HAVE_NETWORKING)
static void content_firmware_download_start(struct content_firmware *firmware,
const char *url)
{
char parent[PATH_MAX_LENGTH];
strlcpy(parent, firmware->download, sizeof(parent));
path_basedir_wrapper(parent);
if (!path_mkdir(parent) || path_is_valid(firmware->download))
{
firmware->failed = true;
return;
}
firmware->downloading = true;
/* The HTTP task copies the borrowed URL on submission. */
if (!task_push_http_download_file(url, firmware->download,
false, msg_hash_to_str(MSG_FIRMWARE),
content_firmware_downloaded, firmware))
content_firmware_download_finish(firmware, false);
}
#endif
static bool content_load_firmware(struct content_load_job *job)
{
struct menu_state *menu_st = menu_state_get_ptr();
settings_t *settings = config_get_ptr();
struct content_firmware *firmware = job->firmware;
core_info_t *core = NULL;
core_info_firmware_t *entry;
bool download_available = false;
const char *content = path_get(RARCH_PATH_CONTENT);
#if defined(HAVE_NETWORKING)
const char *url = NULL;
const char *download_url;
#endif
if (firmware && firmware->downloading)
return false;
if (!settings->bools.core_firmware_notification_enable
|| !menu_st->driver_data
|| (string_is_empty(content)
&& !runloop_state_get_ptr()->system.load_no_content)
|| !core_info_find(path_get(RARCH_PATH_CORE), &core)
|| !core || !core->firmware_count)
return true;
if (menu_st->dialog_st.confirm_cmd || menu_st->dialog_st.pending_cmd)
return false;
if (!firmware)
{
firmware = (struct content_firmware*)calloc(1, sizeof(*firmware));
if (!firmware)
return true;
job->firmware = firmware;
if ((settings->bools.systemfiles_in_content_dir
|| string_is_empty(settings->paths.directory_system))
&& !string_is_empty(content))
fill_pathname_basedir(firmware->system_dir, content,
sizeof(firmware->system_dir));
else
strlcpy(firmware->system_dir, settings->paths.directory_system,
sizeof(firmware->system_dir));
}
if (firmware->shown && !firmware->download_requested)
{
firmware->cancelled = !firmware->has_download && !firmware->confirmed;
return true;
}
if (firmware->index >= core->firmware_count)
{
if (firmware->shown)
{
if (firmware->failed)
{
const char *msg = msg_hash_to_str(MSG_CORE_FIRMWARE_DOWNLOAD_FAILED);
runloop_msg_queue_push(msg, strlen(msg), 1, 180, true, NULL,
MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_ERROR);
}
return true;
}
if (!firmware->missing_count)
return true;
strlcat(firmware->message, "\n\n", sizeof(firmware->message));
strlcat(firmware->message, msg_hash_to_str(firmware->has_download
? MSG_CORE_FIRMWARE_DOWNLOAD_PROMPT
: MSG_CORE_FIRMWARE_CONTINUE_PROMPT), sizeof(firmware->message));
firmware->shown = true;
firmware->index = 0;
menu_dialog_confirm_set(menu_st, MSG_CORE_FIRMWARE_MISSING,
CMD_EVENT_CORE_FIRMWARE_DOWNLOAD);
menu_st->dialog_st.confirm_text = firmware->message;
retroarch_menu_running();
return false;
}
entry = &core->firmware[firmware->index++];
if (entry->optional || string_is_empty(entry->path))
return false;
fill_pathname_join(firmware->target, firmware->system_dir,
entry->path, sizeof(firmware->target));
if (path_is_valid(firmware->target))
return false;
#if defined(HAVE_NETWORKING)
download_url = entry->url;
if (!string_is_empty(download_url)
&& !strchr(download_url, ':')
&& content_firmware_path_valid(download_url))
{
int written = snprintf(firmware->url, sizeof(firmware->url),
"%ssystem/%s", DEFAULT_BUILDBOT_ASSETS_SERVER_URL, download_url);
download_url = written >= 0
&& (size_t)written < sizeof(firmware->url)
? firmware->url : NULL;
}
if (!string_is_empty(firmware->system_dir)
&& content_firmware_path_valid(entry->path)
&& !string_is_empty(download_url)
&& (string_starts_with_size(download_url, "https://", 8)
|| string_starts_with_size(download_url, "http://", 7)))
{
char url_path[PATH_MAX_LENGTH];
strlcpy(url_path, download_url, sizeof(url_path));
url_path[strcspn(url_path, "?#")] = '\0';
firmware->archive = path_is_compressed_file(url_path);
#ifndef HAVE_COMPRESSION
if (!firmware->archive)
#endif
{
if (firmware->archive)
{
char name[64];
snprintf(name, sizeof(name), ".retroarch-firmware.%s",
path_get_extension(url_path));
fill_pathname_join(firmware->download, firmware->system_dir,
name, sizeof(firmware->download));
}
else
{
size_t len = strlcpy(firmware->download, firmware->target,
sizeof(firmware->download));
if (len + sizeof(".download") > sizeof(firmware->download))
return false;
strlcpy_lit(firmware->download + len, ".download",
sizeof(firmware->download) - len);
}
download_available = true;
if (firmware->shown)
url = download_url;
else
firmware->has_download = true;
}
}
#endif
if (firmware->shown)
{
#if defined(HAVE_NETWORKING)
if (url)
content_firmware_download_start(firmware, url);
#endif
return false;
}
if (!firmware->missing_count)
strlcpy(firmware->message, msg_hash_to_str(MSG_CORE_FIRMWARE_MISSING),
sizeof(firmware->message));
strlcat(firmware->message, "\n\n", sizeof(firmware->message));
{
char number[32];
snprintf(number, sizeof(number), "%u. ", ++firmware->missing_count);
strlcat(firmware->message, number, sizeof(firmware->message));
}
strlcat(firmware->message, entry->path, sizeof(firmware->message));
strlcat(firmware->message, "\n[", sizeof(firmware->message));
strlcat(firmware->message, msg_hash_to_str(download_available
? MSG_CORE_FIRMWARE_DOWNLOAD_AVAILABLE
: MSG_CORE_FIRMWARE_SUPPLY_MANUALLY), sizeof(firmware->message));
strlcat(firmware->message, "]", sizeof(firmware->message));
if (!string_is_empty(entry->desc))
{
strlcat(firmware->message, "\n", sizeof(firmware->message));
strlcat(firmware->message, entry->desc, sizeof(firmware->message));
}
return false;
}
#endif
static void content_load_job_free(struct content_load_job *job)
{
size_t i;
@@ -2100,6 +2419,13 @@ static void content_load_job_free(struct content_load_job *job)
free(job->argv_copy[i]);
job->argv_copy[i] = NULL;
}
#ifdef HAVE_MENU
if (job->firmware)
{
free(job->firmware);
job->firmware = NULL;
}
#endif
free(job->wrap_args);
job->wrap_args = NULL;
#ifdef HAVE_CORE_LOAD_CHECK
@@ -2711,6 +3037,19 @@ static void content_load_step(struct content_load_job *job,
{
switch (job->stage)
{
case CONTENT_LOAD_STAGE_FIRMWARE:
#ifdef HAVE_MENU
if (!content_load_firmware(job))
break;
if (job->firmware && job->firmware->cancelled)
{
job->after |= CONTENT_LOAD_AFTER_MENU_ON_FAIL;
content_load_finish(job, p_content);
break;
}
#endif
job->stage = CONTENT_LOAD_STAGE_DEINIT;
break;
case CONTENT_LOAD_STAGE_DEINIT:
if (!content_load_stage_deinit(job))
{
@@ -2837,7 +3176,9 @@ bool task_content_is_load_stage(const retro_task_t *task)
{
return task && task->handler == content_load_task_handler
&& (enum content_load_stage)(uintptr_t)task->state
!= CONTENT_LOAD_STAGE_CLOSE_WAIT;
!= CONTENT_LOAD_STAGE_CLOSE_WAIT
&& (enum content_load_stage)(uintptr_t)task->state
!= CONTENT_LOAD_STAGE_FIRMWARE;
}
static bool content_load_push_stage(struct content_load_job *job)
@@ -2904,6 +3245,15 @@ static bool content_load(content_ctx_info_t *info,
job->after = after;
job->staged = staged;
job->stage = CONTENT_LOAD_STAGE_DEINIT;
#ifdef HAVE_MENU
if (staged && config_get_ptr()->bools.core_firmware_notification_enable)
{
core_info_t *core = NULL;
if (core_info_find(path_get(RARCH_PATH_CORE), &core)
&& core && core->firmware_count)
job->stage = CONTENT_LOAD_STAGE_FIRMWARE;
}
#endif
if (staged)
{
+4
View File
@@ -114,6 +114,10 @@ bool task_content_park_startup(const char *core_path,
const char *content_path);
#endif
#ifdef HAVE_MENU
void task_content_firmware_download(void);
#endif
/* Every task_push_load_* entry point below (the CLI one excepted, which
* is startup itself and loads in one go) starts the load as a chain of
* main-thread tasks of the frontend's queue and returns; the load is