From 3d65eb4b6d1f1343dd9a0f2faa29c96daec9b341 Mon Sep 17 00:00:00 2001 From: rsn8887 Date: Wed, 7 Feb 2018 01:22:38 -0600 Subject: [PATCH] implemented loading files from uma0: --- Readme.txt | 5 +++ src/gp2x/menu/menu_load.cpp | 83 ++++++++++++++++++++++++------------- 2 files changed, 59 insertions(+), 29 deletions(-) diff --git a/Readme.txt b/Readme.txt index ae20389..79a46f3 100755 --- a/Readme.txt +++ b/Readme.txt @@ -125,6 +125,11 @@ single finger drag = move the mouse pointer dual finger drag = drag'n'drop (left mouse button is held down) CHANGELOG: +1.60 + +- support for uma0: added +- prevent suspend mode because it can corrupt hdf files + 1.59 - implemented touchpad-style pointer controls. Touch controls are configured under 'More Options/Touch.' Choices are 'Touch Off', 'Front only', or 'Front and Back.' The default is to use only the front panel. Both panels work the same, using relative touch mode. How far a certain finger motion moves the pointer depends on the Mouse Speed setting, which also affects how fast the analog stick moves the mouse. diff --git a/src/gp2x/menu/menu_load.cpp b/src/gp2x/menu/menu_load.cpp index bc572b3..1217484 100755 --- a/src/gp2x/menu/menu_load.cpp +++ b/src/gp2x/menu/menu_load.cpp @@ -220,38 +220,55 @@ static int menuLoadLoop(char *curr_path) max_in_dir=SHOW_MAX_FILES; #ifdef __PSP2__ - if(strcmp(curr_path, "/") == 0) - strcpy(curr_path, "ux0:/"); - - if ((dir = opendir(curr_path)) == NULL) + if(strcmp(curr_path, "/") == 0 || curr_path[0] == 0) { - printf("opendir failed: %s\n", curr_path); - char *p; - for (p = curr_path + strlen(curr_path) - 1; p > curr_path && *p != '/'; p--); - *p = 0; - fname = p+1; - dir = opendir(curr_path); + struct dirent *ent = NULL; + n = 0; + namelist = (struct dirent **)malloc(3*1024 * sizeof(struct dirent *)); // < 3*1024 files + namelist[0] = (struct dirent *)malloc(sizeof(struct dirent)); + strcpy(namelist[0]->d_name, "."); + namelist[0]->d_type = DT_DIR; n++; + namelist[1] = (struct dirent *)malloc(sizeof(struct dirent)); + strcpy(namelist[1]->d_name, "ux0:"); + namelist[1]->d_type = DT_DIR; n++; + namelist[2] = (struct dirent *)malloc(sizeof(struct dirent)); + strcpy(namelist[2]->d_name, "uma0:"); + namelist[2]->d_type = DT_DIR; n++; + + curr_path[0] == 0; } + else + { + if ((dir = opendir(curr_path)) == NULL) + { + printf("opendir failed: %s\n", curr_path); + char *p; + for (p = curr_path + strlen(curr_path) - 1; p > curr_path && *p != '/'; p--); + *p = 0; + fname = p+1; + dir = opendir(curr_path); + } - struct dirent *ent = NULL; - n = 0; - namelist = (struct dirent **)malloc(3*1024 * sizeof(struct dirent *)); // < 3*1024 files - namelist[0] = (struct dirent *)malloc(sizeof(struct dirent)); - strcpy(namelist[0]->d_name, "."); - namelist[0]->d_type = DT_DIR; n++; - namelist[1] = (struct dirent *)malloc(sizeof(struct dirent)); - strcpy(namelist[1]->d_name, ".."); - namelist[1]->d_type = DT_DIR; n++; - - while ((ent = readdir (dir)) != NULL) { - if(n >= 3*1024-1) - break; - namelist[n] = (struct dirent *)malloc(sizeof(struct dirent)); - memcpy(namelist[n], ent, sizeof(struct dirent)); - n++; + struct dirent *ent = NULL; + n = 0; + namelist = (struct dirent **)malloc(3*1024 * sizeof(struct dirent *)); // < 3*1024 files + namelist[0] = (struct dirent *)malloc(sizeof(struct dirent)); + strcpy(namelist[0]->d_name, "."); + namelist[0]->d_type = DT_DIR; n++; + namelist[1] = (struct dirent *)malloc(sizeof(struct dirent)); + strcpy(namelist[1]->d_name, ".."); + namelist[1]->d_type = DT_DIR; n++; + + while ((ent = readdir (dir)) != NULL) { + if(n >= 3*1024-1) + break; + namelist[n] = (struct dirent *)malloc(sizeof(struct dirent)); + memcpy(namelist[n], ent, sizeof(struct dirent)); + n++; + } + closedir(dir); } - closedir(dir); - + if(n <= 0) { return 0; } @@ -409,7 +426,7 @@ static int menuLoadLoop(char *curr_path) else { newdir=(char*)malloc(newlen); - if (strcmp(namelist[sel+1]->d_name, "..") == 0) + if (strcmp(namelist[sel+1]->d_name, "..") == 0) { char *start = curr_path; p = start + strlen(start) - 1; @@ -418,6 +435,14 @@ static int menuLoadLoop(char *curr_path) if (p <= start) strcpy(newdir, "/"); else { strncpy(newdir, start, p-start); newdir[p-start] = 0; } } + else if (strcmp(namelist[sel+1]->d_name, "ur0:") == 0) + { + strcpy(newdir, "ur0:/"); + } + else if (strcmp(namelist[sel+1]->d_name, "ux0:") == 0) + { + strcpy(newdir, "ux0:/"); + } else { strcpy(newdir, curr_path);