diff --git a/driver.h b/driver.h index 39a85d7214..668c89ae57 100644 --- a/driver.h +++ b/driver.h @@ -328,7 +328,6 @@ typedef struct video_overlay_interface #endif // Optionally implemented interface to poke more deeply into video driver. -// Only used by RGUI atm. typedef struct video_poke_interface { void (*set_filtering)(void *data, unsigned index, bool smooth); diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index b33883f2da..622e45aad8 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -329,6 +329,40 @@ void menu_init(void) RARCH_ERR("Could not initialize menu.\n"); rarch_fail(1, "menu_init()"); } + +#ifdef HAVE_FILEBROWSER + if (!(strlen(g_settings.rgui_browser_directory) > 0)) + strlcpy(g_settings.rgui_browser_directory, default_paths.filebrowser_startup_dir, + sizeof(g_settings.rgui_browser_directory)); + + rgui->browser = (filebrowser_t*)calloc(1, sizeof(*(rgui->browser))); + + if (rgui->browser == NULL) + { + RARCH_ERR("Could not initialize filebrowser.\n"); + rarch_fail(1, "menu_init()"); + } + + strlcpy(rgui->browser->current_dir.extensions, g_extern.system.valid_extensions, + sizeof(rgui->browser->current_dir.extensions)); + strlcpy(rgui->browser->current_dir.root_dir, g_settings.rgui_browser_directory, + sizeof(rgui->browser->current_dir.root_dir)); + + filebrowser_iterate(rgui->browser, FILEBROWSER_ACTION_RESET); +#else + strlcpy(rgui->base_path, g_settings.rgui_browser_directory, sizeof(rgui->base_path)); + + rgui->menu_stack = (rgui_list_t*)calloc(1, sizeof(rgui_list_t)); + rgui->selection_buf = (rgui_list_t*)calloc(1, sizeof(rgui_list_t)); + rgui_list_push(rgui->menu_stack, g_settings.rgui_browser_directory, RGUI_FILE_DIRECTORY, 0); + rgui_list_push(rgui->menu_stack, "", RGUI_SETTINGS, 0); + + rgui_iterate(rgui, RGUI_ACTION_REFRESH); +#endif + +#ifdef HAVE_SHADER_MANAGER + shader_manager_init(rgui); +#endif } void menu_free(void) @@ -337,6 +371,9 @@ void menu_free(void) #ifdef HAVE_FILEBROWSER filebrowser_free(rgui->browser); +#else + rgui_list_free(rgui->menu_stack); + rgui_list_free(rgui->selection_buf); #endif free(rgui); diff --git a/frontend/menu/menu_common.h b/frontend/menu/menu_common.h index 8d23028c5d..6176139e30 100644 --- a/frontend/menu/menu_common.h +++ b/frontend/menu/menu_common.h @@ -170,6 +170,8 @@ void menu_init(void); bool menu_iterate(void); void menu_free(void); +int rgui_iterate(rgui_handle_t *rgui, uint64_t action); + rgui_handle_t *rgui_init(void); void rgui_free(rgui_handle_t *rgui); diff --git a/frontend/menu/rgui.c b/frontend/menu/rgui.c index 85dead863f..4df85591b4 100644 --- a/frontend/menu/rgui.c +++ b/frontend/menu/rgui.c @@ -179,11 +179,8 @@ static bool menu_type_is_shader_browser(unsigned type) type == RGUI_SETTINGS_SHADER_PRESET; } -static int rgui_iterate(rgui_handle_t *rgui, rgui_action_t action); - rgui_handle_t *rgui_init(void) { - const char *base_path = g_settings.rgui_browser_directory; uint16_t *framebuf = menu_framebuf; size_t framebuf_pitch = RGUI_WIDTH * sizeof(uint16_t); const uint8_t *font_bmp_buf = NULL; @@ -193,12 +190,6 @@ rgui_handle_t *rgui_init(void) rgui->frame_buf = framebuf; rgui->frame_buf_pitch = framebuf_pitch; - strlcpy(rgui->base_path, base_path, sizeof(rgui->base_path)); - - rgui->menu_stack = (rgui_list_t*)calloc(1, sizeof(rgui_list_t)); - rgui->selection_buf = (rgui_list_t*)calloc(1, sizeof(rgui_list_t)); - rgui_list_push(rgui->menu_stack, base_path, RGUI_FILE_DIRECTORY, 0); - rgui_list_push(rgui->menu_stack, "", RGUI_SETTINGS, 0); if (font_bmp_buf) init_font(rgui, font_bmp_buf); @@ -207,23 +198,18 @@ rgui_handle_t *rgui_init(void) else { RARCH_ERR("no font bmp or bin, abort"); + return NULL; + /* TODO - should be refactored - perhaps don't do rarch_fail but instead + * exit program */ g_extern.lifecycle_mode_state &= ~((1ULL << MODE_MENU) | (1ULL << MODE_MENU_INGAME) | (1ULL << MODE_GAME)); g_extern.lifecycle_mode_state |= (1ULL << MODE_EXIT); } -#ifdef HAVE_SHADER_MANAGER - shader_manager_init(rgui); -#endif - - rgui_iterate(rgui, RGUI_ACTION_REFRESH); - return rgui; } void rgui_free(rgui_handle_t *rgui) { - rgui_list_free(rgui->menu_stack); - rgui_list_free(rgui->selection_buf); if (rgui->alloc_font) free((uint8_t *) rgui->font); @@ -1699,7 +1685,7 @@ static bool directory_parse(rgui_handle_t *rgui, const char *directory, unsigned return true; } -static int rgui_iterate(rgui_handle_t *rgui, rgui_action_t action) +int rgui_iterate(rgui_handle_t *rgui, uint64_t action) { const char *dir = 0; unsigned menu_type = 0; diff --git a/frontend/menu/rmenu.c b/frontend/menu/rmenu.c index aa15d5b333..e9708fb2b4 100644 --- a/frontend/menu/rmenu.c +++ b/frontend/menu/rmenu.c @@ -801,7 +801,7 @@ static int select_directory(void *data, uint64_t input) strlcpy(g_extern.console.main_wrap.default_sram_dir, path, sizeof(g_extern.console.main_wrap.default_sram_dir)); break; case PATH_DEFAULT_ROM_DIR_CHOICE: - strlcpy(g_extern.console.main_wrap.default_rom_startup_dir, path, sizeof(g_extern.console.main_wrap.default_rom_startup_dir)); + strlcpy(g_settings.rgui_browser_directory, path, sizeof(g_settings.rgui_browser_directory)); break; #ifdef HAVE_XML case PATH_CHEATS_DIR_CHOICE: @@ -827,7 +827,7 @@ static int select_directory(void *data, uint64_t input) strlcpy(g_extern.console.main_wrap.default_sram_dir, path, sizeof(g_extern.console.main_wrap.default_sram_dir)); break; case PATH_DEFAULT_ROM_DIR_CHOICE: - strlcpy(g_extern.console.main_wrap.default_rom_startup_dir, path, sizeof(g_extern.console.main_wrap.default_rom_startup_dir)); + strlcpy(g_settings.rgui_browser_directory, path, sizeof(g_settings.rgui_browser_directory)); break; #ifdef HAVE_XML case PATH_CHEATS_DIR_CHOICE: @@ -1366,7 +1366,8 @@ static int set_setting_action(uint8_t menu_type, unsigned switchvalue, uint64_t } if (input & (1ULL << DEVICE_NAV_START)) - strlcpy(g_extern.console.main_wrap.default_rom_startup_dir, default_paths.filesystem_root_dir, sizeof(g_extern.console.main_wrap.default_rom_startup_dir)); + strlcpy(g_settings.rgui_browser_directory, + default_paths.filesystem_root_dir, sizeof(g_settings.rgui_browser_directory)); break; case SETTING_PATH_SAVESTATES_DIRECTORY: if ((input & (1ULL << DEVICE_NAV_LEFT)) || (input & (1ULL << DEVICE_NAV_RIGHT)) || (input & (1ULL << DEVICE_NAV_B))) @@ -1437,7 +1438,8 @@ static int set_setting_action(uint8_t menu_type, unsigned switchvalue, uint64_t case SETTING_PATH_DEFAULT_ALL: if ((input & (1ULL << DEVICE_NAV_LEFT)) || (input & (1ULL << DEVICE_NAV_RIGHT)) || (input & (1ULL << DEVICE_NAV_B)) || (input & (1ULL << DEVICE_NAV_START))) { - strlcpy(g_extern.console.main_wrap.default_rom_startup_dir, "/", sizeof(g_extern.console.main_wrap.default_rom_startup_dir)); + strlcpy(g_settings.rgui_browser_directory, default_paths.filebrowser_startup_dir, + sizeof(g_settings.rgui_browser_directory)); strlcpy(g_extern.console.main_wrap.default_savestate_dir, default_paths.port_dir, sizeof(g_extern.console.main_wrap.default_savestate_dir)); #ifdef HAVE_XML strlcpy(g_settings.cheat_database, default_paths.port_dir, sizeof(g_settings.cheat_database)); @@ -2174,7 +2176,7 @@ static int select_setting(void *data, uint64_t input) break; case SETTING_PATH_DEFAULT_ROM_DIRECTORY: strlcpy(text, "Startup ROM Directory", sizeof(text)); - strlcpy(setting_text, g_extern.console.main_wrap.default_rom_startup_dir, sizeof(setting_text)); + strlcpy(setting_text, g_settings.rgui_browser_directory, sizeof(setting_text)); strlcpy(comment, "INFO - Set the default Startup ROM directory path.", sizeof(comment)); break; case SETTING_PATH_SAVESTATES_DIRECTORY: @@ -3238,19 +3240,6 @@ rgui_handle_t *rgui_init(void) { rgui_handle_t *rgui = (rgui_handle_t*)calloc(1, sizeof(*rgui)); - rgui->browser = (filebrowser_t*)calloc(1, sizeof(*(rgui->browser))); - - strlcpy(rgui->browser->current_dir.extensions, g_extern.system.valid_extensions, - sizeof(rgui->browser->current_dir.extensions)); - strlcpy(rgui->browser->current_dir.root_dir, g_extern.console.main_wrap.default_rom_startup_dir, - sizeof(rgui->browser->current_dir.root_dir)); - - filebrowser_iterate(rgui->browser, FILEBROWSER_ACTION_RESET); - -#ifdef HAVE_SHADER_MANAGER - shader_manager_init(rgui); -#endif - menu_stack_push(FILE_BROWSER_MENU, false); menu_texture = (struct texture_image*)calloc(1, sizeof(*menu_texture)); diff --git a/general.h b/general.h index 711975b48c..4917b60813 100644 --- a/general.h +++ b/general.h @@ -265,7 +265,7 @@ struct settings uint16_t network_cmd_port; bool stdin_cmd_enable; -#ifdef HAVE_RGUI +#if defined(HAVE_RGUI) || defined(HAVE_RMENU) char rgui_browser_directory[PATH_MAX]; #endif }; @@ -576,7 +576,6 @@ struct global struct { - char default_rom_startup_dir[PATH_MAX]; char default_savestate_dir[PATH_MAX]; char default_sram_dir[PATH_MAX]; } main_wrap; diff --git a/gx/gx_video.c b/gx/gx_video.c index 09d4d4cc2d..5135bbffeb 100644 --- a/gx/gx_video.c +++ b/gx/gx_video.c @@ -1033,8 +1033,9 @@ static void gx_set_texture_frame(void *data, const void *frame, gx->menu_data = (uint32_t*)frame; } -static void gx_set_texture_enable(void *data, bool enable) +static void gx_set_texture_enable(void *data, bool enable, bool full_screen) { + (void)full_screen; gx_video_t *gx = (gx_video_t*)data; gx->rgui_texture_enable = enable; } diff --git a/settings.c b/settings.c index 5276099217..34524fdd6a 100644 --- a/settings.c +++ b/settings.c @@ -260,7 +260,6 @@ void config_set_defaults(void) g_extern.console.screen.orientation = ORIENTATION_NORMAL; g_extern.console.screen.resolutions.current.id = 0; - strlcpy(g_extern.console.main_wrap.default_rom_startup_dir, default_paths.filebrowser_startup_dir, sizeof(g_extern.console.main_wrap.default_rom_startup_dir)); strlcpy(g_extern.console.main_wrap.default_savestate_dir, default_paths.savestate_dir, sizeof(g_extern.console.main_wrap.default_savestate_dir)); #ifdef HAVE_RMENU strlcpy(g_extern.menu_texture_path, default_paths.menu_border_file, sizeof(g_extern.menu_texture_path)); @@ -475,9 +474,6 @@ bool config_load_file(const char *path) bool sram_dir_enable = false; bool state_dir_enable = false; - if (config_get_path(conf, "default_rom_startup_dir", tmp_str, sizeof(tmp_str))) - strlcpy(g_extern.console.main_wrap.default_rom_startup_dir, tmp_str, sizeof(g_extern.console.main_wrap.default_rom_startup_dir)); - #ifdef HAVE_RMENU if (config_get_path(conf, "menu_texture_path", tmp_str, sizeof(tmp_str))) strlcpy(g_extern.menu_texture_path, tmp_str, sizeof(g_extern.menu_texture_path)); @@ -1137,6 +1133,10 @@ bool config_save_file(const char *path) config_set_float(conf, "audio_rate_control_delta", g_settings.audio.rate_control_delta); config_set_string(conf, "system_directory", g_settings.system_directory); +#if defined(HAVE_RGUI) || defined(HAVE_RMENU) + config_set_string(conf, "rgui_browser_directory", g_settings.rgui_browser_directory); +#endif + #ifdef ANDROID config_set_int(conf, "input_back_behavior", input.back_behavior); config_set_int(conf, "input_autodetect_icade_profile_pad1", input.icade_profile[0]); @@ -1181,7 +1181,6 @@ bool config_save_file(const char *path) config_set_int(conf, "custom_viewport_height", g_extern.console.screen.viewports.custom_vp.height); config_set_int(conf, "custom_viewport_x", g_extern.console.screen.viewports.custom_vp.x); config_set_int(conf, "custom_viewport_y", g_extern.console.screen.viewports.custom_vp.y); - config_set_string(conf, "default_rom_startup_dir", g_extern.console.main_wrap.default_rom_startup_dir); #ifdef HAVE_RMENU config_set_string(conf, "menu_texture_path", g_extern.menu_texture_path); #endif