1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-22 20:06:43 +00:00

Ignore menu entries in entries count and include sd ejection detection

This commit is contained in:
Such Meme, Many Skill 2020-03-22 22:56:36 +01:00
parent e4ae9d9d7c
commit bfcdc2ffd5
9 changed files with 45 additions and 27 deletions

View file

@ -45,20 +45,11 @@
sdmmc_t sd_sdmmc;
sdmmc_storage_t sd_storage;
__attribute__ ((aligned (16))) FATFS sd_fs;
static bool sd_mounted, sd_inited;
bool sd_mounted, sd_inited;
volatile nyx_storage_t *nyx_str = (nyx_storage_t *)NYX_STORAGE_ADDR;
hekate_config h_cfg;
boot_cfg_t __attribute__((section ("._boot_cfg"))) b_cfg;
bool return_sd_mounted(int value){
switch(value){
case 10:
return sd_inited;
default:
return sd_mounted;
}
}
bool sd_mount()
{
if (sd_mounted)

View file

@ -19,7 +19,8 @@ enum utils_err_codes_te_call {
ERR_MEM_ALLOC_FAILED,
ERR_EMMC_READ_FAILED,
ERR_EMMC_WRITE_FAILED,
ERR_FILE_TOO_BIG_FOR_DEST
ERR_FILE_TOO_BIG_FOR_DEST,
ERR_SD_EJECTED
};
extern const char *utils_err_codes_te[];

View file

@ -48,7 +48,8 @@ const char *utils_err_codes_te[] = { // these start at 50
"MEM ALLOC FAILED",
"EMMC READ FAILED",
"EMMC WRITE FAILED",
"FILE TOO BIG FOR DEST"
"FILE TOO BIG FOR DEST",
"SD EJECTED"
};
const char *pkg2names[] = {

View file

@ -179,6 +179,8 @@ int filemenu(menu_entry file){
case FILE_RESTOREBIS:
restore_bis_using_file(fsutil_getnextloc(currentpath, file.name), SYSMMC);
break;
case -1:
return -1;
}
return 0;

View file

@ -66,6 +66,7 @@ int foldermenu(){
switch (res){
case DIR_EXITFOLDER:
case -1:
return -1;
case DIR_COPYFOLDER:
fsreader_writeclipboard(currentpath, OPERATIONCOPY | ISDIR);

View file

@ -54,6 +54,8 @@ void fileexplorer(const char *startpath, int type){
if (foldermenu())
return;
break;
case -1:
return;
default:
if(fsreader_files[res].property & ISDIR){
@ -61,7 +63,8 @@ void fileexplorer(const char *startpath, int type){
fsreader_readfolder(currentpath);
}
else
filemenu(fsreader_files[res]);
if(filemenu(fsreader_files[res]))
return;
break;
}

View file

@ -54,7 +54,7 @@ int gfx_errDisplay(char *src_func, int err, int loc){
if (err < 15)
gfx_printf("Desc: %s\n", utils_err_codes[err]);
else if (err >= ERR_SAME_LOC && err <= ERR_FILE_TOO_BIG_FOR_DEST)
else if (err >= ERR_SAME_LOC && err <= ERR_SD_EJECTED)
gfx_printf("Desc: %s\n", utils_err_codes_te[err - 50]);
if (loc)

View file

@ -5,6 +5,11 @@
#include "../common/common.h"
#include "../../utils/util.h"
#include "../../mem/minerva.h"
#include "../../soc/gpio.h"
#include "gfxutils.h"
extern void sd_unmount();
extern bool sd_inited;
void _printentry(menu_entry entry, bool highlighted, bool refresh){
int size;
@ -54,17 +59,25 @@ void _printentry(menu_entry entry, bool highlighted, bool refresh){
}
int menu_make(menu_entry *entries, int amount, char *toptext){
int currentpos = 0, res = 0, offset = 0, delay = 300, minscreen = 0, maxscreen = 59;
int currentpos = 0, res = 0, offset = 0, delay = 300, minscreen = 0, maxscreen = 59, calculatedamount = 0;
u32 scrolltimer, timer;
bool refresh = false;
gfx_clearscreen();
for (int i = 0; i < amount; i++)
if (!(entries[i].property & ISMENU))
calculatedamount++;
gfx_con_setpos(512, 0);
if (calculatedamount){
SWAPCOLOR(COLOR_DEFAULT);
SWAPBGCOLOR(COLOR_WHITE);
gfx_printf("%3d entries\n", amount);
RESETCOLOR;
}
else
gfx_printf("\n");
SWAPCOLOR(COLOR_GREEN);
gfx_printlength(42, toptext);
@ -108,6 +121,14 @@ int menu_make(menu_entry *entries, int amount, char *toptext){
res = 0;
while (!res){
if (!res){
if (sd_inited && !!gpio_read(GPIO_PORT_Z, GPIO_PIN_1)){
gfx_errDisplay("menu", ERR_SD_EJECTED, 0);
sd_unmount();
return -1;
}
}
res = btn_read();
if (!res)

View file

@ -19,8 +19,9 @@
extern bool sd_mount();
extern void sd_unmount();
extern bool return_sd_mounted(int value);
extern int launch_payload(char *path);
extern bool sd_inited;
extern bool sd_mounted;
int res = 0, meter = 0;
@ -47,10 +48,7 @@ void MainMenu_EMUMMC(){
}
void MainMenu_MountSD(){
if (return_sd_mounted(1))
sd_unmount();
else
sd_mount();
(sd_mounted) ? sd_unmount() : sd_mount();
}
void MainMenu_Tools(){
@ -100,7 +98,7 @@ void MainMenu_Credits(){
}
void MainMenu_Exit(){
if (return_sd_mounted(1)){
if (sd_mounted){
SETBIT(mainmenu_shutdown[4].property, ISHIDE, !fsutil_checkfile("/bootloader/update.bin"));
SETBIT(mainmenu_shutdown[5].property, ISHIDE, !fsutil_checkfile("/atmosphere/reboot_payload.bin"));
}
@ -169,7 +167,7 @@ void te_main(){
while (1){
//fillmainmenu();
setter = return_sd_mounted(1);
setter = sd_mounted;
if (emu_cfg.enabled){
for (int i = 4; i <= 6; i++)
@ -179,7 +177,7 @@ void te_main(){
SETBIT(mainmenu_main[0].property, ISHIDE, !setter);
mainmenu_main[7].name = (menu_sd_states[!setter]);
setter = return_sd_mounted(10);
setter = sd_inited;
SETBIT(mainmenu_main[9].property, ISHIDE, !setter);
res = menu_make(mainmenu_main, 12, "-- Main Menu --") + 1;