From 97aa90034a757ba20a2f515ff2b8f24804620c45 Mon Sep 17 00:00:00 2001 From: J-D-K Date: Sun, 20 Dec 2020 01:20:35 -0500 Subject: [PATCH] Quick and dirty HID update --- Makefile | 2 +- inc/data.h | 14 +++++------ inc/file.h | 6 ----- inc/ui.h | 8 +++++++ inc/util.h | 2 -- romfs/lang/en-US.txt | 2 +- src/data.cpp | 54 +++++++++++++++++++++++++++++-------------- src/file.cpp | 48 ++------------------------------------ src/main.cpp | 10 ++++---- src/ui.cpp | 9 ++++++-- src/ui/advmode.cpp | 10 ++++---- src/ui/fldrsel.cpp | 20 ++++++++-------- src/ui/menu.cpp | 4 ++-- src/ui/miscui.cpp | 18 +++++++-------- src/ui/ttlsel.cpp | 36 ++++++++++++++--------------- src/ui/txtui.cpp | 55 +++++++++++++++++++++----------------------- src/ui/uistr.cpp | 2 +- src/ui/usrsel.cpp | 28 +++++++++++----------- src/util.cpp | 5 ---- 19 files changed, 152 insertions(+), 181 deletions(-) diff --git a/Makefile b/Makefile index d7c060b..497af58 100644 --- a/Makefile +++ b/Makefile @@ -38,7 +38,7 @@ INCLUDES := inc EXEFS_SRC := exefs_src APP_TITLE := JKSV APP_AUTHOR := JK -APP_VERSION := 11.01.2020 +APP_VERSION := 12.20.2020 ROMFS := romfs ICON := romfs/icon.jpg diff --git a/inc/data.h b/inc/data.h index 64da150..874ef2e 100644 --- a/inc/data.h +++ b/inc/data.h @@ -12,8 +12,8 @@ #define curUser users[data::selUser] #define curData users[data::selUser].titles[data::selData] -#define BLD_MON 11 -#define BLD_DAY 01 +#define BLD_MON 12 +#define BLD_DAY 20 #define BLD_YEAR 2020 namespace data @@ -67,9 +67,9 @@ namespace data void setType(FsSaveDataType type) { saveDataType = type; } void setFav(bool setFav) { favorite = setFav; } bool getFav() const { return favorite; } - void assignIcons(); - tex *getIcon() const { return icon; } - tex *getIconFav() const { return favIcon; } + void assignIcon(); + void drawIcon(bool full, unsigned x, unsigned y); + void drawIconFav(bool full, unsigned x, unsigned y); void setPlayTime(const uint32_t& _p){ playMins = _p; } uint32_t getPlayTime() const { return playMins; } void setLastTimeStamp(const uint32_t& _ts){ lastTimeStamp = _ts; } @@ -78,7 +78,7 @@ namespace data uint32_t getLaunchCount() const { return launchCount; } private: - tex *icon, *favIcon; + tex *icon; uint8_t saveDataType; std::string title, titleSafe, author; uint64_t id, saveID; @@ -132,7 +132,7 @@ namespace data //User vector extern std::vector users; - extern std::unordered_map> icons; + extern std::unordered_map icons; //Options and info //Restores config to default diff --git a/inc/file.h b/inc/file.h index 86e40e8..961963a 100644 --- a/inc/file.h +++ b/inc/file.h @@ -36,12 +36,6 @@ namespace fs //Copies unzfile to 'to' void copyZipToDir(unzFile *unz, const std::string& to, const std::string& dev); - //Reads svi from path and writes needed info to attr and crInfo. Does NOT set account id for attr - bool readSvi(const std::string& _path, FsSaveDataAttribute *attr, FsSaveDataCreationInfo *crInfo); - - //Creates save data filesystem on NAND - Result createSaveDataFileSystem(const FsSaveDataAttribute *attr, const FsSaveDataCreationInfo *crInfo); - //deletes file void delfile(const std::string& path); //Recursively deletes 'path' diff --git a/inc/ui.h b/inc/ui.h index 9b41798..76c977c 100644 --- a/inc/ui.h +++ b/inc/ui.h @@ -1,6 +1,7 @@ #ifndef UI_H #define UI_H +#include #include #include @@ -35,6 +36,13 @@ namespace ui //Current menu/ui state extern int mstate, prevState; + //pad data cause i don't know where else to put it + extern PadState pad; + static inline void updatePad() { padUpdate(&pad); } + inline uint64_t padKeysDown() { return padGetButtonsDown(&pad); } + inline uint64_t padKeysHeld() { return padGetButtons(&pad); } + inline uint64_t padKeysUp() { return padGetButtonsUp(&pad); } + inline void changeState(int newState) { prevState = mstate; diff --git a/inc/util.h b/inc/util.h index a4e7ca0..35cfb51 100644 --- a/inc/util.h +++ b/inc/util.h @@ -57,8 +57,6 @@ namespace util } void setCPU(uint32_t hz); - - Result fsOpenDataFileSystemByCurrentProcess(FsFileSystem *out); void checkForUpdate(); } #endif // UTIL_H diff --git a/romfs/lang/en-US.txt b/romfs/lang/en-US.txt index 2aa5c73..0a73ad9 100644 --- a/romfs/lang/en-US.txt +++ b/romfs/lang/en-US.txt @@ -123,7 +123,7 @@ optMenuExp = 9, "Changes the UI to be text menu based like the original JKSM for optMenuExp = 10, "Directly uses the Switch's FS commands to copy files instead of stdio." optMenuExp = 11, "Skips the user selection screen and jumps directly to the first user account found." optMenuExp = 12, "Exports saves to zip files." -optMenuExp = 13, ""Changes the way titles are sorted and listed." +optMenuExp = 13, "Changes the way titles are sorted and listed." #Sort Types sortType = 0, "Alphabetical" diff --git a/src/data.cpp b/src/data.cpp index b3c5ea8..3cc9af2 100644 --- a/src/data.cpp +++ b/src/data.cpp @@ -11,6 +11,9 @@ #include "file.h" #include "util.h" +//Color for favorite hearts +const clr heartColor = clrCreateRGBA(0xFF, 0x44, 0x44, 0xFF); + //FsSaveDataSpaceId_All doesn't work for SD static const unsigned saveOrder [] = { @@ -36,7 +39,7 @@ static bool sysBCATPushed = false, cachePushed = false, tempPushed = false; static std::vector blacklist; static std::vector favorites; static std::unordered_map pathDefs; -std::unordered_map> data::icons; +std::unordered_map data::icons; //Sorts titles by sortType static struct @@ -130,9 +133,8 @@ static inline tex *createFavIcon(const tex *_icn) static inline void loadCreateIcon(const uint64_t& _id, size_t _sz, const NsApplicationControlData *_d) { - data::icons[_id].first = texLoadJPEGMem(_d->icon, _sz); - texApplyAlphaMask(data::icons[_id].first, ui::iconMask); - data::icons[_id].second = createFavIcon(data::icons[_id].first); + data::icons[_id] = texLoadJPEGMem(_d->icon, _sz); + texApplyAlphaMask(data::icons[_id], ui::iconMask); } static void loadCreateSystemIcon(const uint64_t& _id) @@ -140,9 +142,8 @@ static void loadCreateSystemIcon(const uint64_t& _id) char tmp[16]; sprintf(tmp, "%08X", (uint32_t)_id); - data::icons[_id].first = util::createIconGeneric(tmp); - texApplyAlphaMask(data::icons[_id].first, ui::iconMask); - data::icons[_id].second = createFavIcon(data::icons[_id].first); + data::icons[_id] = util::createIconGeneric(tmp); + texApplyAlphaMask(data::icons[_id], ui::iconMask); } static inline std::string getIDStr(const uint64_t& _id) @@ -320,14 +321,12 @@ void data::exit() for(data::user& u : data::users) u.delIcon(); for(auto& icn : icons) { - if(icn.second.first) - texDestroy(icn.second.first); - - if(icn.second.second) - texDestroy(icn.second.second); + if(icn.second) + texDestroy(icn.second); } saveFav(); + saveCfg(); saveBlackList(); util::setCPU(1020000000); } @@ -363,7 +362,7 @@ data::titledata::titledata(const FsSaveDataInfo& inf, NsApplicationControlData * if(icnInd == icons.end()) loadCreateIcon(id, icnSize, dat); - assignIcons(); + assignIcon(); } else { @@ -371,7 +370,7 @@ data::titledata::titledata(const FsSaveDataInfo& inf, NsApplicationControlData * loadCreateSystemIcon(id); title = getIDStr(id); titleSafe = getIDStr(id); - assignIcons(); + assignIcon(); } favorite = isFavorite(id); } @@ -396,10 +395,31 @@ std::string data::titledata::getSaveIDStr() const return getIDStr(saveID); } -void data::titledata::assignIcons() +void data::titledata::assignIcon() { - icon = icons[id].first; - favIcon = icons[id].second; + icon = icons[id]; +} + +void data::titledata::drawIcon(bool full, unsigned x, unsigned y) +{ + if(full) + texDraw(icon, frameBuffer, x, y); + else + texDrawSkip(icon, frameBuffer, x, y); +} + +void data::titledata::drawIconFav(bool full, unsigned x, unsigned y) +{ + if(full) + { + texDraw(icon, frameBuffer, x, y); + drawText("♥", frameBuffer, ui::shared, x + 16, y + 16, 48, heartColor); + } + else + { + texDrawSkip(icon, frameBuffer, x, y); + drawText("♥", frameBuffer, ui::shared, x + 8, y + 8, 24, heartColor); + } } data::user::user(const AccountUid& _id, const std::string& _backupName) diff --git a/src/file.cpp b/src/file.cpp index 7dfd750..621a071 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -488,50 +488,6 @@ void fs::copyDirToDirCommit(const std::string& from, const std::string& to, cons } } -bool fs::readSvi(const std::string& _path, FsSaveDataAttribute *attr, FsSaveDataCreationInfo *crInfo) -{ - FILE *sviIn = fopen(_path.c_str(), "rb"); - if(!sviIn) - return false; - - svInfo infoIn; - fread(&infoIn, sizeof(svInfo), 1, sviIn); - fclose(sviIn); - - attr->application_id = infoIn.appID; - attr->save_data_type = infoIn.saveType; - attr->save_data_rank = infoIn.saveRank; - attr->save_data_index = infoIn.saveIndex; - - crInfo->owner_id = infoIn.appID; - crInfo->save_data_size = infoIn.saveSize; - crInfo->available_size = infoIn.availableSize; - crInfo->journal_size = infoIn.journalSize; - crInfo->save_data_space_id = FsSaveDataSpaceId_User; - - return true; -} - -Result fs::createSaveDataFileSystem(const FsSaveDataAttribute *attr, const FsSaveDataCreationInfo *crInfo) -{ - Service *fs = fsGetServiceSession(); - struct - { - FsSaveDataAttribute attr; - FsSaveDataCreationInfo create; - uint32_t unk0; - uint8_t unk1[0x06]; - } in = {*attr, *crInfo, 0, {0}}; - - if(attr->save_data_type != FsSaveDataType_Device) - { - in.unk0 = 0x40060; - in.unk1[0] = 1; - } - - return serviceDispatchIn(fs, 22, in); -} - void fs::delfile(const std::string& path) { if(data::directFsCmd) @@ -598,9 +554,9 @@ bool fs::dumpAllUserSaves(const data::user& u) { for(unsigned i = 0; i < u.titles.size(); i++) { - hidScanInput(); + ui::updatePad(); - if(hidKeysHeld(CONTROLLER_P1_AUTO) & KEY_B) + if(ui::padKeysDown() & HidNpadButton_B) return false; if(fs::mountSave(u, u.titles[i])) diff --git a/src/main.cpp b/src/main.cpp index bd086d2..6f46196 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -54,13 +54,13 @@ int main(int argc, const char *argv[]) while(appletMainLoop()) { - hidScanInput(); + ui::updatePad(); - uint64_t down = hidKeysDown(CONTROLLER_P1_AUTO); - uint64_t held = hidKeysHeld(CONTROLLER_P1_AUTO); - if(held & KEY_LSTICK && held & KEY_RSTICK) + uint64_t down = ui::padKeysDown(), held = ui::padKeysHeld(); + + if(held & HidNpadButton_StickL && held & HidNpadButton_StickR) debDataStats = true; - else if(down & KEY_PLUS) + else if(down & HidNpadButton_Plus) break; gfxBeginFrame(); diff --git a/src/ui.cpp b/src/ui.cpp index 334388d..d02035b 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -10,14 +10,15 @@ #include "util.h" #include "file.h" -#define VER_STRING "v. 06.23.2020" - //text mode bool ui::textMode = false; //Current menu state int ui::mstate = USR_SEL, ui::prevState = USR_SEL; +//pad data? +PadState ui::pad; + //Theme id ColorSetId ui::thmID; @@ -378,6 +379,10 @@ void ui::init() folderHelpX = 1220 - fldrGuide->width; optHelpX = 1220 - optGuide->width; + //setup pad + padConfigureInput(1, HidNpadStyleSet_NpadStandard); + padInitializeDefault(&ui::pad); + advCopyMenuPrep(); ui::exMenuPrep(); ui::optMenuInit(); diff --git a/src/ui/advmode.cpp b/src/ui/advmode.cpp index 5a9e3aa..6b414cc 100644 --- a/src/ui/advmode.cpp +++ b/src/ui/advmode.cpp @@ -419,7 +419,7 @@ void ui::updateAdvMode(const uint64_t& down, const uint64_t& held) } //OH BOY HERE WE GO - if(down & KEY_A) + if(down & HidNpadButton_A) { switch(advMenuCtrl) { @@ -471,7 +471,7 @@ void ui::updateAdvMode(const uint64_t& down, const uint64_t& held) break; } } - else if(down & KEY_B) + else if(down & HidNpadButton_B) { //save if(advMenuCtrl == 0 && savePath != dev) @@ -492,7 +492,7 @@ void ui::updateAdvMode(const uint64_t& down, const uint64_t& held) else if(advMenuCtrl == 2) advMenuCtrl = advPrev; } - else if(down & KEY_X) + else if(down & HidNpadButton_X) { if(advMenuCtrl == 2) { @@ -504,12 +504,12 @@ void ui::updateAdvMode(const uint64_t& down, const uint64_t& held) advMenuCtrl = 2; } } - else if(down & KEY_ZL || down & KEY_ZR) + else if(down & HidNpadButton_ZL || down & HidNpadButton_ZR) { if(advMenuCtrl == 0 || advMenuCtrl == 1) advMenuCtrl = advMenuCtrl == 0 ? 1 : 0; } - else if(down & KEY_MINUS) + else if(down & HidNpadButton_Minus) { switch(prevState) { diff --git a/src/ui/fldrsel.cpp b/src/ui/fldrsel.cpp index 3b78973..df80cd9 100644 --- a/src/ui/fldrsel.cpp +++ b/src/ui/fldrsel.cpp @@ -29,11 +29,11 @@ void ui::createNewBackup(const uint64_t& held) { std::string out; - if(held & KEY_R) + if(held & HidNpadButton_R) out = data::curUser.getUsernameSafe() + " - " + util::getDateTime(util::DATE_FMT_YMD); - else if(held & KEY_L) + else if(held & HidNpadButton_L) out = data::curUser.getUsernameSafe() + " - " + util::getDateTime(util::DATE_FMT_YDM); - else if(held & KEY_ZL) + else if(held & HidNpadButton_ZL) out = data::curUser.getUsernameSafe() + " - " + util::getDateTime(util::DATE_FMT_HOYSTE); else { @@ -176,7 +176,7 @@ void ui::deleteBackup(unsigned ind) void ui::drawFolderMenu() { - texDraw(data::curData.getIcon(), frameBuffer, 96, 98); + data::curData.drawIcon(true, 96, 98); drawTextWrap(folderMenuInfo.c_str(), frameBuffer, ui::shared, 60, 370, 16, ui::txtCont, 360); folderMenu.draw(ui::txtCont); } @@ -187,30 +187,30 @@ void ui::updateFolderMenu(const uint64_t& down, const uint64_t& held) switch(down) { - case KEY_A: + case HidNpadButton_A: if(folderMenu.getSelected() == 0) ui::createNewBackup(held); else ui::overwriteBackup(folderMenu.getSelected() - 1); break; - case KEY_B: + case HidNpadButton_B: fs::unmountSave(); fs::freePathFilters(); ui::changeState(TTL_SEL); break; - case KEY_X: + case HidNpadButton_X: if(folderMenu.getSelected() > 0) ui::deleteBackup(folderMenu.getSelected() - 1); break; - case KEY_Y: + case HidNpadButton_Y: if(folderMenu.getSelected() > 0) ui::restoreBackup(folderMenu.getSelected() - 1); break; - case KEY_ZR: + case HidNpadButton_ZR: if(data::curData.getType() != FsSaveDataType_System && confirm(true, ui::confEraseFolder.c_str(), data::curData.getTitle().c_str())) { fs::delDir("sv:/"); @@ -218,7 +218,7 @@ void ui::updateFolderMenu(const uint64_t& down, const uint64_t& held) } break; - case KEY_MINUS: + case HidNpadButton_Minus: advModePrep("sv:/", data::curData.getType(), true); ui::changeState(ADV_MDE); break; diff --git a/src/ui/menu.cpp b/src/ui/menu.cpp index add862c..e7a1901 100644 --- a/src/ui/menu.cpp +++ b/src/ui/menu.cpp @@ -83,7 +83,7 @@ void ui::menu::handleInput(const uint64_t& down, const uint64_t& held) if(selected == 0) start = 0; } - else if(down & KEY_RIGHT) + else if(down & HidNpadButton_Right) { selected += 7; if(selected > size) @@ -91,7 +91,7 @@ void ui::menu::handleInput(const uint64_t& down, const uint64_t& held) if((selected - 14) > start) start = selected - 14; } - else if(down & KEY_LEFT) + else if(down & HidNpadButton_Left) { selected -= 7; if(selected < 0) diff --git a/src/ui/miscui.cpp b/src/ui/miscui.cpp index 2fc1d23..0f1bce9 100644 --- a/src/ui/miscui.cpp +++ b/src/ui/miscui.cpp @@ -66,11 +66,9 @@ void ui::showMessage(const char *head, const char *fmt, ...) while(true) { - hidScanInput(); + ui::updatePad(); - uint64_t down = hidKeysDown(CONTROLLER_P1_AUTO); - - if(down) + if(ui::padKeysDown()) break; gfxBeginFrame(); @@ -106,12 +104,12 @@ bool ui::confirm(bool hold, const char *fmt, ...) while(true) { - hidScanInput(); + ui::updatePad(); - uint64_t down = hidKeysDown(CONTROLLER_P1_AUTO); - uint64_t held = hidKeysHeld(CONTROLLER_P1_AUTO); + uint64_t down = ui::padKeysDown(); + uint64_t held = ui::padKeysHeld(); - if(hold && held & KEY_A) + if(hold && held & HidNpadButton_A) { heldDown = true; holdCount++, holdClrDiff++; @@ -147,12 +145,12 @@ bool ui::confirm(bool hold, const char *fmt, ...) yesText = ui::yt; holdClr = ui::txtDiag; } - else if(down & KEY_A) + else if(down & HidNpadButton_A) { ret = true; break; } - else if(down & KEY_B) + else if(down & HidNpadButton_B) { ret = false; break; diff --git a/src/ui/ttlsel.cpp b/src/ui/ttlsel.cpp index 7551990..3a98788 100644 --- a/src/ui/ttlsel.cpp +++ b/src/ui/ttlsel.cpp @@ -74,9 +74,9 @@ void ui::drawTitleMenu() drawText(data::curData.getTitle().c_str(), frameBuffer, ui::shared, rectX + 16, y - 40, 18, ui::txtDiag); } if(data::curUser.titles[i].getFav()) - texDrawSkip(data::curUser.titles[i].getIconFav(), frameBuffer, tX, y); + data::curUser.titles[i].drawIconFav(false, tX, y); else - texDrawSkip(data::curUser.titles[i].getIcon(), frameBuffer, tX, y); + data::curUser.titles[i].drawIcon(false, tX, y); } } } @@ -85,7 +85,7 @@ void ui::updateTitleMenu(const uint64_t& down, const uint64_t& held) { switch(down) { - case KEY_A: + case HidNpadButton_A: if(fs::mountSave(data::curUser, data::curData)) { folderMenuPrepare(data::curUser, data::curData); @@ -94,34 +94,34 @@ void ui::updateTitleMenu(const uint64_t& down, const uint64_t& held) } break; - case KEY_B: + case HidNpadButton_B: reset(); ui::changeState(USR_SEL); break; - case KEY_X: + case HidNpadButton_X: data::favoriteTitle(data::curData); break; - case KEY_Y: + case HidNpadButton_Y: fs::dumpAllUserSaves(data::curUser); break; - case KEY_L: + case HidNpadButton_L: if(--data::selUser < 0) data::selUser = data::users.size() - 1; reset(); ui::showPopup(POP_FRAME_DEFAULT, data::curUser.getUsername().c_str()); break; - case KEY_R: + case HidNpadButton_R: if(++data::selUser == (int)data::users.size()) data::selUser = 0; reset(); ui::showPopup(POP_FRAME_DEFAULT, data::curUser.getUsername().c_str()); break; - case KEY_ZR: + case HidNpadButton_ZR: if(data::curData.getType() != FsSaveDataType_System && confirm(true, ui::confEraseNand.c_str(), data::curData.getTitle().c_str())) { fsDeleteSaveDataFileSystemBySaveDataSpaceId(FsSaveDataSpaceId_User, data::curData.getSaveID()); @@ -130,33 +130,33 @@ void ui::updateTitleMenu(const uint64_t& down, const uint64_t& held) } break; - case KEY_MINUS: + case HidNpadButton_Minus: if(ui::confirm(false, ui::confBlacklist.c_str(), data::curUser.titles[data::selData].getTitle().c_str())) data::blacklistAdd(data::curData); break; - case KEY_LSTICK_UP: - case KEY_DUP: + case HidNpadButton_StickLUp: + case HidNpadButton_Up: data::selData -= 8; if(data::selData < 0) data::selData = 0; break; - case KEY_LSTICK_DOWN: - case KEY_DDOWN: + case HidNpadButton_StickLDown: + case HidNpadButton_Down: data::selData += 8; if(data::selData > (int)data::curUser.titles.size() - 1) data::selData = data::curUser.titles.size() - 1; break; - case KEY_LSTICK_LEFT: - case KEY_DLEFT: + case HidNpadButton_StickLLeft: + case HidNpadButton_Left: if(data::selData > 0) --data::selData; break; - case KEY_LSTICK_RIGHT: - case KEY_DRIGHT: + case HidNpadButton_StickLRight: + case HidNpadButton_Right: if(data::selData < (int)data::curUser.titles.size() - 1) ++data::selData; break; diff --git a/src/ui/txtui.cpp b/src/ui/txtui.cpp index 50634cf..e12ed8b 100644 --- a/src/ui/txtui.cpp +++ b/src/ui/txtui.cpp @@ -44,7 +44,7 @@ void ui::textUserMenuUpdate(const uint64_t& down, const uint64_t& held) switch(down) { - case KEY_A: + case HidNpadButton_A: if(data::curUser.titles.size() > 0) { ui::textTitlePrep(data::curUser); @@ -54,12 +54,12 @@ void ui::textUserMenuUpdate(const uint64_t& down, const uint64_t& held) ui::showPopup(POP_FRAME_DEFAULT, ui::noSavesFound.c_str(), data::curUser.getUsername().c_str()); break; - case KEY_X: + case HidNpadButton_X: ui::textMode = false; ui::changeState(USR_SEL); break; - case KEY_Y: + case HidNpadButton_Y: { bool cont = true; for(unsigned i = 0; i < data::users.size() - 2; i++) @@ -70,15 +70,15 @@ void ui::textUserMenuUpdate(const uint64_t& down, const uint64_t& held) } break; - case KEY_R: + case HidNpadButton_R: util::checkForUpdate(); break; - case KEY_ZR: + case HidNpadButton_ZR: ui::changeState(EX_MNU); break; - case KEY_MINUS: + case HidNpadButton_Minus: ui::changeState(OPT_MNU); break; } @@ -97,7 +97,7 @@ void ui::textTitleMenuUpdate(const uint64_t& down, const uint64_t& held) switch(down) { - case KEY_A: + case HidNpadButton_A: if(fs::mountSave(data::curUser, data::curData)) { folderMenuPrepare(data::curUser, data::curData); @@ -106,34 +106,34 @@ void ui::textTitleMenuUpdate(const uint64_t& down, const uint64_t& held) } break; - case KEY_B: + case HidNpadButton_B: ui::changeState(TXT_USR); break; - case KEY_X: + case HidNpadButton_X: data::favoriteTitle(data::curData); textTitlePrep(data::curUser); break; - case KEY_Y: + case HidNpadButton_Y: fs::dumpAllUserSaves(data::curUser); break; - case KEY_L: + case HidNpadButton_L: if(--data::selUser < 0) data::selUser = data::users.size() - 1; ui::textTitlePrep(data::curUser); ui::showPopup(POP_FRAME_DEFAULT, data::curUser.getUsername().c_str()); break; - case KEY_R: + case HidNpadButton_R: if(++data::selUser == (int)data::users.size()) data::selUser = 0; ui::textTitlePrep(data::curUser); ui::showPopup(POP_FRAME_DEFAULT, data::curUser.getUsername().c_str()); break; - case KEY_ZR: + case HidNpadButton_ZR: if(data::curData.getType() != FsSaveDataType_System && confirm(true, ui::confEraseNand.c_str(), data::curData.getTitle().c_str())) { fsDeleteSaveDataFileSystemBySaveDataSpaceId(FsSaveDataSpaceId_User, data::curData.getSaveID()); @@ -142,7 +142,7 @@ void ui::textTitleMenuUpdate(const uint64_t& down, const uint64_t& held) } break; - case KEY_MINUS: + case HidNpadButton_Minus: if(ui::confirm(false, ui::confBlacklist.c_str(), data::curUser.titles[data::selData].getTitle().c_str())) data::blacklistAdd(data::curData); break; @@ -160,30 +160,30 @@ void ui::textFolderMenuUpdate(const uint64_t& down, const uint64_t& held) switch(down) { - case KEY_A: + case HidNpadButton_A: if(folderMenu.getSelected() == 0) ui::createNewBackup(held); else ui::overwriteBackup(folderMenu.getSelected() - 1); break; - case KEY_B: + case HidNpadButton_B: fs::unmountSave(); fs::freePathFilters(); ui::changeState(TXT_TTL); break; - case KEY_X: + case HidNpadButton_X: if(folderMenu.getSelected() > 0) ui::deleteBackup(folderMenu.getSelected() - 1); break; - case KEY_Y: + case HidNpadButton_Y: if(folderMenu.getSelected() > 0) ui::restoreBackup(folderMenu.getSelected() - 1); break; - case KEY_ZR: + case HidNpadButton_ZR: if(data::curData.getType() != FsSaveDataType_System && confirm(true, ui::confEraseFolder.c_str(), data::curData.getTitle().c_str())) { fs::delDir("sv:/"); @@ -191,7 +191,7 @@ void ui::textFolderMenuUpdate(const uint64_t& down, const uint64_t& held) } break; - case KEY_MINUS: + case HidNpadButton_Minus: advModePrep("sv:/", data::curData.getType(), true); ui::changeState(ADV_MDE); break; @@ -216,7 +216,7 @@ void ui::updateExMenu(const uint64_t& down, const uint64_t& held) { exMenu.handleInput(down, held); - if(down & KEY_A) + if(down & HidNpadButton_A) { fsdevUnmountDevice("sv"); FsFileSystem sv; @@ -313,7 +313,7 @@ void ui::updateExMenu(const uint64_t& down, const uint64_t& held) { FsFileSystem tromfs; //Result res = romfsMountFromCurrentProcess("tromfs"); << Works too, but is kinda weird - if(R_SUCCEEDED(util::fsOpenDataFileSystemByCurrentProcess(&tromfs))) + if(R_SUCCEEDED(fsOpenDataFileSystemByCurrentProcess(&tromfs))) { fsdevMountDevice("tromfs", tromfs); advModePrep("tromfs:/", FsSaveDataType_Account, false); @@ -336,7 +336,7 @@ void ui::updateExMenu(const uint64_t& down, const uint64_t& held) break; } } - else if(down & KEY_B) + else if(down & HidNpadButton_B) { fsdevUnmountDevice("sv"); ui::changeState(ui::textMode ? TXT_USR : USR_SEL); @@ -392,7 +392,7 @@ void ui::updateOptMenu(const uint64_t& down, const uint64_t& held) optMenu.editOpt(12, optMenuStr[12] + getBoolText(data::zip)); optMenu.editOpt(13, optMenuStr[13] + ui::sortString[data::sortType]); - if(down & KEY_A) + if(down & HidNpadButton_A) { switch(optMenu.getSelected()) { @@ -454,13 +454,10 @@ void ui::updateOptMenu(const uint64_t& down, const uint64_t& held) break; } } - else if(down & KEY_X) + else if(down & HidNpadButton_X) data::restoreDefaultConfig(); - else if(down & KEY_B) - { - data::saveCfg(); + else if(down & HidNpadButton_B) ui::changeState(ui::textMode ? TXT_USR : USR_SEL); - } } void ui::drawOptMenu() diff --git a/src/ui/uistr.cpp b/src/ui/uistr.cpp index d5ebbd6..ec03ea6 100644 --- a/src/ui/uistr.cpp +++ b/src/ui/uistr.cpp @@ -23,7 +23,7 @@ std::string ui::errorConnecting = "Error Connecting!"; std::string ui::noUpdate = "No updates available!"; std::string ui::advMenuStr[6] = { "Copy to ", "Delete", "Rename", "Make Dir", "Properties", "Close" }; std::string ui::exMenuStr[11] = { "SD to SD Browser", "BIS: PRODINFOF", "BIS: SAFE", "BIS: SYSTEM", "BIS: USER", "Remove Update", "Terminate Process", "Mount System Save", "Rescan Titles", "Mount Process RomFS", "Backup JKSV Folder" }; -std::string ui::optMenuStr[14] = { "Include Dev Sv: ", "AutoBackup: ", "Overclock: ", "Hold to Delete: ", "Hold to Restore: ", "Hold to Overwrite: ", "Force Mount: ", "Account Sys. Saves: ", "Write to Sys. Saves: ", "Text UI Mode: ", "Direct FS Cmd: ", "Skip User Select: ", "Export to ZIP: ", "Sort: " }; +std::string ui::optMenuStr[14] = { "Include Dev Sv: ", "AutoBackup: ", "Overclock: ", "Hold to Delete: ", "Hold to Restore: ", "Hold to Overwrite: ", "Force Mount: ", "Account Sys. Saves: ", "Write to Sys. Saves: ", "Text UI Mode: ", "Direct FS Cmd: ", "Skip User Select: ", "Export to ZIP: ", "Sort: "}; std::string ui::optMenuExp[14] = { "Includes Device Save data in user accounts.", diff --git a/src/ui/usrsel.cpp b/src/ui/usrsel.cpp index 6950d02..fffa181 100644 --- a/src/ui/usrsel.cpp +++ b/src/ui/usrsel.cpp @@ -68,19 +68,19 @@ void ui::updateUserMenu(const uint64_t& down, const uint64_t& held) { switch(down) { - case KEY_A: + case HidNpadButton_A: if(data::curUser.titles.size() > 0) ui::changeState(TTL_SEL); else ui::showPopup(POP_FRAME_DEFAULT, ui::noSavesFound.c_str(), data::curUser.getUsername().c_str()); break; - case KEY_X: + case HidNpadButton_X: ui::textMode = true; ui::changeState(TXT_USR); break; - case KEY_Y: + case HidNpadButton_Y: { bool cont = true; for(unsigned i = 0; i < data::users.size() - 2; i++) @@ -91,36 +91,36 @@ void ui::updateUserMenu(const uint64_t& down, const uint64_t& held) } break; - case KEY_R: + case HidNpadButton_R: util::checkForUpdate(); break; - case KEY_ZR: + case HidNpadButton_ZR: ui::changeState(EX_MNU); break; - case KEY_MINUS: + case HidNpadButton_Minus: ui::changeState(OPT_MNU); break; - case KEY_LSTICK_UP: - case KEY_DUP: + case HidNpadButton_StickLUp: + case HidNpadButton_Up: data::selUser - 5 < 0 ? data::selUser = 0 : data::selUser -= 4; break; - case KEY_LSTICK_DOWN: - case KEY_DDOWN: + case HidNpadButton_StickLDown: + case HidNpadButton_Down: data::selUser + 5 > (int)data::users.size() - 1 ? data::selUser = data::users.size() - 1 : data::selUser += 5; break; - case KEY_LSTICK_LEFT: - case KEY_DLEFT: + case HidNpadButton_StickLLeft: + case HidNpadButton_Left: if(data::selUser > 0) --data::selUser; break; - case KEY_LSTICK_RIGHT: - case KEY_DRIGHT: + case HidNpadButton_StickLRight: + case HidNpadButton_Right: if(data::selUser < (int)data::users.size() - 1) ++data::selUser; break; diff --git a/src/util.cpp b/src/util.cpp index d56f4ca..11d987a 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -335,11 +335,6 @@ void util::setCPU(uint32_t hz) clkrstExit(); } -Result util::fsOpenDataFileSystemByCurrentProcess(FsFileSystem *out) -{ - return serviceDispatch(fsGetServiceSession(), 2, 0, .out_num_objects = 1, .out_objects = &out->s); -} - void util::checkForUpdate() { std::string gitJson = getJSONURL(NULL, "https://api.github.com/repos/J-D-K/JKSV/releases/latest");