mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-23 04:12:04 +00:00
Add basic folder navigation
+ Add hekate/ams to shutdown menu
This commit is contained in:
parent
cd4f2cd347
commit
79027591ac
4 changed files with 92 additions and 8 deletions
|
@ -24,6 +24,38 @@ char *getnextloc(char *current, char *add){
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *getprevloc(char *current){
|
||||||
|
char *ret, *temp;
|
||||||
|
size_t size = strlen(current) + 1;
|
||||||
|
|
||||||
|
ret = (char*) malloc (size);
|
||||||
|
strcpy(ret, current);
|
||||||
|
|
||||||
|
temp = strrchr(ret, '/');
|
||||||
|
memset(temp, '\0', 1);
|
||||||
|
|
||||||
|
if (strlen(rootpath) > strlen(ret))
|
||||||
|
strcpy(ret, rootpath);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
fs_entry getfileobj(int spot){
|
||||||
|
return fileobjects[spot];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool checkfile(char* path){
|
||||||
|
FRESULT fr;
|
||||||
|
FILINFO fno;
|
||||||
|
|
||||||
|
fr = f_stat(path, &fno);
|
||||||
|
|
||||||
|
if (fr & FR_NO_FILE)
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void addobject(char* name, int spot, bool isfol, bool isarc){
|
void addobject(char* name, int spot, bool isfol, bool isarc){
|
||||||
size_t size = strlen(name) + 1;
|
size_t size = strlen(name) + 1;
|
||||||
fileobjects[spot].property = 0;
|
fileobjects[spot].property = 0;
|
||||||
|
@ -76,10 +108,34 @@ int readfolder(const char *path){
|
||||||
}
|
}
|
||||||
|
|
||||||
void filemenu(const char *startpath){
|
void filemenu(const char *startpath){
|
||||||
int amount;
|
int amount, res;
|
||||||
strcpy(rootpath, startpath);
|
strcpy(rootpath, startpath);
|
||||||
strcpy(currentpath, startpath);
|
strcpy(currentpath, startpath);
|
||||||
|
|
||||||
amount = readfolder(currentpath);
|
amount = readfolder(currentpath);
|
||||||
makefilemenu(fileobjects, amount, currentpath);
|
|
||||||
|
while (1){
|
||||||
|
res = makefilemenu(fileobjects, amount, currentpath);
|
||||||
|
if (res < 1){
|
||||||
|
if (res == -2){
|
||||||
|
if (!strcmp(rootpath, currentpath))
|
||||||
|
break;
|
||||||
|
else {
|
||||||
|
strcpy(currentpath, getprevloc(currentpath));
|
||||||
|
amount = readfolder(currentpath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (res == -1){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (fileobjects[res - 1].property & ISDIR){
|
||||||
|
strcpy(currentpath, getnextloc(currentpath, fileobjects[res - 1].name));
|
||||||
|
amount = readfolder(currentpath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -26,3 +26,4 @@ typedef struct _fs_entry {
|
||||||
|
|
||||||
int readfolder(const char *path);
|
int readfolder(const char *path);
|
||||||
void filemenu();
|
void filemenu();
|
||||||
|
bool checkfile(char* path);
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
extern bool sd_mount();
|
extern bool sd_mount();
|
||||||
extern void sd_unmount();
|
extern void sd_unmount();
|
||||||
|
extern int launch_payload(char *path);
|
||||||
bool sd_mounted;
|
bool sd_mounted;
|
||||||
|
|
||||||
menu_item mainmenu[MAINMENU_AMOUNT] = {
|
menu_item mainmenu[MAINMENU_AMOUNT] = {
|
||||||
|
@ -19,12 +20,14 @@ menu_item mainmenu[MAINMENU_AMOUNT] = {
|
||||||
{"Exit", COLOR_WHITE, EXIT, 1}
|
{"Exit", COLOR_WHITE, EXIT, 1}
|
||||||
};
|
};
|
||||||
|
|
||||||
menu_item shutdownmenu[5] = {
|
menu_item shutdownmenu[7] = {
|
||||||
{"-- EXIT --\n", COLOR_ORANGE, -1, 0},
|
{"-- EXIT --\n", COLOR_ORANGE, -1, 0},
|
||||||
{"Back", COLOR_WHITE, -1, 1},
|
{"Back", COLOR_WHITE, -1, 1},
|
||||||
{"\nReboot to RCM", COLOR_VIOLET, REBOOT_RCM, 1},
|
{"\nReboot to RCM", COLOR_VIOLET, REBOOT_RCM, 1},
|
||||||
{"Reboot normally", COLOR_ORANGE, REBOOT_NORMAL, 1},
|
{"Reboot normally", COLOR_ORANGE, REBOOT_NORMAL, 1},
|
||||||
{"Power off", COLOR_BLUE, POWER_OFF, 1}
|
{"Power off\n", COLOR_BLUE, POWER_OFF, 1},
|
||||||
|
{"Reboot to Hekate", COLOR_GREEN, HEKATE, -1},
|
||||||
|
{"Reboot to Atmosphere", COLOR_GREEN, AMS, -1}
|
||||||
};
|
};
|
||||||
|
|
||||||
menu_item toolsmenu[3] = {
|
menu_item toolsmenu[3] = {
|
||||||
|
@ -96,7 +99,23 @@ void te_main(){
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EXIT:
|
case EXIT:
|
||||||
res = makemenu(shutdownmenu, 5);
|
if (sd_mounted){
|
||||||
|
if (checkfile("/bootloader/update.bin"))
|
||||||
|
shutdownmenu[5].property = 1;
|
||||||
|
else
|
||||||
|
shutdownmenu[5].property = -1;
|
||||||
|
|
||||||
|
if (checkfile("/atmosphere/reboot_payload.bin"))
|
||||||
|
shutdownmenu[6].property = 1;
|
||||||
|
else
|
||||||
|
shutdownmenu[6].property = -1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
shutdownmenu[5].property = -1;
|
||||||
|
shutdownmenu[6].property = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = makemenu(shutdownmenu, 7);
|
||||||
|
|
||||||
switch(res){
|
switch(res){
|
||||||
case REBOOT_RCM:
|
case REBOOT_RCM:
|
||||||
|
@ -107,6 +126,12 @@ void te_main(){
|
||||||
|
|
||||||
case POWER_OFF:
|
case POWER_OFF:
|
||||||
power_off();
|
power_off();
|
||||||
|
|
||||||
|
case HEKATE:
|
||||||
|
launch_payload("/bootloader/update.bin");
|
||||||
|
|
||||||
|
case AMS:
|
||||||
|
launch_payload("/atmosphere/reboot_payload.bin");
|
||||||
} //todo declock bpmp
|
} //todo declock bpmp
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -23,7 +23,9 @@ enum mainmenu_return {
|
||||||
enum shutdownmenu_return {
|
enum shutdownmenu_return {
|
||||||
REBOOT_RCM = 1,
|
REBOOT_RCM = 1,
|
||||||
REBOOT_NORMAL,
|
REBOOT_NORMAL,
|
||||||
POWER_OFF
|
POWER_OFF,
|
||||||
|
HEKATE,
|
||||||
|
AMS
|
||||||
};
|
};
|
||||||
|
|
||||||
enum toolsmenu_return {
|
enum toolsmenu_return {
|
||||||
|
|
Loading…
Reference in a new issue