mirror of
https://github.com/rvtr/GodMode9i.git
synced 2025-11-02 00:11:07 -04:00
Improve screen swap (#164)
This commit is contained in:
parent
fb9b56f622
commit
68a81840d6
@ -97,11 +97,7 @@ DumpOption dumpMenu(std::vector<DumpOption> allowedOptions, const char *dumpName
|
|||||||
pressed = keysDownRepeat();
|
pressed = keysDownRepeat();
|
||||||
held = keysHeld();
|
held = keysHeld();
|
||||||
swiWaitForVBlank();
|
swiWaitForVBlank();
|
||||||
} while (!(pressed & (KEY_UP| KEY_DOWN | KEY_A | KEY_B | KEY_L))
|
} while (!(pressed & (KEY_UP| KEY_DOWN | KEY_A | KEY_B | KEY_L)));
|
||||||
#ifdef SCREENSWAP
|
|
||||||
&& !(pressed & KEY_TOUCH)
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
if (pressed & KEY_UP)
|
if (pressed & KEY_UP)
|
||||||
optionOffset--;
|
optionOffset--;
|
||||||
@ -114,19 +110,13 @@ DumpOption dumpMenu(std::vector<DumpOption> allowedOptions, const char *dumpName
|
|||||||
if (optionOffset >= (int)allowedOptions.size()) // Wrap around to top of list
|
if (optionOffset >= (int)allowedOptions.size()) // Wrap around to top of list
|
||||||
optionOffset = 0;
|
optionOffset = 0;
|
||||||
|
|
||||||
if (pressed & KEY_A)
|
if (pressed & KEY_A) {
|
||||||
return allowedOptions[optionOffset];
|
return allowedOptions[optionOffset];
|
||||||
|
|
||||||
if (pressed & KEY_B)
|
|
||||||
return DumpOption::none;
|
|
||||||
|
|
||||||
#ifdef SCREENSWAP
|
|
||||||
// Swap screens
|
|
||||||
if (pressed & KEY_TOUCH) {
|
|
||||||
screenSwapped = !screenSwapped;
|
|
||||||
screenSwapped ? lcdMainOnBottom() : lcdMainOnTop();
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
if (pressed & KEY_B) {
|
||||||
|
return DumpOption::none;
|
||||||
|
}
|
||||||
|
|
||||||
// Make a screenshot
|
// Make a screenshot
|
||||||
if ((held & KEY_R) && (pressed & KEY_L)) {
|
if ((held & KEY_R) && (pressed & KEY_L)) {
|
||||||
@ -740,6 +730,10 @@ void ndsCardSaveRestore(const char *filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ndsCardDump(void) {
|
void ndsCardDump(void) {
|
||||||
|
#ifdef SCREENSWAP
|
||||||
|
lcdMainOnTop();
|
||||||
|
#endif
|
||||||
|
|
||||||
u16 pressed;
|
u16 pressed;
|
||||||
|
|
||||||
font->clear(false);
|
font->clear(false);
|
||||||
@ -758,6 +752,9 @@ void ndsCardDump(void) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (pressed & KEY_B) {
|
if (pressed & KEY_B) {
|
||||||
|
#ifdef SCREENSWAP
|
||||||
|
screenSwapped ? lcdMainOnBottom() : lcdMainOnTop();
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -928,8 +925,11 @@ void ndsCardDump(void) {
|
|||||||
fclose(destinationFile);
|
fclose(destinationFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
#ifdef SCREENSWAP
|
||||||
|
screenSwapped ? lcdMainOnBottom() : lcdMainOnTop();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void gbaCartSaveDump(const char *filename) {
|
void gbaCartSaveDump(const char *filename) {
|
||||||
font->clear(false);
|
font->clear(false);
|
||||||
@ -1023,6 +1023,10 @@ void readChange(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void gbaCartDump(void) {
|
void gbaCartDump(void) {
|
||||||
|
#ifdef SCREENSWAP
|
||||||
|
lcdMainOnTop();
|
||||||
|
#endif
|
||||||
|
|
||||||
font->clear(false);
|
font->clear(false);
|
||||||
font->print(0, 0, false, STR_LOADING);
|
font->print(0, 0, false, STR_LOADING);
|
||||||
font->update(false);
|
font->update(false);
|
||||||
@ -1236,4 +1240,8 @@ void gbaCartDump(void) {
|
|||||||
fclose(destinationFile);
|
fclose(destinationFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SCREENSWAP
|
||||||
|
screenSwapped ? lcdMainOnBottom() : lcdMainOnTop();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@ -170,6 +170,10 @@ void showDirectoryContents(std::vector<DirEntry> &dirContents, int fileOffset, i
|
|||||||
}
|
}
|
||||||
|
|
||||||
FileOperation fileBrowse_A(DirEntry* entry, char path[PATH_MAX]) {
|
FileOperation fileBrowse_A(DirEntry* entry, char path[PATH_MAX]) {
|
||||||
|
#ifdef SCREENSWAP
|
||||||
|
lcdMainOnTop();
|
||||||
|
#endif
|
||||||
|
|
||||||
int pressed = 0, held = 0;
|
int pressed = 0, held = 0;
|
||||||
std::vector<FileOperation> operations;
|
std::vector<FileOperation> operations;
|
||||||
int optionOffset = 0;
|
int optionOffset = 0;
|
||||||
@ -295,13 +299,13 @@ FileOperation fileBrowse_A(DirEntry* entry, char path[PATH_MAX]) {
|
|||||||
held = keysHeld();
|
held = keysHeld();
|
||||||
swiWaitForVBlank();
|
swiWaitForVBlank();
|
||||||
|
|
||||||
if(driveRemoved(currentDrive))
|
if(driveRemoved(currentDrive)) {
|
||||||
return FileOperation::none;
|
|
||||||
} while (!(pressed & (KEY_UP| KEY_DOWN | KEY_A | KEY_B | KEY_L))
|
|
||||||
#ifdef SCREENSWAP
|
#ifdef SCREENSWAP
|
||||||
&& !(pressed & KEY_TOUCH)
|
screenSwapped ? lcdMainOnBottom() : lcdMainOnTop();
|
||||||
#endif
|
#endif
|
||||||
);
|
return FileOperation::none;
|
||||||
|
}
|
||||||
|
} while (!(pressed & (KEY_UP| KEY_DOWN | KEY_A | KEY_B | KEY_L)));
|
||||||
|
|
||||||
if (pressed & KEY_UP) optionOffset -= 1;
|
if (pressed & KEY_UP) optionOffset -= 1;
|
||||||
if (pressed & KEY_DOWN) optionOffset += 1;
|
if (pressed & KEY_DOWN) optionOffset += 1;
|
||||||
@ -463,18 +467,16 @@ FileOperation fileBrowse_A(DirEntry* entry, char path[PATH_MAX]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
keysDownRepeat(); // prevent unwanted key repeat
|
keysDownRepeat(); // prevent unwanted key repeat
|
||||||
|
#ifdef SCREENSWAP
|
||||||
|
screenSwapped ? lcdMainOnBottom() : lcdMainOnTop();
|
||||||
|
#endif
|
||||||
return operations[optionOffset];
|
return operations[optionOffset];
|
||||||
} else if (pressed & KEY_B) {
|
} else if (pressed & KEY_B) {
|
||||||
|
#ifdef SCREENSWAP
|
||||||
|
screenSwapped ? lcdMainOnBottom() : lcdMainOnTop();
|
||||||
|
#endif
|
||||||
return FileOperation::none;
|
return FileOperation::none;
|
||||||
}
|
}
|
||||||
#ifdef SCREENSWAP
|
|
||||||
// Swap screens
|
|
||||||
else if (pressed & KEY_TOUCH) {
|
|
||||||
screenSwapped = !screenSwapped;
|
|
||||||
screenSwapped ? lcdMainOnBottom() : lcdMainOnTop();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Make a screenshot
|
// Make a screenshot
|
||||||
else if ((held & KEY_R) && (pressed & KEY_L)) {
|
else if ((held & KEY_R) && (pressed & KEY_L)) {
|
||||||
screenshot();
|
screenshot();
|
||||||
@ -483,6 +485,10 @@ FileOperation fileBrowse_A(DirEntry* entry, char path[PATH_MAX]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool fileBrowse_paste(char dest[256]) {
|
bool fileBrowse_paste(char dest[256]) {
|
||||||
|
#ifdef SCREENSWAP
|
||||||
|
lcdMainOnTop();
|
||||||
|
#endif
|
||||||
|
|
||||||
int pressed = 0;
|
int pressed = 0;
|
||||||
int optionOffset = 0;
|
int optionOffset = 0;
|
||||||
|
|
||||||
@ -512,12 +518,7 @@ bool fileBrowse_paste(char dest[256]) {
|
|||||||
scanKeys();
|
scanKeys();
|
||||||
pressed = keysDownRepeat();
|
pressed = keysDownRepeat();
|
||||||
swiWaitForVBlank();
|
swiWaitForVBlank();
|
||||||
} while (!(pressed & KEY_UP) && !(pressed & KEY_DOWN)
|
} while (!(pressed & (KEY_UP | KEY_DOWN | KEY_A | KEY_B)));
|
||||||
&& !(pressed & KEY_A) && !(pressed & KEY_B)
|
|
||||||
#ifdef SCREENSWAP
|
|
||||||
&& !(pressed & KEY_TOUCH)
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
if (pressed & KEY_UP) optionOffset -= 1;
|
if (pressed & KEY_UP) optionOffset -= 1;
|
||||||
if (pressed & KEY_DOWN) optionOffset += 1;
|
if (pressed & KEY_DOWN) optionOffset += 1;
|
||||||
@ -546,18 +547,17 @@ bool fileBrowse_paste(char dest[256]) {
|
|||||||
}
|
}
|
||||||
clipboardUsed = true; // Disable clipboard restore
|
clipboardUsed = true; // Disable clipboard restore
|
||||||
clipboardOn = false; // Clear clipboard after copying or moving
|
clipboardOn = false; // Clear clipboard after copying or moving
|
||||||
|
#ifdef SCREENSWAP
|
||||||
|
screenSwapped ? lcdMainOnBottom() : lcdMainOnTop();
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (pressed & KEY_B) {
|
if (pressed & KEY_B) {
|
||||||
|
#ifdef SCREENSWAP
|
||||||
|
screenSwapped ? lcdMainOnBottom() : lcdMainOnTop();
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#ifdef SCREENSWAP
|
|
||||||
// Swap screens
|
|
||||||
if (pressed & KEY_TOUCH) {
|
|
||||||
screenSwapped = !screenSwapped;
|
|
||||||
screenSwapped ? lcdMainOnBottom() : lcdMainOnTop();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,7 +660,7 @@ std::string browseForFile (void) {
|
|||||||
screenMode = 0;
|
screenMode = 0;
|
||||||
return "null";
|
return "null";
|
||||||
}
|
}
|
||||||
} while (!(pressed & ~(KEY_R | KEY_TOUCH | KEY_LID)));
|
} while (!(pressed & ~(KEY_R | KEY_LID)));
|
||||||
|
|
||||||
if (pressed & KEY_UP) {
|
if (pressed & KEY_UP) {
|
||||||
fileOffset--;
|
fileOffset--;
|
||||||
|
|||||||
@ -1,11 +1,16 @@
|
|||||||
#include "keyboard.h"
|
#include "keyboard.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
|
#include "main.h"
|
||||||
|
|
||||||
#include <nds.h>
|
#include <nds.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
std::string kbdGetString(std::string label, int maxSize, std::string oldStr) {
|
std::string kbdGetString(std::string label, int maxSize, std::string oldStr) {
|
||||||
|
#ifdef SCREENSWAP
|
||||||
|
lcdMainOnTop();
|
||||||
|
#endif
|
||||||
|
|
||||||
font->clear(false);
|
font->clear(false);
|
||||||
font->update(false);
|
font->update(false);
|
||||||
|
|
||||||
@ -34,11 +39,7 @@ std::string kbdGetString(std::string label, int maxSize, std::string oldStr) {
|
|||||||
pressed = keysDownRepeat();
|
pressed = keysDownRepeat();
|
||||||
key = keyboardUpdate();
|
key = keyboardUpdate();
|
||||||
swiWaitForVBlank();
|
swiWaitForVBlank();
|
||||||
} while (!((pressed & (KEY_LEFT | KEY_RIGHT | KEY_B | KEY_START
|
} while (!((pressed & (KEY_LEFT | KEY_RIGHT | KEY_B | KEY_START)) || (key != -1)));
|
||||||
#ifdef SCREENSWAP
|
|
||||||
&& !(pressed & KEY_TOUCH)
|
|
||||||
#endif
|
|
||||||
)) || (key != -1)));
|
|
||||||
|
|
||||||
switch(key) {
|
switch(key) {
|
||||||
case NOKEY:
|
case NOKEY:
|
||||||
@ -97,5 +98,9 @@ std::string kbdGetString(std::string label, int maxSize, std::string oldStr) {
|
|||||||
}
|
}
|
||||||
keyboardHide();
|
keyboardHide();
|
||||||
|
|
||||||
|
#ifdef SCREENSWAP
|
||||||
|
screenSwapped ? lcdMainOnBottom() : lcdMainOnTop();
|
||||||
|
#endif
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,7 +45,7 @@
|
|||||||
|
|
||||||
#include "gm9i_logo.h"
|
#include "gm9i_logo.h"
|
||||||
|
|
||||||
char titleName[32] = {" "};
|
char titleName[64] = {" "};
|
||||||
|
|
||||||
int screenMode = 0;
|
int screenMode = 0;
|
||||||
|
|
||||||
@ -115,7 +115,11 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
bool yHeld = false;
|
bool yHeld = false;
|
||||||
|
|
||||||
|
#ifdef SCREENSWAP
|
||||||
|
sprintf(titleName, "GodMode9i (Screen Swap) %s", VER_NUMBER);
|
||||||
|
#else
|
||||||
sprintf(titleName, "GodMode9i %s", VER_NUMBER);
|
sprintf(titleName, "GodMode9i %s", VER_NUMBER);
|
||||||
|
#endif
|
||||||
|
|
||||||
// initialize video mode
|
// initialize video mode
|
||||||
videoSetMode(MODE_5_2D);
|
videoSetMode(MODE_5_2D);
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#include "fileOperations.h"
|
#include "fileOperations.h"
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
#include "language.h"
|
#include "language.h"
|
||||||
|
#include "main.h"
|
||||||
#include "screenshot.h"
|
#include "screenshot.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user