From d5c47e0607b3239140ec4d48c732ce8ddb834afb Mon Sep 17 00:00:00 2001 From: mrdude2478 Date: Fri, 29 Apr 2022 11:35:25 +0100 Subject: [PATCH] touchscreen stuff fixed --- README.md | 6 +- source/ui/HDInstPage.cpp | 28 +++- source/ui/mainPage.cpp | 61 +++++---- source/ui/netInstPage.cpp | 43 +++--- source/ui/optionsPage.cpp | 279 ++++++++++++++++++++------------------ source/ui/sdInstPage.cpp | 41 ++++-- source/ui/usbInstPage.cpp | 39 +++--- 7 files changed, 280 insertions(+), 217 deletions(-) diff --git a/README.md b/README.md index 63fb254..41edaaa 100644 --- a/README.md +++ b/README.md @@ -37,11 +37,7 @@ Third, "make clean". This is a work in progress and lets you build with new libnx, plutonium packages. Some stuff still needs fixed to work with the new plutonium and libnx changes. ## Stuff still to fix -~~Font sizes in menus.~~ Fixed \ -~~Threading in the main menu - to stop GUI freezing or Network installs failing.~~ Fixed \ -~~Options page - stop jumping back to top of page after something is selected.~~ Fixed \ -Touchscreen not working properly.\ -~~Crash when pressing A or + in the network install page.~~ Fixed \ +~~All known bugs fixed~~ \ ## Build Issues Make sure you are using Libnx build at least 9865dbf9 version. diff --git a/source/ui/HDInstPage.cpp b/source/ui/HDInstPage.cpp index 8176cef..4f96e31 100644 --- a/source/ui/HDInstPage.cpp +++ b/source/ui/HDInstPage.cpp @@ -11,6 +11,7 @@ namespace inst::ui { extern MainApplication *mainApp; + s32 zzz=0; //touchscreen variable HDInstPage::HDInstPage() : Layout::Layout() { this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR("#00000080")); @@ -148,12 +149,25 @@ namespace inst::ui { if (Down & HidNpadButton_B) { mainApp->LoadLayout(mainApp->mainPage); } - if ((Down & HidNpadButton_A)) { - this->selectNsp(this->menu->GetSelectedIndex()); - if (this->ourFiles.size() == 1 && this->selectedTitles.size() == 1) { - this->startInstall(); - } - } + + HidTouchScreenState state={0}; + + if (hidGetTouchScreenStates(&state, 1)) { + + if ((Down & HidNpadButton_A) || (state.count != zzz)) + { + zzz = state.count; + + if (zzz != 1) { + this->selectNsp(this->menu->GetSelectedIndex()); + if (this->ourFiles.size() == 1 && this->selectedTitles.size() == 1) { + this->startInstall(); + } + + } + } + } + if ((Down & HidNpadButton_Y)) { if (this->selectedTitles.size() == this->ourFiles.size()) this->drawMenuItems(true, currentDir); else { @@ -166,9 +180,11 @@ namespace inst::ui { this->drawMenuItems(false, currentDir); } } + if ((Down & HidNpadButton_X)) { inst::ui::mainApp->CreateShowDialog("inst.hd.help.title"_lang, "inst.hd.help.desc"_lang, {"common.ok"_lang}, true); } + if (Down & HidNpadButton_Plus) { if (this->selectedTitles.size() == 0 && this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetIconPath() == "romfs:/images/icons/checkbox-blank-outline.png") { this->selectNsp(this->menu->GetSelectedIndex()); diff --git a/source/ui/mainPage.cpp b/source/ui/mainPage.cpp index 2832cef..54af8e8 100644 --- a/source/ui/mainPage.cpp +++ b/source/ui/mainPage.cpp @@ -18,6 +18,7 @@ int statvfs(const char *path, struct statvfs *buf); +s32 prev_touchcount=0; double GetAvailableSpace(const char* path) { @@ -264,32 +265,42 @@ namespace inst::ui { mainApp->Close(); } - if (Down & HidNpadButton_A) { - int menuindex = this->optionMenu->GetSelectedIndex(); - switch (menuindex) { - case 0: - this->installMenuItem_Click(); - break; - case 1: - this->netInstallMenuItem_Click(); - break; - case 2: - MainPage::usbInstallMenuItem_Click(); - break; - case 3: - MainPage::HdInstallMenuItem_Click(); - break; - case 4: - MainPage::settingsMenuItem_Click(); - break; - case 5: - MainPage::exitMenuItem_Click(); - break; - default: - break; - } - } + HidTouchScreenState state={0}; + if (hidGetTouchScreenStates(&state, 1)) { + + if ((Down & HidNpadButton_A) || (state.count != prev_touchcount)) + { + prev_touchcount = state.count; + + if (prev_touchcount != 1) { + int menuindex = this->optionMenu->GetSelectedIndex(); + switch (menuindex) { + case 0: + this->installMenuItem_Click(); + break; + case 1: + this->netInstallMenuItem_Click(); + break; + case 2: + MainPage::usbInstallMenuItem_Click(); + break; + case 3: + MainPage::HdInstallMenuItem_Click(); + break; + case 4: + MainPage::settingsMenuItem_Click(); + break; + case 5: + MainPage::exitMenuItem_Click(); + break; + default: + break; + } + } + } + } + if (Down & HidNpadButton_X) { this->awooImage->SetVisible(false); this->eggImage->SetVisible(true); diff --git a/source/ui/netInstPage.cpp b/source/ui/netInstPage.cpp index c92e662..cae2da8 100644 --- a/source/ui/netInstPage.cpp +++ b/source/ui/netInstPage.cpp @@ -14,6 +14,7 @@ namespace inst::ui { extern MainApplication *mainApp; + s32 xxx=0; std::string lastUrl = "https://"; std::string lastFileID = ""; @@ -172,25 +173,33 @@ namespace inst::ui { mainApp->LoadLayout(mainApp->mainPage); } - - if (Down & HidNpadButton_A) { - - int var = this->menu->GetItems().size(); - auto s = std::to_string(var); - //std::string s = ourUrlString; //debug stuff - //this->appVersionText->SetText(s); //debug stuff - - if (s == "0") { - //do nothing here because there's no items in the list, that way the app won't freeze - } - else { - this->selectTitle(this->menu->GetSelectedIndex()); - if (this->menu->GetItems().size() == 1 && this->selectedUrls.size() == 1) { - this->startInstall(false); + HidTouchScreenState state={0}; + + if (hidGetTouchScreenStates(&state, 1)) { + + if ((Down & HidNpadButton_A) || (state.count != xxx)) + { + xxx = state.count; + + if (xxx != 1) { + int var = this->menu->GetItems().size(); + auto s = std::to_string(var); + //std::string s = ourUrlString; //debug stuff + //this->appVersionText->SetText(s); //debug stuff + + if (s == "0") { + //do nothing here because there's no items in the list, that way the app won't freeze + } + else { + this->selectTitle(this->menu->GetSelectedIndex()); + if (this->menu->GetItems().size() == 1 && this->selectedUrls.size() == 1) { + this->startInstall(false); + } + } } - } - + } } + if ((Down & HidNpadButton_Y)) { if (this->selectedUrls.size() == this->menu->GetItems().size()) this->drawMenuItems(true); diff --git a/source/ui/optionsPage.cpp b/source/ui/optionsPage.cpp index e357422..09fd01e 100644 --- a/source/ui/optionsPage.cpp +++ b/source/ui/optionsPage.cpp @@ -17,6 +17,7 @@ namespace inst::ui { extern MainApplication *mainApp; + s32 prev_touchcount=0; std::vector languageStrings = {"En", "Jpn", "Fr", "De", "It", "Ru", "Zh"}; @@ -165,139 +166,151 @@ namespace inst::ui { if (Down & HidNpadButton_B) { mainApp->LoadLayout(mainApp->mainPage); } - if (Down & HidNpadButton_A) { - std::string keyboardResult; - int rc; - std::vector downloadUrl; - std::vector languageList; - int index = this->menu->GetSelectedIndex(); - switch (index) { - case 0: - inst::config::ignoreReqVers = !inst::config::ignoreReqVers; - inst::config::setConfig(); - this->setMenuText(); - //makes sure to jump back to the selected item once the menu is reloaded - this->menu->SetSelectedIndex(index); - // - break; - case 1: - if (inst::config::validateNCAs) { - if (inst::ui::mainApp->CreateShowDialog("options.nca_warn.title"_lang, "options.nca_warn.desc"_lang, {"common.cancel"_lang, "options.nca_warn.opt1"_lang}, false) == 1) inst::config::validateNCAs = false; - } else inst::config::validateNCAs = true; - inst::config::setConfig(); - this->setMenuText(); - this->menu->SetSelectedIndex(index); - break; - case 2: - inst::config::overClock = !inst::config::overClock; - inst::config::setConfig(); - this->setMenuText(); - this->menu->SetSelectedIndex(index); - break; - case 3: - inst::config::deletePrompt = !inst::config::deletePrompt; - inst::config::setConfig(); - this->setMenuText(); - this->menu->SetSelectedIndex(index); - break; - case 4: - inst::config::autoUpdate = !inst::config::autoUpdate; - inst::config::setConfig(); - this->setMenuText(); - this->menu->SetSelectedIndex(index); - break; - case 5: - if (inst::config::gayMode) { - inst::config::gayMode = false; - mainApp->mainPage->awooImage->SetVisible(false); - - } - else { - inst::config::gayMode = true; - mainApp->mainPage->awooImage->SetVisible(true); - } - this->setMenuText(); - this->menu->SetSelectedIndex(index); - thememessage(); - inst::config::setConfig(); - break; - - case 6: - if (inst::config::useSound) { - inst::config::useSound = false; - } - else { - inst::config::useSound = true; - } - this->setMenuText(); - this->menu->SetSelectedIndex(index); - inst::config::setConfig(); - break; - - case 7: - sigPatchesMenuItem_Click(); - break; - case 8: - keyboardResult = inst::util::softwareKeyboard("options.sig_hint"_lang, inst::config::sigPatchesUrl.c_str(), 500); - if (keyboardResult.size() > 0) { - inst::config::sigPatchesUrl = keyboardResult; - inst::config::setConfig(); - this->setMenuText(); - this->menu->SetSelectedIndex(index); - } - break; - case 9: - languageList = languageStrings; - languageList.push_back("options.language.system_language"_lang); - rc = inst::ui::mainApp->CreateShowDialog("options.language.title"_lang, "options.language.desc"_lang, languageList, false); - if (rc == -1) break; - switch(rc) { - case 0: - inst::config::languageSetting = 0; - break; - case 1: - inst::config::languageSetting = 1; - break; - case 2: - inst::config::languageSetting = 2; - break; - case 3: - inst::config::languageSetting = 3; - break; - case 4: - inst::config::languageSetting = 4; - break; - case 5: - inst::config::languageSetting = 5; - break; - case 6: - inst::config::languageSetting = 6; - break; - default: - inst::config::languageSetting = 99; - } - inst::config::setConfig(); - mainApp->FadeOut(); - mainApp->Close(); - break; - case 10: - if (inst::util::getIPAddress() == "1.0.0.127") { - inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, {"common.ok"_lang}, true); - break; - } - downloadUrl = inst::util::checkForAppUpdate(); - if (!downloadUrl.size()) { - mainApp->CreateShowDialog("options.update.title_check_fail"_lang, "options.update.desc_check_fail"_lang, {"common.ok"_lang}, false); - break; - } - this->askToUpdate(downloadUrl); - break; - case 11: - inst::ui::mainApp->CreateShowDialog("options.credits.title"_lang, "options.credits.desc"_lang, {"common.close"_lang}, true); - break; - default: - break; - } + + HidTouchScreenState state={0}; + + if (hidGetTouchScreenStates(&state, 1)) { + + if ((Down & HidNpadButton_A) || (state.count != prev_touchcount)) + { + prev_touchcount = state.count; + + if (prev_touchcount != 1) { + + std::string keyboardResult; + int rc; + std::vector downloadUrl; + std::vector languageList; + int index = this->menu->GetSelectedIndex(); + switch (index) { + case 0: + inst::config::ignoreReqVers = !inst::config::ignoreReqVers; + inst::config::setConfig(); + this->setMenuText(); + //makes sure to jump back to the selected item once the menu is reloaded + this->menu->SetSelectedIndex(index); + // + break; + case 1: + if (inst::config::validateNCAs) { + if (inst::ui::mainApp->CreateShowDialog("options.nca_warn.title"_lang, "options.nca_warn.desc"_lang, {"common.cancel"_lang, "options.nca_warn.opt1"_lang}, false) == 1) inst::config::validateNCAs = false; + } else inst::config::validateNCAs = true; + inst::config::setConfig(); + this->setMenuText(); + this->menu->SetSelectedIndex(index); + break; + case 2: + inst::config::overClock = !inst::config::overClock; + inst::config::setConfig(); + this->setMenuText(); + this->menu->SetSelectedIndex(index); + break; + case 3: + inst::config::deletePrompt = !inst::config::deletePrompt; + inst::config::setConfig(); + this->setMenuText(); + this->menu->SetSelectedIndex(index); + break; + case 4: + inst::config::autoUpdate = !inst::config::autoUpdate; + inst::config::setConfig(); + this->setMenuText(); + this->menu->SetSelectedIndex(index); + break; + case 5: + if (inst::config::gayMode) { + inst::config::gayMode = false; + mainApp->mainPage->awooImage->SetVisible(false); + + } + else { + inst::config::gayMode = true; + mainApp->mainPage->awooImage->SetVisible(true); + } + this->setMenuText(); + this->menu->SetSelectedIndex(index); + thememessage(); + inst::config::setConfig(); + break; + + case 6: + if (inst::config::useSound) { + inst::config::useSound = false; + } + else { + inst::config::useSound = true; + } + this->setMenuText(); + this->menu->SetSelectedIndex(index); + inst::config::setConfig(); + break; + + case 7: + sigPatchesMenuItem_Click(); + break; + case 8: + keyboardResult = inst::util::softwareKeyboard("options.sig_hint"_lang, inst::config::sigPatchesUrl.c_str(), 500); + if (keyboardResult.size() > 0) { + inst::config::sigPatchesUrl = keyboardResult; + inst::config::setConfig(); + this->setMenuText(); + this->menu->SetSelectedIndex(index); + } + break; + case 9: + languageList = languageStrings; + languageList.push_back("options.language.system_language"_lang); + rc = inst::ui::mainApp->CreateShowDialog("options.language.title"_lang, "options.language.desc"_lang, languageList, false); + if (rc == -1) break; + switch(rc) { + case 0: + inst::config::languageSetting = 0; + break; + case 1: + inst::config::languageSetting = 1; + break; + case 2: + inst::config::languageSetting = 2; + break; + case 3: + inst::config::languageSetting = 3; + break; + case 4: + inst::config::languageSetting = 4; + break; + case 5: + inst::config::languageSetting = 5; + break; + case 6: + inst::config::languageSetting = 6; + break; + default: + inst::config::languageSetting = 99; + } + inst::config::setConfig(); + mainApp->FadeOut(); + mainApp->Close(); + break; + case 10: + if (inst::util::getIPAddress() == "1.0.0.127") { + inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, {"common.ok"_lang}, true); + break; + } + downloadUrl = inst::util::checkForAppUpdate(); + if (!downloadUrl.size()) { + mainApp->CreateShowDialog("options.update.title_check_fail"_lang, "options.update.desc_check_fail"_lang, {"common.ok"_lang}, false); + break; + } + this->askToUpdate(downloadUrl); + break; + case 11: + inst::ui::mainApp->CreateShowDialog("options.credits.title"_lang, "options.credits.desc"_lang, {"common.close"_lang}, true); + break; + default: + break; + } + } } } + } } \ No newline at end of file diff --git a/source/ui/sdInstPage.cpp b/source/ui/sdInstPage.cpp index 19dc7a6..e3d4c6b 100644 --- a/source/ui/sdInstPage.cpp +++ b/source/ui/sdInstPage.cpp @@ -11,6 +11,7 @@ namespace inst::ui { extern MainApplication *mainApp; + s32 yyy=0; sdInstPage::sdInstPage() : Layout::Layout() { this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR("#00000080")); @@ -154,24 +155,34 @@ namespace inst::ui { mainApp->LoadLayout(mainApp->mainPage); } - if (Down & HidNpadButton_A) { - - int var = this->menu->GetItems().size(); - auto s = std::to_string(var); - - if (s == "0") { - //do nothing here because there's no items in the list, that way the app won't freeze - } + HidTouchScreenState state={0}; + + if (hidGetTouchScreenStates(&state, 1)) { - else { - this->selectNsp(this->menu->GetSelectedIndex()); - - if (this->ourFiles.size() == 1 && this->selectedTitles.size() == 1) { - this->startInstall(); - } + if ((Down & HidNpadButton_A) || (state.count != yyy)) + { + yyy = state.count; + + if (yyy != 1) { + int var = this->menu->GetItems().size(); + auto s = std::to_string(var); + + if (s == "0") { + //do nothing here because there's no items in the list, that way the app won't freeze + } + + else { + this->selectNsp(this->menu->GetSelectedIndex()); + + if (this->ourFiles.size() == 1 && this->selectedTitles.size() == 1) { + this->startInstall(); + } + } + + } } } - + if ((Down & HidNpadButton_Y)) { if (this->selectedTitles.size() == this->ourFiles.size()) this->drawMenuItems(true, currentDir); else { diff --git a/source/ui/usbInstPage.cpp b/source/ui/usbInstPage.cpp index 6bd4ccd..e24ebc0 100644 --- a/source/ui/usbInstPage.cpp +++ b/source/ui/usbInstPage.cpp @@ -10,6 +10,7 @@ namespace inst::ui { extern MainApplication *mainApp; + s32 www=0; //touchscreen variable usbInstPage::usbInstPage() : Layout::Layout() { this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR("#00000080")); @@ -117,24 +118,30 @@ namespace inst::ui { mainApp->LoadLayout(mainApp->mainPage); } - if (Down & HidNpadButton_A) { - - int var = this->menu->GetItems().size(); - auto s = std::to_string(var); - if (s == "0") { - //do nothing here because there's no items in the list, that way the app won't freeze - } - else { - this->selectTitle(this->menu->GetSelectedIndex()); - if (this->menu->GetItems().size() == 1 && this->selectedTitles.size() == 1) { - this->startInstall(); - } - } - + HidTouchScreenState state={0}; + + if (hidGetTouchScreenStates(&state, 1)) { + + if ((Down & HidNpadButton_A) || (state.count != www)) + { + www = state.count; + + if (www != 1) { + int var = this->menu->GetItems().size(); + auto s = std::to_string(var); + if (s == "0") { + //do nothing here because there's no items in the list, that way the app won't freeze + } + else { + this->selectTitle(this->menu->GetSelectedIndex()); + if (this->menu->GetItems().size() == 1 && this->selectedTitles.size() == 1) { + this->startInstall(); + } + } + } + } } - - if ((Down & HidNpadButton_Y)) { if (this->selectedTitles.size() == this->menu->GetItems().size()) this->drawMenuItems(true); else {