mirror of
https://github.com/libretro/RetroArch
synced 2025-01-26 18:35:22 +00:00
Merge git://github.com/ToadKing/RetroArch-Rpi
This commit is contained in:
commit
313086482b
@ -210,6 +210,7 @@ clean:
|
||||
rm -f *.o
|
||||
rm -f audio/*.o
|
||||
rm -f audio/xaudio-c/*.o
|
||||
rm -f compat/*.o
|
||||
rm -f conf/*.o
|
||||
rm -f gfx/*.o
|
||||
rm -f gfx/context/*.o
|
||||
|
@ -22,6 +22,7 @@ struct rgui_file
|
||||
{
|
||||
char *path;
|
||||
rgui_file_type_t type;
|
||||
size_t directory_ptr;
|
||||
};
|
||||
|
||||
struct rgui_list
|
||||
@ -42,7 +43,8 @@ bool rgui_list_empty(const rgui_list_t *list)
|
||||
return list->ptr == 0;
|
||||
}
|
||||
|
||||
void rgui_list_push(rgui_list_t *list, const char *path, rgui_file_type_t type)
|
||||
void rgui_list_push(rgui_list_t *list,
|
||||
const char *path, rgui_file_type_t type, size_t directory_ptr)
|
||||
{
|
||||
if (list->ptr >= list->capacity)
|
||||
{
|
||||
@ -53,6 +55,7 @@ void rgui_list_push(rgui_list_t *list, const char *path, rgui_file_type_t type)
|
||||
|
||||
list->list[list->ptr].path = strdup(path);
|
||||
list->list[list->ptr].type = type;
|
||||
list->list[list->ptr].directory_ptr = directory_ptr;
|
||||
list->ptr++;
|
||||
}
|
||||
|
||||
@ -78,10 +81,10 @@ void rgui_list_clear(rgui_list_t *list)
|
||||
}
|
||||
|
||||
void rgui_list_back(const rgui_list_t *list,
|
||||
const char **path, rgui_file_type_t *file_type)
|
||||
const char **path, rgui_file_type_t *file_type, size_t *directory_ptr)
|
||||
{
|
||||
if (rgui_list_size(list) > 0)
|
||||
rgui_list_at(list, rgui_list_size(list) - 1, path, file_type);
|
||||
rgui_list_at(list, rgui_list_size(list) - 1, path, file_type, directory_ptr);
|
||||
}
|
||||
|
||||
size_t rgui_list_size(const rgui_list_t *list)
|
||||
@ -90,12 +93,14 @@ size_t rgui_list_size(const rgui_list_t *list)
|
||||
}
|
||||
|
||||
void rgui_list_at(const rgui_list_t *list, size_t index,
|
||||
const char **path, rgui_file_type_t *file_type)
|
||||
const char **path, rgui_file_type_t *file_type, size_t *directory_ptr)
|
||||
{
|
||||
if (path)
|
||||
*path = list->list[index].path;
|
||||
if (file_type)
|
||||
*file_type = list->list[index].type;
|
||||
if (directory_ptr)
|
||||
*directory_ptr = list->list[index].directory_ptr;
|
||||
}
|
||||
|
||||
static int list_comp(const void *a_, const void *b_)
|
||||
|
@ -28,17 +28,18 @@ typedef struct rgui_list rgui_list_t;
|
||||
rgui_list_t *rgui_list_new(void);
|
||||
void rgui_list_free(rgui_list_t *list);
|
||||
|
||||
void rgui_list_push(rgui_list_t *list, const char *path, rgui_file_type_t type);
|
||||
void rgui_list_push(rgui_list_t *list,
|
||||
const char *path, rgui_file_type_t type, size_t directory_ptr);
|
||||
void rgui_list_pop(rgui_list_t *list);
|
||||
void rgui_list_clear(rgui_list_t *list);
|
||||
|
||||
bool rgui_list_empty(const rgui_list_t *list);
|
||||
void rgui_list_back(const rgui_list_t *list,
|
||||
const char **path, rgui_file_type_t *type);
|
||||
const char **path, rgui_file_type_t *type, size_t *directory_ptr);
|
||||
|
||||
size_t rgui_list_size(const rgui_list_t *list);
|
||||
void rgui_list_at(const rgui_list_t *list, size_t index,
|
||||
const char **path, rgui_file_type_t *type);
|
||||
const char **path, rgui_file_type_t *type, size_t *directory_ptr);
|
||||
|
||||
void rgui_list_sort(rgui_list_t *list);
|
||||
|
||||
|
@ -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, 0);
|
||||
file_cb(ctx, "usb:", RGUI_FILE_DEVICE, 0);
|
||||
#endif
|
||||
file_cb(ctx, "carda:", RGUI_FILE_DEVICE, 0);
|
||||
file_cb(ctx, "cardb:", RGUI_FILE_DEVICE, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
char _dir[PATH_MAX];
|
||||
snprintf(_dir, sizeof(_dir), "%s/", directory);
|
||||
DIR *dir = opendir(_dir);
|
||||
if (!dir)
|
||||
return false;
|
||||
|
||||
@ -63,7 +76,7 @@ static bool folder_cb(const char *directory, rgui_file_enum_cb_t file_cb,
|
||||
|
||||
file_cb(ctx,
|
||||
entry->d_name, S_ISDIR(st.st_mode) ?
|
||||
RGUI_FILE_DIRECTORY : RGUI_FILE_PLAIN);
|
||||
RGUI_FILE_DIRECTORY : RGUI_FILE_PLAIN, 0);
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
@ -75,8 +88,6 @@ static bool get_rom_path(rgui_handle_t *rgui)
|
||||
uint16_t old_input_state = 0;
|
||||
bool can_quit = false;
|
||||
|
||||
rgui_iterate(rgui, RGUI_ACTION_REFRESH);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
uint16_t input_state = 0;
|
||||
@ -140,7 +151,7 @@ int main(void)
|
||||
|
||||
#ifdef HAVE_FILE_LOGGER
|
||||
g_extern.verbose = true;
|
||||
log_fp = fopen("sd:/retroarch-log.txt", "w");
|
||||
log_fp = fopen("/retroarch-log.txt", "w");
|
||||
#endif
|
||||
|
||||
config_set_defaults();
|
||||
@ -152,9 +163,10 @@ int main(void)
|
||||
wii_video_init();
|
||||
input_wii.init();
|
||||
|
||||
rgui_handle_t *rgui = rgui_init("sd:/",
|
||||
rgui_handle_t *rgui = rgui_init("",
|
||||
menu_framebuf, RGUI_WIDTH * sizeof(uint16_t),
|
||||
_binary_console_font_bmp_start, folder_cb, NULL);
|
||||
rgui_iterate(rgui, RGUI_ACTION_REFRESH);
|
||||
|
||||
int ret = 0;
|
||||
while (get_rom_path(rgui) && ret == 0)
|
||||
|
@ -98,7 +98,7 @@ rgui_handle_t *rgui_init(const char *base_path,
|
||||
|
||||
rgui->path_stack = rgui_list_new();
|
||||
rgui->folder_buf = rgui_list_new();
|
||||
rgui_list_push(rgui->path_stack, base_path, RGUI_FILE_DIRECTORY);
|
||||
rgui_list_push(rgui->path_stack, base_path, RGUI_FILE_DIRECTORY, 0);
|
||||
|
||||
init_font(rgui, "font.bmp");
|
||||
|
||||
@ -180,7 +180,11 @@ static void render_text(rgui_handle_t *rgui, size_t begin, size_t end)
|
||||
fill_rect(rgui->frame_buf, rgui->frame_buf_pitch,
|
||||
RGUI_WIDTH - 10, 5, 5, RGUI_HEIGHT - 10, green_filler);
|
||||
|
||||
blit_line(rgui, TERM_START_X + 15, 15, "FILE BROWSER\n", true);
|
||||
char title[TERM_WIDTH - 1];
|
||||
const char *dir;
|
||||
rgui_list_back(rgui->path_stack, &dir, NULL, NULL);
|
||||
snprintf(title, sizeof(title), "FILE BROWSER: %s", dir);
|
||||
blit_line(rgui, TERM_START_X + 15, 15, title, true);
|
||||
|
||||
unsigned x = TERM_START_X;
|
||||
unsigned y = TERM_START_Y;
|
||||
@ -189,14 +193,27 @@ static void render_text(rgui_handle_t *rgui, size_t begin, size_t end)
|
||||
{
|
||||
const char *path;
|
||||
rgui_file_type_t type;
|
||||
rgui_list_at(rgui->folder_buf, i, &path, &type);
|
||||
rgui_list_at(rgui->folder_buf, i, &path, &type, NULL);
|
||||
|
||||
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);
|
||||
}
|
||||
@ -263,7 +280,10 @@ const char *rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
|
||||
case RGUI_ACTION_CANCEL:
|
||||
if (rgui_list_size(rgui->path_stack) > 1)
|
||||
{
|
||||
size_t directory_ptr;
|
||||
rgui_list_back(rgui->path_stack, NULL, NULL, &directory_ptr);
|
||||
rgui_list_pop(rgui->path_stack);
|
||||
rgui->directory_ptr = directory_ptr;
|
||||
rgui->need_refresh = true;
|
||||
}
|
||||
break;
|
||||
@ -274,27 +294,40 @@ 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;
|
||||
rgui_list_at(rgui->folder_buf, rgui->directory_ptr,
|
||||
&path, &type);
|
||||
const char *path;
|
||||
rgui_file_type_t type;
|
||||
rgui_list_at(rgui->folder_buf, rgui->directory_ptr, &path, &type, NULL);
|
||||
|
||||
const char *dir;
|
||||
rgui_list_back(rgui->path_stack, &dir, NULL);
|
||||
size_t directory_ptr;
|
||||
rgui_list_back(rgui->path_stack, &dir, NULL, &directory_ptr);
|
||||
|
||||
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->directory_ptr = directory_ptr;
|
||||
rgui_list_pop(rgui->path_stack);
|
||||
}
|
||||
else if (strcmp(path, ".") != 0)
|
||||
{
|
||||
rgui_list_push(rgui->path_stack, cat_path, RGUI_FILE_DIRECTORY, rgui->directory_ptr);
|
||||
rgui->directory_ptr = 0;
|
||||
}
|
||||
rgui->need_refresh = true;
|
||||
}
|
||||
else if (type == RGUI_FILE_DEVICE)
|
||||
{
|
||||
rgui_list_push(rgui->path_stack, path, RGUI_FILE_DEVICE, rgui->directory_ptr);
|
||||
rgui->directory_ptr = 0;
|
||||
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;
|
||||
@ -303,6 +336,7 @@ const char *rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
|
||||
}
|
||||
|
||||
case RGUI_ACTION_REFRESH:
|
||||
rgui->directory_ptr = 0;
|
||||
rgui->need_refresh = true;
|
||||
break;
|
||||
|
||||
@ -312,20 +346,17 @@ const char *rgui_iterate(rgui_handle_t *rgui, rgui_action_t action)
|
||||
|
||||
if (rgui->need_refresh)
|
||||
{
|
||||
rgui->directory_ptr = 0;
|
||||
rgui->need_refresh = false;
|
||||
rgui_list_clear(rgui->folder_buf);
|
||||
|
||||
const char *path = NULL;
|
||||
rgui_list_back(rgui->path_stack, &path, NULL);
|
||||
rgui_list_back(rgui->path_stack, &path, NULL, NULL);
|
||||
|
||||
if (!rgui->folder_cb(path,
|
||||
(rgui_file_enum_cb_t)rgui_list_push,
|
||||
rgui->userdata, rgui->folder_buf))
|
||||
return NULL;
|
||||
rgui->folder_cb(path, (rgui_file_enum_cb_t)rgui_list_push,
|
||||
rgui->userdata, rgui->folder_buf);
|
||||
|
||||
rgui_list_sort(rgui->folder_buf);
|
||||
|
||||
rgui->need_refresh = false;
|
||||
if (*path)
|
||||
rgui_list_sort(rgui->folder_buf);
|
||||
}
|
||||
|
||||
size_t begin = rgui->directory_ptr >= TERM_HEIGHT / 2 ?
|
||||
|
@ -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
|
||||
@ -45,8 +46,8 @@ typedef enum
|
||||
|
||||
typedef struct rgui_handle rgui_handle_t;
|
||||
|
||||
typedef void (*rgui_file_enum_cb_t)(void *ctx, const char *path,
|
||||
rgui_file_type_t file_type);
|
||||
typedef void (*rgui_file_enum_cb_t)(void *ctx,
|
||||
const char *path, rgui_file_type_t file_type, size_t directory_ptr);
|
||||
typedef bool (*rgui_folder_enum_cb_t)(const char *directory,
|
||||
rgui_file_enum_cb_t file_cb, void *userdata, void *ctx);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user