(Wii) allow changing between SD and USB

This commit is contained in:
Toad King 2012-06-30 03:08:05 -04:00
parent 65a269a532
commit c9c723482a
3 changed files with 46 additions and 12 deletions

View File

@ -45,7 +45,20 @@ static bool folder_cb(const char *directory, rgui_file_enum_cb_t file_cb,
{
(void)userdata;
DIR *dir = opendir(directory);
if (!*directory)
{
#ifdef HW_RVL
file_cb(ctx, "sd:", RGUI_FILE_DEVICE);
file_cb(ctx, "usb:", RGUI_FILE_DEVICE);
#endif
file_cb(ctx, "carda:", RGUI_FILE_DEVICE);
file_cb(ctx, "cardb:", RGUI_FILE_DEVICE);
return true;
}
char _dir[PATH_MAX];
snprintf(_dir, sizeof(_dir), "%s/", directory);
DIR *dir = opendir(_dir);
if (!dir)
return false;
@ -152,7 +165,7 @@ int main(void)
wii_video_init();
input_wii.init();
rgui_handle_t *rgui = rgui_init("/",
rgui_handle_t *rgui = rgui_init("",
menu_framebuf, RGUI_WIDTH * sizeof(uint16_t),
_binary_console_font_bmp_start, folder_cb, NULL);

View File

@ -192,11 +192,24 @@ static void render_text(rgui_handle_t *rgui, size_t begin, size_t end)
rgui_list_at(rgui->folder_buf, i, &path, &type);
char message[TERM_WIDTH + 1];
char *type_str;
switch (type)
{
case RGUI_FILE_PLAIN:
type_str = "(FILE)";
break;
case RGUI_FILE_DIRECTORY:
type_str = "(DIR)";
break;
case RGUI_FILE_DEVICE:
type_str = "(DEV)";
break;
}
snprintf(message, sizeof(message), "%c %-*s %6s\n",
i == rgui->directory_ptr ? '>' : ' ',
TERM_WIDTH - (6 + 1 + 2),
path,
type == RGUI_FILE_PLAIN ? "(FILE)" : "(DIR)");
type_str);
blit_line(rgui, x, y, message, i == rgui->directory_ptr);
}
@ -274,8 +287,8 @@ const char *rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
if (rgui_list_size(rgui->folder_buf) == 0)
return NULL;
const char *path = NULL;
rgui_file_type_t type = RGUI_FILE_PLAIN;
const char *path;
rgui_file_type_t type;
rgui_list_at(rgui->folder_buf, rgui->directory_ptr,
&path, &type);
@ -285,16 +298,22 @@ const char *rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
if (type == RGUI_FILE_DIRECTORY)
{
char cat_path[PATH_MAX];
snprintf(cat_path, sizeof(cat_path), "%s/%s",
strcmp(dir, "/") == 0 ? "" : dir, path);
snprintf(cat_path, sizeof(cat_path), "%s/%s", dir, path);
rgui_list_push(rgui->path_stack, cat_path, RGUI_FILE_DIRECTORY);
if (strcmp(path, "..") == 0)
rgui_list_pop(rgui->path_stack);
else if (strcmp(path, ".") != 0)
rgui_list_push(rgui->path_stack, cat_path, RGUI_FILE_DIRECTORY);
rgui->need_refresh = true;
}
else if (type == RGUI_FILE_DEVICE)
{
rgui_list_push(rgui->path_stack, path, RGUI_FILE_DEVICE);
rgui->need_refresh = true;
}
else
{
snprintf(rgui->path_buf, sizeof(rgui->path_buf), "%s/%s",
strcmp(dir, "/") == 0 ? "" : dir, path);
snprintf(rgui->path_buf, sizeof(rgui->path_buf), "%s/%s", dir, path);
strlcpy(g_console.rom_path, rgui->path_buf, sizeof(g_console.rom_path));
rarch_settings_msg(S_MSG_LOADING_ROM, S_DELAY_1);
found = true;
@ -323,7 +342,8 @@ const char *rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
rgui->userdata, rgui->folder_buf))
return NULL;
rgui_list_sort(rgui->folder_buf);
if (*path)
rgui_list_sort(rgui->folder_buf);
rgui->need_refresh = false;
}

View File

@ -28,7 +28,8 @@ extern "C" {
typedef enum
{
RGUI_FILE_PLAIN,
RGUI_FILE_DIRECTORY
RGUI_FILE_DIRECTORY,
RGUI_FILE_DEVICE
} rgui_file_type_t;
typedef enum