diff --git a/include/screens/credits.hpp b/include/screens/credits.hpp index 59b0f8e..208c9bf 100644 --- a/include/screens/credits.hpp +++ b/include/screens/credits.hpp @@ -42,6 +42,7 @@ private: int creditsPage = 0; int screenPos = 0; int Selection = 0; + int keyRepeatDelay = 0; std::vector arrowPos = { {0, 215, 25, 25}, // Back Arrow. diff --git a/include/screens/settings.hpp b/include/screens/settings.hpp index a5aee86..ef00f7c 100644 --- a/include/screens/settings.hpp +++ b/include/screens/settings.hpp @@ -46,6 +46,7 @@ private: bool dropDownMenu = false; mutable int screenPos = 0; int colorSelection = 0; + int keyRepeatDelay = 0; // Draws. void DrawSubMenu(void) const; @@ -54,8 +55,8 @@ private: void DrawMiscSettings(void) const; // Logic's. void SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch); - void LanguageSelection(u32 hDown, touchPosition touch); - void colorChanging(u32 hDown, touchPosition touch); + void LanguageSelection(u32 hDown, u32 hHeld, touchPosition touch); + void colorChanging(u32 hDown, u32 hHeld, touchPosition touch); void MiscSettingsLogic(u32 hDown, u32 hHeld, touchPosition touch); std::vector mainButtons = { diff --git a/source/screens/credits.cpp b/source/screens/credits.cpp index 73dbafc..7c80f4b 100644 --- a/source/screens/credits.cpp +++ b/source/screens/credits.cpp @@ -146,16 +146,54 @@ void Credits::DrawBottom(void) const { void Credits::Logic(u32 hDown, u32 hHeld, touchPosition touch) { + if (keyRepeatDelay) keyRepeatDelay--; // KEY_DOWN Logic. (SIZE) if (creditsPage == 0) { - if (hDown & KEY_DOWN) { if (Selection < (int)Translators.size()-1) Selection++; } + if ((hHeld & KEY_DOWN && !keyRepeatDelay)) { + if (Selection < (int)Translators.size()-1) { + Selection++; + } else { + Selection = 0; + } + + keyRepeatDelay = Config::keyDelay; + } } else if (creditsPage == 1) { - if (hDown & KEY_DOWN) { if (Selection < (int)UniversalTeam.size()-1) Selection++; } + if ((hHeld & KEY_DOWN && !keyRepeatDelay)) { + if (Selection < (int)UniversalTeam.size()-1) { + Selection++; + } else { + Selection = 0; + } + + keyRepeatDelay = Config::keyDelay; + } } else if (creditsPage == 2) { - if (hDown & KEY_DOWN) { if (Selection < (int)ScriptCreators.size()-1) Selection++; } + if ((hHeld & KEY_DOWN && !keyRepeatDelay)) { + if (Selection < (int)ScriptCreators.size()-1) { + Selection++; + } else { + Selection = 0; + } + + keyRepeatDelay = Config::keyDelay; + } } - if (hDown & KEY_UP) { if (Selection > 0) Selection--; } + if ((hHeld & KEY_UP && !keyRepeatDelay)) { + if (Selection > 0) { + Selection--; + } else { + if (creditsPage == 0) { + Selection = (int)Translators.size()-1; + } else if (creditsPage == 1) { + Selection = (int)UniversalTeam.size()-1; + } else if (creditsPage == 2) { + Selection = (int)ScriptCreators.size()-1; + } + } + keyRepeatDelay = Config::keyDelay; + } if ((hDown & KEY_L || hDown & KEY_LEFT)) { diff --git a/source/screens/settings.cpp b/source/screens/settings.cpp index 51771c2..ef76498 100644 --- a/source/screens/settings.cpp +++ b/source/screens/settings.cpp @@ -343,11 +343,27 @@ void Settings::SubMenuLogic(u32 hDown, u32 hHeld, touchPosition touch) { } std::string langsTemp[] = {"br", "da", "de", "en", "es", "fr", "it", "lt", "pl", "pt", "ru", "jp"}; -void Settings::LanguageSelection(u32 hDown, touchPosition touch) { - if (hDown & KEY_UP) { - if(selectedLang > 0) { - selectedLang--; +void Settings::LanguageSelection(u32 hDown, u32 hHeld, touchPosition touch) { + if (keyRepeatDelay) keyRepeatDelay--; + + if ((hHeld & KEY_DOWN && !keyRepeatDelay)) { + if (selectedLang < (int)languages.size()-1) { + selectedLang++; + } else { + selectedLang = 0; } + + keyRepeatDelay = Config::keyDelay; + } + + if ((hHeld & KEY_UP && !keyRepeatDelay)) { + if (selectedLang > 0) { + selectedLang--; + } else { + selectedLang = (int)languages.size()-1; + } + + keyRepeatDelay = Config::keyDelay; } if (hDown & KEY_A) { @@ -357,12 +373,6 @@ void Settings::LanguageSelection(u32 hDown, touchPosition touch) { mode = 0; } - if (hDown & KEY_DOWN) { - if(selectedLang < (int)languages.size()-1) { - selectedLang++; - } - } - if ((hDown & KEY_B)) { mode = 0; } @@ -374,7 +384,8 @@ void Settings::LanguageSelection(u32 hDown, touchPosition touch) { } -void Settings::colorChanging(u32 hDown, touchPosition touch) { +void Settings::colorChanging(u32 hDown, u32 hHeld, touchPosition touch) { + if (keyRepeatDelay) keyRepeatDelay--; int red; int green; int blue; @@ -385,8 +396,26 @@ void Settings::colorChanging(u32 hDown, touchPosition touch) { dropDownMenu = false; } - if (hDown & KEY_UP) { if (colorSelection > 0) colorSelection--; } - if (hDown & KEY_DOWN) { if (colorSelection < (int)colorList.size()-1) colorSelection++; } + if ((hHeld & KEY_DOWN && !keyRepeatDelay)) { + if (colorSelection < (int)colorList.size()-1) { + colorSelection++; + } else { + colorSelection = 0; + } + + keyRepeatDelay = Config::keyDelay; + } + + if ((hHeld & KEY_UP && !keyRepeatDelay)) { + if (colorSelection > 0) { + colorSelection--; + } else { + colorSelection = (int)colorList.size()-1; + } + + keyRepeatDelay = Config::keyDelay; + } + } else { if ((hDown & KEY_SELECT) || (hDown & KEY_TOUCH && touching(touch, arrowPos[3]))) { @@ -514,9 +543,9 @@ void Settings::Logic(u32 hDown, u32 hHeld, touchPosition touch) { if (mode == 0) { SubMenuLogic(hDown, hHeld, touch); } else if (mode == 1) { - LanguageSelection(hDown, touch); + LanguageSelection(hDown, hHeld, touch); } else if (mode == 2) { - colorChanging(hDown, touch); + colorChanging(hDown, hHeld, touch); } else if (mode == 4) { MiscSettingsLogic(hDown, hHeld, touch); }