mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 09:35:39 +00:00
(Android) Added a small input blocking delay when entering the foreground to prevent unintended button presses
This commit is contained in:
parent
55e8e4ea88
commit
a7215af23c
|
@ -62,6 +62,11 @@ namespace
|
||||||
Window* window {nullptr};
|
Window* window {nullptr};
|
||||||
int lastTime {0};
|
int lastTime {0};
|
||||||
|
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
int inputBlockTime {0};
|
||||||
|
bool blockInput {false};
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(APPLICATION_UPDATER)
|
#if defined(APPLICATION_UPDATER)
|
||||||
bool noUpdateCheck {false};
|
bool noUpdateCheck {false};
|
||||||
#endif
|
#endif
|
||||||
|
@ -496,6 +501,15 @@ void applicationLoop()
|
||||||
#endif
|
#endif
|
||||||
if (SDL_PollEvent(&event)) {
|
if (SDL_PollEvent(&event)) {
|
||||||
do {
|
do {
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
// Prevent that button presses get registered immediately when entering the
|
||||||
|
// foreground (which most commonly mean we're returning from a game).
|
||||||
|
if (event.type == SDL_APP_WILLENTERFOREGROUND) {
|
||||||
|
blockInput = true;
|
||||||
|
inputBlockTime = 0;
|
||||||
|
window->setBlockInput(true);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
InputManager::getInstance().parseEvent(event);
|
InputManager::getInstance().parseEvent(event);
|
||||||
|
|
||||||
if (event.type == SDL_QUIT)
|
if (event.type == SDL_QUIT)
|
||||||
|
@ -515,6 +529,16 @@ void applicationLoop()
|
||||||
if (deltaTime < 0)
|
if (deltaTime < 0)
|
||||||
deltaTime = 1000;
|
deltaTime = 1000;
|
||||||
|
|
||||||
|
#if defined(__ANDROID__)
|
||||||
|
if (blockInput) {
|
||||||
|
inputBlockTime += deltaTime;
|
||||||
|
if (inputBlockTime > 300) {
|
||||||
|
inputBlockTime = 0;
|
||||||
|
blockInput = false;
|
||||||
|
window->setBlockInput(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
window->update(deltaTime);
|
window->update(deltaTime);
|
||||||
window->render();
|
window->render();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue