Add support for key repeats via UC_KEY_REPEAT flag

This commit is contained in:
RocketRobz
2021-09-03 21:21:37 -06:00
parent 2d75edbc92
commit bb846879b8
3 changed files with 33 additions and 0 deletions
+24
View File
@@ -340,11 +340,34 @@ void Gui::DrawScreen(bool stack) {
Do the current screen's logic. Do the current screen's logic.
u32 hDown: The hidKeysDown() variable. u32 hDown: The hidKeysDown() variable.
u32 hDownRepeat: the hidKeysDownRepeat() variable.
u32 hHeld: The hidKeysHeld() variable. u32 hHeld: The hidKeysHeld() variable.
touchPosition touch: The touchPosition variable. touchPosition touch: The touchPosition variable.
bool waitFade: If waiting for the fade until control of the screen or not. bool waitFade: If waiting for the fade until control of the screen or not.
bool stack: If using the stack-screens. bool stack: If using the stack-screens.
*/ */
#ifdef UC_KEY_REPEAT
void Gui::ScreenLogic(u32 hDown, u32 hDownRepeat, u32 hHeld, touchPosition touch, bool waitFade, bool stack) {
if (waitFade) {
if (!fadein && !fadeout && !fadein2 && !fadeout2) {
if (!stack) {
if (usedScreen) usedScreen->Logic(hDown, hDownRepeat, hHeld, touch);
} else {
if (!screens.empty()) screens.top()->Logic(hDown, hDownRepeat, hHeld, touch);
}
}
} else {
if (!stack) {
if (usedScreen) usedScreen->Logic(hDown, hDownRepeat, hHeld, touch);
} else {
if (!screens.empty()) screens.top()->Logic(hDown, hDownRepeat, hHeld, touch);
}
}
}
#else
void Gui::ScreenLogic(u32 hDown, u32 hHeld, touchPosition touch, bool waitFade, bool stack) { void Gui::ScreenLogic(u32 hDown, u32 hHeld, touchPosition touch, bool waitFade, bool stack) {
if (waitFade) { if (waitFade) {
if (!fadein && !fadeout && !fadein2 && !fadeout2) { if (!fadein && !fadeout && !fadein2 && !fadeout2) {
@@ -365,6 +388,7 @@ void Gui::ScreenLogic(u32 hDown, u32 hHeld, touchPosition touch, bool waitFade,
} }
} }
} }
#endif
/* /*
Move's the tempScreen to the used one. Move's the tempScreen to the used one.
+5
View File
@@ -188,12 +188,17 @@ namespace Gui {
Used for the current Screen's Logic. (Optional!) Used for the current Screen's Logic. (Optional!)
hDown: the hidKeysDown() variable. hDown: the hidKeysDown() variable.
hDownRepeat: the hidKeysDownRepeat() variable.
hHeld: the HidKeysHeld() variable. hHeld: the HidKeysHeld() variable.
touch: The TouchPosition variable. touch: The TouchPosition variable.
waitFade: Wheter to wait until the fade ends. waitFade: Wheter to wait until the fade ends.
stack: Is it the stack variant? stack: Is it the stack variant?
*/ */
#ifdef UC_KEY_REPEAT
void ScreenLogic(u32 hDown, u32 hDownRepeat, u32 hHeld, touchPosition touch, bool waitFade = true, bool stack = false);
#else
void ScreenLogic(u32 hDown, u32 hHeld, touchPosition touch, bool waitFade = true, bool stack = false); void ScreenLogic(u32 hDown, u32 hHeld, touchPosition touch, bool waitFade = true, bool stack = false);
#endif
/* /*
Transfer the Temp Screen to the used one. (Optional!) Transfer the Temp Screen to the used one. (Optional!)
+4
View File
@@ -33,7 +33,11 @@
class Screen { class Screen {
public: public:
virtual ~Screen() {} virtual ~Screen() {}
#ifdef UC_KEY_REPEAT
virtual void Logic(u32 hDown, u32 hDownRepeat, u32 hHeld, touchPosition touch) = 0;
#else
virtual void Logic(u32 hDown, u32 hHeld, touchPosition touch) = 0; virtual void Logic(u32 hDown, u32 hHeld, touchPosition touch) = 0;
#endif
virtual void Draw() const = 0; virtual void Draw() const = 0;
}; };