touchscreen stuff fixed

This commit is contained in:
mrdude2478 2022-04-29 11:35:25 +01:00
parent 5e94cbf9ae
commit d5c47e0607
7 changed files with 280 additions and 217 deletions

View File

@ -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. 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 ## Stuff still to fix
~~Font sizes in menus.~~ Fixed \ ~~All known bugs 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 \
## Build Issues ## Build Issues
Make sure you are using Libnx build at least 9865dbf9 version. Make sure you are using Libnx build at least 9865dbf9 version.

View File

@ -11,6 +11,7 @@
namespace inst::ui { namespace inst::ui {
extern MainApplication *mainApp; extern MainApplication *mainApp;
s32 zzz=0; //touchscreen variable
HDInstPage::HDInstPage() : Layout::Layout() { HDInstPage::HDInstPage() : Layout::Layout() {
this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR("#00000080")); this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR("#00000080"));
@ -148,12 +149,25 @@ namespace inst::ui {
if (Down & HidNpadButton_B) { if (Down & HidNpadButton_B) {
mainApp->LoadLayout(mainApp->mainPage); mainApp->LoadLayout(mainApp->mainPage);
} }
if ((Down & HidNpadButton_A)) {
this->selectNsp(this->menu->GetSelectedIndex()); HidTouchScreenState state={0};
if (this->ourFiles.size() == 1 && this->selectedTitles.size() == 1) {
this->startInstall(); 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 ((Down & HidNpadButton_Y)) {
if (this->selectedTitles.size() == this->ourFiles.size()) this->drawMenuItems(true, currentDir); if (this->selectedTitles.size() == this->ourFiles.size()) this->drawMenuItems(true, currentDir);
else { else {
@ -166,9 +180,11 @@ namespace inst::ui {
this->drawMenuItems(false, currentDir); this->drawMenuItems(false, currentDir);
} }
} }
if ((Down & HidNpadButton_X)) { if ((Down & HidNpadButton_X)) {
inst::ui::mainApp->CreateShowDialog("inst.hd.help.title"_lang, "inst.hd.help.desc"_lang, {"common.ok"_lang}, true); inst::ui::mainApp->CreateShowDialog("inst.hd.help.title"_lang, "inst.hd.help.desc"_lang, {"common.ok"_lang}, true);
} }
if (Down & HidNpadButton_Plus) { if (Down & HidNpadButton_Plus) {
if (this->selectedTitles.size() == 0 && this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetIconPath() == "romfs:/images/icons/checkbox-blank-outline.png") { if (this->selectedTitles.size() == 0 && this->menu->GetItems()[this->menu->GetSelectedIndex()]->GetIconPath() == "romfs:/images/icons/checkbox-blank-outline.png") {
this->selectNsp(this->menu->GetSelectedIndex()); this->selectNsp(this->menu->GetSelectedIndex());

View File

@ -18,6 +18,7 @@
int statvfs(const char *path, struct statvfs *buf); int statvfs(const char *path, struct statvfs *buf);
s32 prev_touchcount=0;
double GetAvailableSpace(const char* path) double GetAvailableSpace(const char* path)
{ {
@ -264,32 +265,42 @@ namespace inst::ui {
mainApp->Close(); mainApp->Close();
} }
if (Down & HidNpadButton_A) { HidTouchScreenState state={0};
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 (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) { if (Down & HidNpadButton_X) {
this->awooImage->SetVisible(false); this->awooImage->SetVisible(false);
this->eggImage->SetVisible(true); this->eggImage->SetVisible(true);

View File

@ -14,6 +14,7 @@
namespace inst::ui { namespace inst::ui {
extern MainApplication *mainApp; extern MainApplication *mainApp;
s32 xxx=0;
std::string lastUrl = "https://"; std::string lastUrl = "https://";
std::string lastFileID = ""; std::string lastFileID = "";
@ -172,25 +173,33 @@ namespace inst::ui {
mainApp->LoadLayout(mainApp->mainPage); mainApp->LoadLayout(mainApp->mainPage);
} }
HidTouchScreenState state={0};
if (Down & HidNpadButton_A) {
if (hidGetTouchScreenStates(&state, 1)) {
int var = this->menu->GetItems().size();
auto s = std::to_string(var); if ((Down & HidNpadButton_A) || (state.count != xxx))
//std::string s = ourUrlString; //debug stuff {
//this->appVersionText->SetText(s); //debug stuff xxx = state.count;
if (s == "0") { if (xxx != 1) {
//do nothing here because there's no items in the list, that way the app won't freeze int var = this->menu->GetItems().size();
} auto s = std::to_string(var);
else { //std::string s = ourUrlString; //debug stuff
this->selectTitle(this->menu->GetSelectedIndex()); //this->appVersionText->SetText(s); //debug stuff
if (this->menu->GetItems().size() == 1 && this->selectedUrls.size() == 1) {
this->startInstall(false); 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 ((Down & HidNpadButton_Y)) {
if (this->selectedUrls.size() == this->menu->GetItems().size()) this->drawMenuItems(true); if (this->selectedUrls.size() == this->menu->GetItems().size()) this->drawMenuItems(true);

View File

@ -17,6 +17,7 @@
namespace inst::ui { namespace inst::ui {
extern MainApplication *mainApp; extern MainApplication *mainApp;
s32 prev_touchcount=0;
std::vector<std::string> languageStrings = {"En", "Jpn", "Fr", "De", "It", "Ru", "Zh"}; std::vector<std::string> languageStrings = {"En", "Jpn", "Fr", "De", "It", "Ru", "Zh"};
@ -165,139 +166,151 @@ namespace inst::ui {
if (Down & HidNpadButton_B) { if (Down & HidNpadButton_B) {
mainApp->LoadLayout(mainApp->mainPage); mainApp->LoadLayout(mainApp->mainPage);
} }
if (Down & HidNpadButton_A) {
std::string keyboardResult; HidTouchScreenState state={0};
int rc;
std::vector<std::string> downloadUrl; if (hidGetTouchScreenStates(&state, 1)) {
std::vector<std::string> languageList;
int index = this->menu->GetSelectedIndex(); if ((Down & HidNpadButton_A) || (state.count != prev_touchcount))
switch (index) { {
case 0: prev_touchcount = state.count;
inst::config::ignoreReqVers = !inst::config::ignoreReqVers;
inst::config::setConfig(); if (prev_touchcount != 1) {
this->setMenuText();
//makes sure to jump back to the selected item once the menu is reloaded std::string keyboardResult;
this->menu->SetSelectedIndex(index); int rc;
// std::vector<std::string> downloadUrl;
break; std::vector<std::string> languageList;
case 1: int index = this->menu->GetSelectedIndex();
if (inst::config::validateNCAs) { switch (index) {
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; case 0:
} else inst::config::validateNCAs = true; inst::config::ignoreReqVers = !inst::config::ignoreReqVers;
inst::config::setConfig(); inst::config::setConfig();
this->setMenuText(); this->setMenuText();
this->menu->SetSelectedIndex(index); //makes sure to jump back to the selected item once the menu is reloaded
break; this->menu->SetSelectedIndex(index);
case 2: //
inst::config::overClock = !inst::config::overClock; break;
inst::config::setConfig(); case 1:
this->setMenuText(); if (inst::config::validateNCAs) {
this->menu->SetSelectedIndex(index); 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;
break; } else inst::config::validateNCAs = true;
case 3: inst::config::setConfig();
inst::config::deletePrompt = !inst::config::deletePrompt; this->setMenuText();
inst::config::setConfig(); this->menu->SetSelectedIndex(index);
this->setMenuText(); break;
this->menu->SetSelectedIndex(index); case 2:
break; inst::config::overClock = !inst::config::overClock;
case 4: inst::config::setConfig();
inst::config::autoUpdate = !inst::config::autoUpdate; this->setMenuText();
inst::config::setConfig(); this->menu->SetSelectedIndex(index);
this->setMenuText(); break;
this->menu->SetSelectedIndex(index); case 3:
break; inst::config::deletePrompt = !inst::config::deletePrompt;
case 5: inst::config::setConfig();
if (inst::config::gayMode) { this->setMenuText();
inst::config::gayMode = false; this->menu->SetSelectedIndex(index);
mainApp->mainPage->awooImage->SetVisible(false); break;
case 4:
} inst::config::autoUpdate = !inst::config::autoUpdate;
else { inst::config::setConfig();
inst::config::gayMode = true; this->setMenuText();
mainApp->mainPage->awooImage->SetVisible(true); this->menu->SetSelectedIndex(index);
} break;
this->setMenuText(); case 5:
this->menu->SetSelectedIndex(index); if (inst::config::gayMode) {
thememessage(); inst::config::gayMode = false;
inst::config::setConfig(); mainApp->mainPage->awooImage->SetVisible(false);
break;
}
case 6: else {
if (inst::config::useSound) { inst::config::gayMode = true;
inst::config::useSound = false; mainApp->mainPage->awooImage->SetVisible(true);
} }
else { this->setMenuText();
inst::config::useSound = true; this->menu->SetSelectedIndex(index);
} thememessage();
this->setMenuText(); inst::config::setConfig();
this->menu->SetSelectedIndex(index); break;
inst::config::setConfig();
break; case 6:
if (inst::config::useSound) {
case 7: inst::config::useSound = false;
sigPatchesMenuItem_Click(); }
break; else {
case 8: inst::config::useSound = true;
keyboardResult = inst::util::softwareKeyboard("options.sig_hint"_lang, inst::config::sigPatchesUrl.c_str(), 500); }
if (keyboardResult.size() > 0) { this->setMenuText();
inst::config::sigPatchesUrl = keyboardResult; this->menu->SetSelectedIndex(index);
inst::config::setConfig(); inst::config::setConfig();
this->setMenuText(); break;
this->menu->SetSelectedIndex(index);
} case 7:
break; sigPatchesMenuItem_Click();
case 9: break;
languageList = languageStrings; case 8:
languageList.push_back("options.language.system_language"_lang); keyboardResult = inst::util::softwareKeyboard("options.sig_hint"_lang, inst::config::sigPatchesUrl.c_str(), 500);
rc = inst::ui::mainApp->CreateShowDialog("options.language.title"_lang, "options.language.desc"_lang, languageList, false); if (keyboardResult.size() > 0) {
if (rc == -1) break; inst::config::sigPatchesUrl = keyboardResult;
switch(rc) { inst::config::setConfig();
case 0: this->setMenuText();
inst::config::languageSetting = 0; this->menu->SetSelectedIndex(index);
break; }
case 1: break;
inst::config::languageSetting = 1; case 9:
break; languageList = languageStrings;
case 2: languageList.push_back("options.language.system_language"_lang);
inst::config::languageSetting = 2; rc = inst::ui::mainApp->CreateShowDialog("options.language.title"_lang, "options.language.desc"_lang, languageList, false);
break; if (rc == -1) break;
case 3: switch(rc) {
inst::config::languageSetting = 3; case 0:
break; inst::config::languageSetting = 0;
case 4: break;
inst::config::languageSetting = 4; case 1:
break; inst::config::languageSetting = 1;
case 5: break;
inst::config::languageSetting = 5; case 2:
break; inst::config::languageSetting = 2;
case 6: break;
inst::config::languageSetting = 6; case 3:
break; inst::config::languageSetting = 3;
default: break;
inst::config::languageSetting = 99; case 4:
} inst::config::languageSetting = 4;
inst::config::setConfig(); break;
mainApp->FadeOut(); case 5:
mainApp->Close(); inst::config::languageSetting = 5;
break; break;
case 10: case 6:
if (inst::util::getIPAddress() == "1.0.0.127") { inst::config::languageSetting = 6;
inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, {"common.ok"_lang}, true); break;
break; default:
} inst::config::languageSetting = 99;
downloadUrl = inst::util::checkForAppUpdate(); }
if (!downloadUrl.size()) { inst::config::setConfig();
mainApp->CreateShowDialog("options.update.title_check_fail"_lang, "options.update.desc_check_fail"_lang, {"common.ok"_lang}, false); mainApp->FadeOut();
break; mainApp->Close();
} break;
this->askToUpdate(downloadUrl); case 10:
break; if (inst::util::getIPAddress() == "1.0.0.127") {
case 11: inst::ui::mainApp->CreateShowDialog("main.net.title"_lang, "main.net.desc"_lang, {"common.ok"_lang}, true);
inst::ui::mainApp->CreateShowDialog("options.credits.title"_lang, "options.credits.desc"_lang, {"common.close"_lang}, true); break;
break; }
default: downloadUrl = inst::util::checkForAppUpdate();
break; 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;
}
}
} }
} }
}
} }

View File

@ -11,6 +11,7 @@
namespace inst::ui { namespace inst::ui {
extern MainApplication *mainApp; extern MainApplication *mainApp;
s32 yyy=0;
sdInstPage::sdInstPage() : Layout::Layout() { sdInstPage::sdInstPage() : Layout::Layout() {
this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR("#00000080")); this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR("#00000080"));
@ -154,24 +155,34 @@ namespace inst::ui {
mainApp->LoadLayout(mainApp->mainPage); mainApp->LoadLayout(mainApp->mainPage);
} }
if (Down & HidNpadButton_A) { HidTouchScreenState state={0};
int var = this->menu->GetItems().size(); if (hidGetTouchScreenStates(&state, 1)) {
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 { if ((Down & HidNpadButton_A) || (state.count != yyy))
this->selectNsp(this->menu->GetSelectedIndex()); {
yyy = state.count;
if (this->ourFiles.size() == 1 && this->selectedTitles.size() == 1) {
this->startInstall(); 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 ((Down & HidNpadButton_Y)) {
if (this->selectedTitles.size() == this->ourFiles.size()) this->drawMenuItems(true, currentDir); if (this->selectedTitles.size() == this->ourFiles.size()) this->drawMenuItems(true, currentDir);
else { else {

View File

@ -10,6 +10,7 @@
namespace inst::ui { namespace inst::ui {
extern MainApplication *mainApp; extern MainApplication *mainApp;
s32 www=0; //touchscreen variable
usbInstPage::usbInstPage() : Layout::Layout() { usbInstPage::usbInstPage() : Layout::Layout() {
this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR("#00000080")); this->infoRect = Rectangle::New(0, 95, 1280, 60, COLOR("#00000080"));
@ -117,24 +118,30 @@ namespace inst::ui {
mainApp->LoadLayout(mainApp->mainPage); mainApp->LoadLayout(mainApp->mainPage);
} }
if (Down & HidNpadButton_A) { HidTouchScreenState state={0};
int var = this->menu->GetItems().size(); if (hidGetTouchScreenStates(&state, 1)) {
auto s = std::to_string(var);
if (s == "0") { if ((Down & HidNpadButton_A) || (state.count != www))
//do nothing here because there's no items in the list, that way the app won't freeze {
} www = state.count;
else {
this->selectTitle(this->menu->GetSelectedIndex()); if (www != 1) {
if (this->menu->GetItems().size() == 1 && this->selectedTitles.size() == 1) { int var = this->menu->GetItems().size();
this->startInstall(); 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 ((Down & HidNpadButton_Y)) {
if (this->selectedTitles.size() == this->menu->GetItems().size()) this->drawMenuItems(true); if (this->selectedTitles.size() == this->menu->GetItems().size()) this->drawMenuItems(true);
else { else {