Added R+B shortcut for quick return to root

This commit is contained in:
d0k3 2016-07-26 18:51:16 +02:00
parent d7d6b18e3d
commit 83928cde9a

View File

@ -686,17 +686,23 @@ u32 GodMode() {
} }
} else if (*current_path && ((pad_state & BUTTON_B) || // one level down } else if (*current_path && ((pad_state & BUTTON_B) || // one level down
((pad_state & BUTTON_A) && (curr_entry->type == T_DOTDOT)))) { ((pad_state & BUTTON_A) && (curr_entry->type == T_DOTDOT)))) {
char old_path[256]; if (switched) { // use R+B to return to root fast
char* last_slash = strrchr(current_path, '/'); *current_path = '\0';
strncpy(old_path, current_path, 256); GetDirContents(current_dir, current_path);
if (last_slash) *last_slash = '\0'; cursor = scroll = 0;
else *current_path = '\0'; } else {
GetDirContents(current_dir, current_path); char old_path[256];
if (*old_path && current_dir->n_entries) { char* last_slash = strrchr(current_path, '/');
for (cursor = current_dir->n_entries - 1; strncpy(old_path, current_path, 256);
(cursor > 0) && (strncmp(current_dir->entry[cursor].path, old_path, 256) != 0); cursor--); if (last_slash) *last_slash = '\0';
if (*current_path && !cursor && (current_dir->n_entries > 1)) cursor = 1; // don't set it on the dotdot else *current_path = '\0';
scroll = 0; GetDirContents(current_dir, current_path);
if (*old_path && current_dir->n_entries) {
for (cursor = current_dir->n_entries - 1;
(cursor > 0) && (strncmp(current_dir->entry[cursor].path, old_path, 256) != 0); cursor--);
if (*current_path && !cursor && (current_dir->n_entries > 1)) cursor = 1; // don't set it on the dotdot
scroll = 0;
}
} }
} else if (switched && (pad_state & BUTTON_B)) { // unmount SD card } else if (switched && (pad_state & BUTTON_B)) { // unmount SD card
DeinitExtFS(); DeinitExtFS();