mirror of
https://github.com/libretro/RetroArch
synced 2025-04-01 04:20:27 +00:00
(RMenu/RMenu XUI) Move browser_update to upper-layer menu_common.c -
use same function for both RMenu and RMenu XUI
This commit is contained in:
parent
1f6d3a8610
commit
798f40b6a1
@ -248,6 +248,49 @@ bool filebrowser_iterate(void *data, unsigned action)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void filebrowser_update(void *data, uint64_t input, const char *extensions)
|
||||
{
|
||||
filebrowser_action_t action = FILEBROWSER_ACTION_NOOP;
|
||||
bool ret = true;
|
||||
|
||||
if (input & (1ULL << DEVICE_NAV_DOWN))
|
||||
action = FILEBROWSER_ACTION_DOWN;
|
||||
else if (input & (1ULL << DEVICE_NAV_UP))
|
||||
action = FILEBROWSER_ACTION_UP;
|
||||
else if (input & (1ULL << DEVICE_NAV_RIGHT))
|
||||
action = FILEBROWSER_ACTION_RIGHT;
|
||||
else if (input & (1ULL << DEVICE_NAV_LEFT))
|
||||
action = FILEBROWSER_ACTION_LEFT;
|
||||
else if (input & (1ULL << DEVICE_NAV_R2))
|
||||
action = FILEBROWSER_ACTION_SCROLL_DOWN;
|
||||
else if (input & (1ULL << DEVICE_NAV_L2))
|
||||
action = FILEBROWSER_ACTION_SCROLL_UP;
|
||||
else if (input & (1ULL << DEVICE_NAV_A))
|
||||
{
|
||||
char tmp_str[PATH_MAX];
|
||||
fill_pathname_parent_dir(tmp_str, rgui->browser->current_dir.directory_path, sizeof(tmp_str));
|
||||
|
||||
if (tmp_str[0] != '\0')
|
||||
action = FILEBROWSER_ACTION_CANCEL;
|
||||
}
|
||||
else if (input & (1ULL << DEVICE_NAV_START))
|
||||
{
|
||||
action = FILEBROWSER_ACTION_RESET;
|
||||
filebrowser_set_root_and_ext(rgui->browser, NULL, default_paths.filesystem_root_dir);
|
||||
strlcpy(rgui->browser->current_dir.extensions, extensions,
|
||||
sizeof(rgui->browser->current_dir.extensions));
|
||||
#ifdef HAVE_RMENU_XUI
|
||||
filebrowser_fetch_directory_entries(1ULL << RMENU_DEVICE_NAV_B);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (action != FILEBROWSER_ACTION_NOOP)
|
||||
ret = filebrowser_iterate(rgui->browser, action);
|
||||
|
||||
if (!ret)
|
||||
msg_queue_push(g_extern.msg_queue, "ERROR - Failed to open directory.", 1, 180);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
struct rgui_file
|
||||
|
@ -544,46 +544,6 @@ static void display_menubar(uint8_t menu_type)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void browser_update(void *data, uint64_t input, const char *extensions)
|
||||
{
|
||||
filebrowser_action_t action = FILEBROWSER_ACTION_NOOP;
|
||||
bool ret = true;
|
||||
|
||||
if (input & (1ULL << DEVICE_NAV_DOWN))
|
||||
action = FILEBROWSER_ACTION_DOWN;
|
||||
else if (input & (1ULL << DEVICE_NAV_UP))
|
||||
action = FILEBROWSER_ACTION_UP;
|
||||
else if (input & (1ULL << DEVICE_NAV_RIGHT))
|
||||
action = FILEBROWSER_ACTION_RIGHT;
|
||||
else if (input & (1ULL << DEVICE_NAV_LEFT))
|
||||
action = FILEBROWSER_ACTION_LEFT;
|
||||
else if (input & (1ULL << DEVICE_NAV_R2))
|
||||
action = FILEBROWSER_ACTION_SCROLL_DOWN;
|
||||
else if (input & (1ULL << DEVICE_NAV_L2))
|
||||
action = FILEBROWSER_ACTION_SCROLL_UP;
|
||||
else if (input & (1ULL << DEVICE_NAV_A))
|
||||
{
|
||||
char tmp_str[PATH_MAX];
|
||||
fill_pathname_parent_dir(tmp_str, rgui->browser->current_dir.directory_path, sizeof(tmp_str));
|
||||
|
||||
if (tmp_str[0] != '\0')
|
||||
action = FILEBROWSER_ACTION_CANCEL;
|
||||
}
|
||||
else if (input & (1ULL << DEVICE_NAV_START))
|
||||
{
|
||||
action = FILEBROWSER_ACTION_RESET;
|
||||
filebrowser_set_root_and_ext(rgui->browser, NULL, default_paths.filesystem_root_dir);
|
||||
strlcpy(rgui->browser->current_dir.extensions, extensions,
|
||||
sizeof(rgui->browser->current_dir.extensions));
|
||||
}
|
||||
|
||||
if (action != FILEBROWSER_ACTION_NOOP)
|
||||
ret = filebrowser_iterate(rgui->browser, action);
|
||||
|
||||
if (!ret)
|
||||
msg_queue_push(g_extern.msg_queue, "ERROR - Failed to open directory.", 1, 180);
|
||||
}
|
||||
|
||||
static void browser_render(void *data)
|
||||
{
|
||||
unsigned file_count = rgui->browser->list->size;
|
||||
@ -659,7 +619,7 @@ static int select_file(void *data, uint64_t input)
|
||||
break;
|
||||
}
|
||||
|
||||
browser_update(rgui->browser, input, extensions);
|
||||
filebrowser_update(rgui->browser, input, extensions);
|
||||
|
||||
if (input & (1ULL << DEVICE_NAV_B))
|
||||
{
|
||||
@ -784,7 +744,7 @@ static int select_directory(void *data, uint64_t input)
|
||||
|
||||
bool is_dir = filebrowser_iterate(rgui->browser, FILEBROWSER_ACTION_PATH_ISDIR);
|
||||
bool pop_menu_stack = false;
|
||||
browser_update(rgui->browser, input, "empty");
|
||||
filebrowser_update(rgui->browser, input, "empty");
|
||||
|
||||
if (input & (1ULL << DEVICE_NAV_Y))
|
||||
{
|
||||
@ -2584,7 +2544,7 @@ static int select_rom(void *data, uint64_t input)
|
||||
if (driver.input->set_keybinds)
|
||||
driver.input->set_keybinds(&key_label_b, 0, 0, 0, (1ULL << KEYBINDS_ACTION_GET_BIND_LABEL));
|
||||
|
||||
browser_update(rgui->browser, input, g_extern.system.valid_extensions);
|
||||
filebrowser_update(rgui->browser, input, g_extern.system.valid_extensions);
|
||||
|
||||
if (input & (1ULL << DEVICE_NAV_SELECT))
|
||||
menu_stack_push(GENERAL_VIDEO_MENU, false);
|
||||
@ -2610,7 +2570,7 @@ static int select_rom(void *data, uint64_t input)
|
||||
if (drive_map != NULL)
|
||||
{
|
||||
filebrowser_set_root_and_ext(rgui->browser, g_extern.system.valid_extensions, drive_map);
|
||||
browser_update(rgui->browser, 1ULL << DEVICE_NAV_B, g_extern.system.valid_extensions);
|
||||
filebrowser_update(rgui->browser, 1ULL << DEVICE_NAV_B, g_extern.system.valid_extensions);
|
||||
}
|
||||
}
|
||||
else if (input & (1ULL << DEVICE_NAV_R1))
|
||||
@ -2619,7 +2579,7 @@ static int select_rom(void *data, uint64_t input)
|
||||
if (drive_map != NULL)
|
||||
{
|
||||
filebrowser_set_root_and_ext(rgui->browser, g_extern.system.valid_extensions, drive_map);
|
||||
browser_update(rgui->browser, 1ULL << DEVICE_NAV_B, g_extern.system.valid_extensions);
|
||||
filebrowser_update(rgui->browser, 1ULL << DEVICE_NAV_B, g_extern.system.valid_extensions);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,11 +299,9 @@ static void menu_settings_create_menu_item_label_w(wchar_t *strwbuf, unsigned se
|
||||
mbstowcs(strwbuf, str, size / sizeof(wchar_t));
|
||||
}
|
||||
|
||||
static void browser_update(void *data, uint64_t input, const char *extensions);
|
||||
|
||||
static void filebrowser_fetch_directory_entries(uint64_t action)
|
||||
void filebrowser_fetch_directory_entries(uint64_t action)
|
||||
{
|
||||
browser_update(rgui->browser, action, rgui->browser->current_dir.extensions);
|
||||
filebrowser_update(rgui->browser, action, rgui->browser->current_dir.extensions);
|
||||
|
||||
mbstowcs(strw_buffer, rgui->browser->current_dir.directory_path, sizeof(strw_buffer) / sizeof(wchar_t));
|
||||
XuiTextElementSetText(m_list_path, strw_buffer);
|
||||
@ -320,48 +318,6 @@ static void filebrowser_fetch_directory_entries(uint64_t action)
|
||||
}
|
||||
}
|
||||
|
||||
static void browser_update(void *data, uint64_t input, const char *extensions)
|
||||
{
|
||||
filebrowser_action_t action = FILEBROWSER_ACTION_NOOP;
|
||||
bool ret = true;
|
||||
|
||||
if (input & (1ULL << RMENU_DEVICE_NAV_DOWN))
|
||||
action = FILEBROWSER_ACTION_DOWN;
|
||||
else if (input & (1ULL << RMENU_DEVICE_NAV_UP))
|
||||
action = FILEBROWSER_ACTION_UP;
|
||||
else if (input & (1ULL << RMENU_DEVICE_NAV_RIGHT))
|
||||
action = FILEBROWSER_ACTION_RIGHT;
|
||||
else if (input & (1ULL << RMENU_DEVICE_NAV_LEFT))
|
||||
action = FILEBROWSER_ACTION_LEFT;
|
||||
else if (input & (1ULL << RMENU_DEVICE_NAV_R2))
|
||||
action = FILEBROWSER_ACTION_SCROLL_DOWN;
|
||||
else if (input & (1ULL << RMENU_DEVICE_NAV_L2))
|
||||
action = FILEBROWSER_ACTION_SCROLL_UP;
|
||||
else if (input & (1ULL << RMENU_DEVICE_NAV_A))
|
||||
{
|
||||
char tmp_str[256];
|
||||
fill_pathname_parent_dir(tmp_str, rgui->browser->current_dir.directory_path, sizeof(tmp_str));
|
||||
|
||||
if (tmp_str[0] != '\0')
|
||||
action = FILEBROWSER_ACTION_CANCEL;
|
||||
}
|
||||
else if (input & (1ULL << RMENU_DEVICE_NAV_START))
|
||||
{
|
||||
action = FILEBROWSER_ACTION_RESET;
|
||||
filebrowser_set_root_and_ext(rgui->browser, g_extern.system.valid_extensions,
|
||||
g_settings.rgui_browser_directory);
|
||||
strlcpy(rgui->browser->current_dir.extensions, extensions,
|
||||
sizeof(rgui->browser->current_dir.extensions));
|
||||
filebrowser_fetch_directory_entries(1ULL << RMENU_DEVICE_NAV_B);
|
||||
}
|
||||
|
||||
if(action != FILEBROWSER_ACTION_NOOP)
|
||||
ret = filebrowser_iterate(rgui->browser, action);
|
||||
|
||||
if(!ret)
|
||||
msg_queue_push(g_extern.msg_queue, "ERROR - Failed to open directory.", 1, 180);
|
||||
}
|
||||
|
||||
HRESULT CRetroArchFileBrowser::OnInit(XUIMessageInit * pInitData, BOOL& bHandled)
|
||||
{
|
||||
GetChildById(L"XuiRomList", &m_list);
|
||||
|
@ -62,5 +62,6 @@ enum
|
||||
};
|
||||
|
||||
bool menu_iterate_xui(void);
|
||||
void filebrowser_fetch_directory_entries(uint64_t action);
|
||||
|
||||
#endif
|
||||
|
@ -51,6 +51,7 @@ typedef enum
|
||||
FILEBROWSER_ACTION_NOOP
|
||||
} filebrowser_action_t;
|
||||
|
||||
void filebrowser_update(void *data, uint64_t input, const char *extensions);
|
||||
void filebrowser_set_root_and_ext(void *data, const char *ext, const char *root_dir);
|
||||
bool filebrowser_iterate(void *data, unsigned action);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user