driveMenu: Fix text re-printing, if R button is held

This commit is contained in:
Robz8 2018-10-04 20:51:36 -06:00
parent 9cfe9e1445
commit 4228719d2a

View File

@ -33,6 +33,7 @@
using namespace std;
static bool dmTextPrinted = false;
static int dmCursorPosition = 0;
static bool sdMounted = false;
@ -45,6 +46,7 @@ void driveMenu (void) {
}
while (true) {
if (!dmTextPrinted) {
consoleInit(NULL, 1, BgType_Text4bpp, BgSize_T_256x256, 15, 0, false, true);
if (dmCursorPosition == 0 && isDSiMode()) {
printf ("[sd:] SDCARD\n");
@ -91,6 +93,9 @@ void driveMenu (void) {
printf ("[x]");
}
dmTextPrinted = true;
}
// Power saving loop. Only poll the keys once per frame and sleep the CPU if there is nothing else to do
do {
// Move to right side of screen
@ -104,8 +109,14 @@ void driveMenu (void) {
swiWaitForVBlank();
} while (!(pressed & KEY_UP) && !(pressed & KEY_DOWN) && !(pressed & KEY_A) && !(held & KEY_R));
if ((pressed & KEY_UP) && isDSiMode()) dmCursorPosition -= 1;
if ((pressed & KEY_DOWN) && isDSiMode()) dmCursorPosition += 1;
if ((pressed & KEY_UP) && isDSiMode()) {
dmCursorPosition -= 1;
dmTextPrinted = false;
}
if ((pressed & KEY_DOWN) && isDSiMode()) {
dmCursorPosition += 1;
dmTextPrinted = false;
}
if (dmCursorPosition < 0) dmCursorPosition = 1; // Wrap around to bottom of list
if (dmCursorPosition > 1) dmCursorPosition = 0; // Wrap around to top of list
@ -113,6 +124,7 @@ void driveMenu (void) {
if (pressed & KEY_A) {
if (dmCursorPosition == 0 && isDSiMode()) {
if (sdMounted) {
dmTextPrinted = false;
chdir("sd:/");
screenMode = 1;
break;
@ -122,6 +134,7 @@ void driveMenu (void) {
flashcardMount();
}
if (flashcardFound()) {
dmTextPrinted = false;
chdir("fat:/");
screenMode = 1;
break;
@ -132,9 +145,11 @@ void driveMenu (void) {
// Unmount/Remount SD card
if ((held & KEY_R) && (pressed & KEY_B) && isDSiMode()) {
if (sdMounted) {
dmTextPrinted = false;
sdUnmount();
sdMounted = false;
} else {
dmTextPrinted = false;
sdMounted = sdMount();
}
}