Fixed multiple issues and glitches related to the screensaver.

This commit is contained in:
Leon Styhre 2020-09-18 18:40:22 +02:00
parent afa91aa093
commit 522fbebee8
5 changed files with 75 additions and 71 deletions

View file

@ -1,4 +1,6 @@
// SPDX-License-Identifier: MIT
// //
// EmulationStation Desktop Edition
// SystemScreenSaver.cpp // SystemScreenSaver.cpp
// //
// Screensaver, supporting the following modes: // Screensaver, supporting the following modes:
@ -86,9 +88,8 @@ void SystemScreenSaver::startScreenSaver()
if (!mVideoScreensaver && (screensaver_behavior == "video")) { if (!mVideoScreensaver && (screensaver_behavior == "video")) {
// Configure to fade out the windows, skip fading if mode is set to Instant. // Configure to fade out the windows, skip fading if mode is set to Instant.
mState = PowerSaver::getMode() == PowerSaver::INSTANT mState = PowerSaver::getMode() ==
? STATE_SCREENSAVER_ACTIVE PowerSaver::INSTANT ? STATE_SCREENSAVER_ACTIVE : STATE_FADE_OUT_WINDOW;
: STATE_FADE_OUT_WINDOW;
mVideoChangeTime = Settings::getInstance()->getInt("ScreenSaverSwapVideoTimeout"); mVideoChangeTime = Settings::getInstance()->getInt("ScreenSaverSwapVideoTimeout");
mOpacity = 0.0f; mOpacity = 0.0f;
@ -120,11 +121,11 @@ void SystemScreenSaver::startScreenSaver()
Renderer::getScreenHeight() / 2.0f); Renderer::getScreenHeight() / 2.0f);
if (Settings::getInstance()->getBool("ScreenSaverStretchVideos")) if (Settings::getInstance()->getBool("ScreenSaverStretchVideos"))
mVideoScreensaver->setResize((float)Renderer::getScreenWidth(), mVideoScreensaver->setResize(static_cast<float>(Renderer::getScreenWidth()),
(float)Renderer::getScreenHeight()); static_cast<float>(Renderer::getScreenHeight()));
else else
mVideoScreensaver->setMaxSize((float)Renderer::getScreenWidth(), mVideoScreensaver->setMaxSize(static_cast<float>(Renderer::getScreenWidth()),
(float)Renderer::getScreenHeight()); static_cast<float>(Renderer::getScreenHeight()));
mVideoScreensaver->setVideo(path); mVideoScreensaver->setVideo(path);
mVideoScreensaver->setScreensaverMode(true); mVideoScreensaver->setScreensaverMode(true);
@ -136,9 +137,8 @@ void SystemScreenSaver::startScreenSaver()
} }
else if (screensaver_behavior == "slideshow") { else if (screensaver_behavior == "slideshow") {
// Configure to fade out the windows, skip fading if mode is set to Instant. // Configure to fade out the windows, skip fading if mode is set to Instant.
mState = PowerSaver::getMode() == PowerSaver::INSTANT mState = PowerSaver::getMode() ==
? STATE_SCREENSAVER_ACTIVE PowerSaver::INSTANT ? STATE_SCREENSAVER_ACTIVE : STATE_FADE_OUT_WINDOW;
: STATE_FADE_OUT_WINDOW;
mVideoChangeTime = Settings::getInstance()->getInt("ScreenSaverSwapImageTimeout"); mVideoChangeTime = Settings::getInstance()->getInt("ScreenSaverSwapImageTimeout");
mOpacity = 0.0f; mOpacity = 0.0f;
@ -164,11 +164,11 @@ void SystemScreenSaver::startScreenSaver()
Renderer::getScreenHeight() / 2.0f); Renderer::getScreenHeight() / 2.0f);
if (Settings::getInstance()->getBool("ScreenSaverStretchImages")) if (Settings::getInstance()->getBool("ScreenSaverStretchImages"))
mImageScreensaver->setResize((float)Renderer::getScreenWidth(), mImageScreensaver->setResize(static_cast<float>(Renderer::getScreenWidth()),
(float)Renderer::getScreenHeight()); static_cast<float>(Renderer::getScreenHeight()));
else else
mImageScreensaver->setMaxSize((float)Renderer::getScreenWidth(), mImageScreensaver->setMaxSize(static_cast<float>(Renderer::getScreenWidth()),
(float)Renderer::getScreenHeight()); static_cast<float>(Renderer::getScreenHeight()));
std::string bg_audio_file = Settings::getInstance()-> std::string bg_audio_file = Settings::getInstance()->
getString("SlideshowScreenSaverBackgroundAudioFile"); getString("SlideshowScreenSaverBackgroundAudioFile");
@ -222,7 +222,7 @@ void SystemScreenSaver::renderScreenSaver()
Renderer::getScreenHeight(), 0x000000FF, 0x000000FF); Renderer::getScreenHeight(), 0x000000FF, 0x000000FF);
// Only render the video if the state requires it. // Only render the video if the state requires it.
if ((int)mState >= STATE_FADE_IN_VIDEO) { if (static_cast<int>(mState) >= STATE_FADE_IN_VIDEO) {
Transform4x4f transform = Transform4x4f::Identity(); Transform4x4f transform = Transform4x4f::Identity();
mVideoScreensaver->render(transform); mVideoScreensaver->render(transform);
} }
@ -236,7 +236,7 @@ void SystemScreenSaver::renderScreenSaver()
// Only render the video if the state requires it. // Only render the video if the state requires it.
if ((int)mState >= STATE_FADE_IN_VIDEO) { if ((int)mState >= STATE_FADE_IN_VIDEO) {
if (mImageScreensaver->hasImage()) { if (mImageScreensaver->hasImage()) {
mImageScreensaver->setOpacity(255- (unsigned char) (mOpacity * 255)); mImageScreensaver->setOpacity(255 - static_cast<unsigned char>(mOpacity * 255));
Transform4x4f transform = Transform4x4f::Identity(); Transform4x4f transform = Transform4x4f::Identity();
mImageScreensaver->render(transform); mImageScreensaver->render(transform);
@ -357,7 +357,8 @@ void SystemScreenSaver::pickRandomVideo(std::string& path)
// not shown again. // not shown again.
if (mVideoCount > 0) { if (mVideoCount > 0) {
do { do {
int video = (int)(((float)rand() / float(RAND_MAX)) * (float)mVideoCount); int video = static_cast<int>((static_cast<float>(rand()) /
static_cast<float>(RAND_MAX)) * static_cast<float>(mVideoCount));
pickGameListNode(video, "video", path); pickGameListNode(video, "video", path);
} }
while (mPreviousGame && mCurrentGame == mPreviousGame); while (mPreviousGame && mCurrentGame == mPreviousGame);
@ -376,7 +377,8 @@ void SystemScreenSaver::pickRandomGameListImage(std::string& path)
// not shown again. // not shown again.
if (mImageCount > 0) { if (mImageCount > 0) {
do { do {
int image = (int)(((float)rand() / float(RAND_MAX)) * (float)mImageCount); int image = static_cast<int>((static_cast<float>(rand()) /
static_cast<float>(RAND_MAX)) * static_cast<float>(mImageCount));
pickGameListNode(image, "image", path); pickGameListNode(image, "image", path);
} }
while (mPreviousGame && mCurrentGame == mPreviousGame); while (mPreviousGame && mCurrentGame == mPreviousGame);
@ -405,7 +407,7 @@ void SystemScreenSaver::pickRandomCustomImage(std::string& path)
} }
} }
int fileCount = (int)matchingFiles.size(); int fileCount = static_cast<int>(matchingFiles.size());
if (fileCount > 0) { if (fileCount > 0) {
// Get a random index in the range 0 to fileCount (exclusive). // Get a random index in the range 0 to fileCount (exclusive).
int randomIndex = rand() % fileCount; int randomIndex = rand() % fileCount;
@ -425,7 +427,7 @@ void SystemScreenSaver::update(int deltaTime)
{ {
// Use this to update the fade value for the current fade stage. // Use this to update the fade value for the current fade stage.
if (mState == STATE_FADE_OUT_WINDOW) { if (mState == STATE_FADE_OUT_WINDOW) {
mOpacity += (float)deltaTime / FADE_TIME; mOpacity += static_cast<float>(deltaTime) / FADE_TIME;
if (mOpacity >= 1.0f) { if (mOpacity >= 1.0f) {
mOpacity = 1.0f; mOpacity = 1.0f;
@ -434,7 +436,7 @@ void SystemScreenSaver::update(int deltaTime)
} }
} }
else if (mState == STATE_FADE_IN_VIDEO) { else if (mState == STATE_FADE_IN_VIDEO) {
mOpacity -= (float)deltaTime / FADE_TIME; mOpacity -= static_cast<float>(deltaTime) / FADE_TIME;
if (mOpacity <= 0.0f) { if (mOpacity <= 0.0f) {
mOpacity = 0.0f; mOpacity = 0.0f;
// Update to the next state. // Update to the next state.
@ -475,7 +477,7 @@ void SystemScreenSaver::launchGame()
IGameListView* view = ViewController::get()-> IGameListView* view = ViewController::get()->
getGameListView(mCurrentGame->getSystem()).get(); getGameListView(mCurrentGame->getSystem()).get();
view->setCursor(mCurrentGame); view->setCursor(mCurrentGame);
if (Settings::getInstance()->getBool("ScreenSaverControls")) ViewController::get()->resetMovingCamera();
view->launch(mCurrentGame); ViewController::get()->launch(mCurrentGame);
} }
} }

View file

@ -1,11 +1,12 @@
// SPDX-License-Identifier: MIT
// //
// EmulationStation Desktop Edition
// SystemScreenSaver.h // SystemScreenSaver.h
// //
// Screensaver, supporting the following modes: // Screensaver, supporting the following modes:
// Dim, black, slideshow, video. // Dim, black, slideshow, video.
// //
#pragma once
#ifndef ES_APP_SYSTEM_SCREEN_SAVER_H #ifndef ES_APP_SYSTEM_SCREEN_SAVER_H
#define ES_APP_SYSTEM_SCREEN_SAVER_H #define ES_APP_SYSTEM_SCREEN_SAVER_H

View file

@ -37,7 +37,8 @@ SystemView::SystemView(
mExtrasCamOffset = 0; mExtrasCamOffset = 0;
mExtrasFadeOpacity = 0.0f; mExtrasFadeOpacity = 0.0f;
setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight()); setSize(static_cast<float>(Renderer::getScreenWidth()),
static_cast<float>(Renderer::getScreenHeight()));
populate(); populate();
} }
@ -218,13 +219,7 @@ bool SystemView::input(InputConfig* config, Input input)
setCursor(SystemData::getRandomSystem(getSelected())); setCursor(SystemData::getRandomSystem(getSelected()));
return true; return true;
} }
}
else {
if (config->isMappedLike("left", input) ||
config->isMappedLike("right", input) ||
config->isMappedLike("up", input) ||
config->isMappedLike("down", input))
listInput(0);
if (!UIModeController::getInstance()->isUIModeKid() && if (!UIModeController::getInstance()->isUIModeKid() &&
config->isMappedTo("select", input) && config->isMappedTo("select", input) &&
Settings::getInstance()->getBool("ScreenSaverControls")) { Settings::getInstance()->getBool("ScreenSaverControls")) {
@ -232,12 +227,16 @@ bool SystemView::input(InputConfig* config, Input input)
mWindow->startScreenSaver(); mWindow->startScreenSaver();
mWindow->renderScreenSaver(); mWindow->renderScreenSaver();
} }
else {
mWindow->cancelScreenSaver();
}
return true; return true;
} }
} }
else {
if (config->isMappedLike("left", input) ||
config->isMappedLike("right", input) ||
config->isMappedLike("up", input) ||
config->isMappedLike("down", input))
listInput(0);
}
return GuiComponent::input(config, input); return GuiComponent::input(config, input);
} }
@ -255,8 +254,8 @@ void SystemView::onCursorChanged(const CursorState& /*state*/)
float startPos = mCamOffset; float startPos = mCamOffset;
float posMax = (float)mEntries.size(); float posMax = static_cast<float>(mEntries.size());
float target = (float)mCursor; float target = static_cast<float>(mCursor);
// What's the shortest way to get to our target? // What's the shortest way to get to our target?
// It's one of these... // It's one of these...
@ -280,8 +279,9 @@ void SystemView::onCursorChanged(const CursorState& /*state*/)
Animation* infoFadeOut = new LambdaAnimation( Animation* infoFadeOut = new LambdaAnimation(
[infoStartOpacity, this] (float t) { [infoStartOpacity, this] (float t) {
mSystemInfo.setOpacity((unsigned char)(Math::lerp(infoStartOpacity, 0.f, t) * 255)); mSystemInfo.setOpacity(static_cast<unsigned char>(
}, (int)(infoStartOpacity * (goFast ? 10 : 150))); Math::lerp(infoStartOpacity, 0.f, t) * 255));
}, static_cast<int>(infoStartOpacity * (goFast ? 10 : 150)));
unsigned int gameCount = getSelected()->getDisplayedGameCount(); unsigned int gameCount = getSelected()->getDisplayedGameCount();
@ -299,7 +299,7 @@ void SystemView::onCursorChanged(const CursorState& /*state*/)
Animation* infoFadeIn = new LambdaAnimation( Animation* infoFadeIn = new LambdaAnimation(
[this](float t) { [this](float t) {
mSystemInfo.setOpacity((unsigned char)(Math::lerp(0.f, 1.f, t) * 255)); mSystemInfo.setOpacity(static_cast<unsigned char>(Math::lerp(0.f, 1.f, t) * 255));
}, goFast ? 10 : 300); }, goFast ? 10 : 300);
// Wait 150ms to fade in. // Wait 150ms to fade in.
@ -467,8 +467,8 @@ void SystemView::renderCarousel(const Transform4x4f& trans)
mCarousel.origin.y() * mCarousel.size.y() * -1, 0.0f)); mCarousel.origin.y() * mCarousel.size.y() * -1, 0.0f));
Vector2f clipPos(carouselTrans.translation().x(), carouselTrans.translation().y()); Vector2f clipPos(carouselTrans.translation().x(), carouselTrans.translation().y());
Renderer::pushClipRect(Vector2i((int)clipPos.x(), (int)clipPos.y()), Renderer::pushClipRect(Vector2i(static_cast<int>(clipPos.x()), static_cast<int>(clipPos.y())),
Vector2i((int)mCarousel.size.x(), (int)mCarousel.size.y())); Vector2i(static_cast<int>(mCarousel.size.x()), static_cast<int>(mCarousel.size.y())));
Renderer::setMatrix(carouselTrans); Renderer::setMatrix(carouselTrans);
Renderer::drawRect(0.0f, 0.0f, mCarousel.size.x(), mCarousel.size.y(), Renderer::drawRect(0.0f, 0.0f, mCarousel.size.x(), mCarousel.size.y(),
@ -530,8 +530,8 @@ void SystemView::renderCarousel(const Transform4x4f& trans)
break; break;
} }
int center = (int)(mCamOffset); int center = static_cast<int>(mCamOffset);
int logoCount = Math::min(mCarousel.maxLogoCount, (int)mEntries.size()); int logoCount = Math::min(mCarousel.maxLogoCount, static_cast<int>(mEntries.size()));
// Adding texture loading buffers depending on scrolling speed and status. // Adding texture loading buffers depending on scrolling speed and status.
int bufferIndex = getScrollingVelocity() + 1; int bufferIndex = getScrollingVelocity() + 1;
@ -546,9 +546,9 @@ void SystemView::renderCarousel(const Transform4x4f& trans)
i <= center + logoCount / 2 + bufferRight; i++) { i <= center + logoCount / 2 + bufferRight; i++) {
int index = i; int index = i;
while (index < 0) while (index < 0)
index += (int)mEntries.size(); index += static_cast<int>(mEntries.size());
while (index >= (int)mEntries.size()) while (index >= static_cast<int>(mEntries.size()))
index -= (int)mEntries.size(); index -= static_cast<int>(mEntries.size());
Transform4x4f logoTrans = carouselTrans; Transform4x4f logoTrans = carouselTrans;
logoTrans.translate(Vector3f(i * logoSpacing[0] + xOff, i * logoSpacing[1] + yOff, 0)); logoTrans.translate(Vector3f(i * logoSpacing[0] + xOff, i * logoSpacing[1] + yOff, 0));
@ -559,8 +559,9 @@ void SystemView::renderCarousel(const Transform4x4f& trans)
scale = Math::min(mCarousel.logoScale, Math::max(1.0f, scale)); scale = Math::min(mCarousel.logoScale, Math::max(1.0f, scale));
scale /= mCarousel.logoScale; scale /= mCarousel.logoScale;
int opacity = (int)Math::round(0x80 + ((0xFF - 0x80) * (1.0f - fabs(distance)))); int opacity = static_cast<int>(Math::round(0x80 + ((0xFF - 0x80) *
opacity = Math::max((int) 0x80, opacity); (1.0f - fabs(distance)))));
opacity = Math::max(static_cast<int>(0x80), opacity);
const std::shared_ptr<GuiComponent> &comp = mEntries.at(index).data.logo; const std::shared_ptr<GuiComponent> &comp = mEntries.at(index).data.logo;
if (mCarousel.type == VERTICAL_WHEEL || mCarousel.type == HORIZONTAL_WHEEL) { if (mCarousel.type == VERTICAL_WHEEL || mCarousel.type == HORIZONTAL_WHEEL) {
@ -568,7 +569,7 @@ void SystemView::renderCarousel(const Transform4x4f& trans)
comp->setRotationOrigin(mCarousel.logoRotationOrigin); comp->setRotationOrigin(mCarousel.logoRotationOrigin);
} }
comp->setScale(scale); comp->setScale(scale);
comp->setOpacity((unsigned char)opacity); comp->setOpacity(static_cast<unsigned char>(opacity));
comp->render(logoTrans); comp->render(logoTrans);
} }
Renderer::popClipRect(); Renderer::popClipRect();
@ -583,20 +584,21 @@ void SystemView::renderInfoBar(const Transform4x4f& trans)
// Draw background extras. // Draw background extras.
void SystemView::renderExtras(const Transform4x4f& trans, float lower, float upper) void SystemView::renderExtras(const Transform4x4f& trans, float lower, float upper)
{ {
int extrasCenter = (int)mExtrasCamOffset; int extrasCenter = static_cast<int>(mExtrasCamOffset);
// Adding texture loading buffers depending on scrolling speed and status. // Adding texture loading buffers depending on scrolling speed and status.
int bufferIndex = getScrollingVelocity() + 1; int bufferIndex = getScrollingVelocity() + 1;
Renderer::pushClipRect(Vector2i::Zero(), Vector2i((int)mSize.x(), (int)mSize.y())); Renderer::pushClipRect(Vector2i::Zero(), Vector2i(static_cast<int>(mSize.x()),
static_cast<int>(mSize.y())));
for (int i = extrasCenter + logoBuffersLeft[bufferIndex]; i <= extrasCenter + for (int i = extrasCenter + logoBuffersLeft[bufferIndex]; i <= extrasCenter +
logoBuffersRight[bufferIndex]; i++) { logoBuffersRight[bufferIndex]; i++) {
int index = i; int index = i;
while (index < 0) while (index < 0)
index += (int)mEntries.size(); index += static_cast<int>(mEntries.size());
while (index >= (int)mEntries.size()) while (index >= static_cast<int>(mEntries.size()))
index -= (int)mEntries.size(); index -= static_cast<int>(mEntries.size());
// Only render selected system when not showing. // Only render selected system when not showing.
if (mShowing || index == mCursor) if (mShowing || index == mCursor)
@ -607,9 +609,9 @@ void SystemView::renderExtras(const Transform4x4f& trans, float lower, float upp
else else
extrasTrans.translate(Vector3f(0, (i - mExtrasCamOffset) * mSize.y(), 0)); extrasTrans.translate(Vector3f(0, (i - mExtrasCamOffset) * mSize.y(), 0));
Renderer::pushClipRect(Vector2i((int)extrasTrans.translation()[0], Renderer::pushClipRect(Vector2i(static_cast<int>(extrasTrans.translation()[0]),
(int)extrasTrans.translation()[1]), static_cast<int>(extrasTrans.translation()[1])),
Vector2i((int)mSize.x(), (int)mSize.y())); Vector2i(static_cast<int>(mSize.x()), static_cast<int>(mSize.y())));
SystemViewData data = mEntries.at(index).data; SystemViewData data = mEntries.at(index).data;
for (unsigned int j = 0; j < data.backgroundExtras.size(); j++) { for (unsigned int j = 0; j < data.backgroundExtras.size(); j++) {
GuiComponent *extra = data.backgroundExtras[j]; GuiComponent *extra = data.backgroundExtras[j];
@ -627,7 +629,7 @@ void SystemView::renderFade(const Transform4x4f& trans)
{ {
// Fade extras if necessary. // Fade extras if necessary.
if (mExtrasFadeOpacity) { if (mExtrasFadeOpacity) {
unsigned int fadeColor = 0x00000000 | (unsigned char)(mExtrasFadeOpacity * 255); unsigned int fadeColor = 0x00000000 | static_cast<unsigned char>(mExtrasFadeOpacity * 255);
Renderer::setMatrix(trans); Renderer::setMatrix(trans);
Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), fadeColor, fadeColor); Renderer::drawRect(0.0f, 0.0f, mSize.x(), mSize.y(), fadeColor, fadeColor);
} }
@ -662,7 +664,7 @@ void SystemView::getDefaultElements(void)
mSystemInfo.setPosition(0, (mCarousel.pos.y() + mCarousel.size.y() - 0.2f)); mSystemInfo.setPosition(0, (mCarousel.pos.y() + mCarousel.size.y() - 0.2f));
mSystemInfo.setBackgroundColor(0xDDDDDDD8); mSystemInfo.setBackgroundColor(0xDDDDDDD8);
mSystemInfo.setRenderBackground(true); mSystemInfo.setRenderBackground(true);
mSystemInfo.setFont(Font::get((int)(0.035f * mSize.y()), Font::getDefaultPath())); mSystemInfo.setFont(Font::get(static_cast<int>(0.035f * mSize.y()), Font::getDefaultPath()));
mSystemInfo.setColor(0x000000FF); mSystemInfo.setColor(0x000000FF);
mSystemInfo.setZIndex(50); mSystemInfo.setZIndex(50);
mSystemInfo.setDefaultZIndex(50); mSystemInfo.setDefaultZIndex(50);
@ -699,7 +701,7 @@ void SystemView::getCarouselFromTheme(const ThemeData::ThemeElement* elem)
if (elem->has("logoSize")) if (elem->has("logoSize"))
mCarousel.logoSize = elem->get<Vector2f>("logoSize") * mSize; mCarousel.logoSize = elem->get<Vector2f>("logoSize") * mSize;
if (elem->has("maxLogoCount")) if (elem->has("maxLogoCount"))
mCarousel.maxLogoCount = (int)Math::round(elem->get<float>("maxLogoCount")); mCarousel.maxLogoCount = static_cast<int>(Math::round(elem->get<float>("maxLogoCount")));
if (elem->has("zIndex")) if (elem->has("zIndex"))
mCarousel.zIndex = elem->get<float>("zIndex"); mCarousel.zIndex = elem->get<float>("zIndex");
if (elem->has("logoRotation")) if (elem->has("logoRotation"))

View file

@ -191,7 +191,7 @@ void ViewController::goToPrevGameList()
void ViewController::goToGameList(SystemData* system) void ViewController::goToGameList(SystemData* system)
{ {
// Stop any scrolling, animations and camera movements. // Stop any scrolling, animations and camera movements.
if (mSystemListView) { if (mState.viewing == SYSTEM_SELECT) {
mSystemListView->stopScrolling(); mSystemListView->stopScrolling();
if (mSystemListView->isAnimationPlaying(0)) if (mSystemListView->isAnimationPlaying(0))
mSystemListView->finishAnimation(0); mSystemListView->finishAnimation(0);
@ -201,9 +201,8 @@ void ViewController::goToGameList(SystemData* system)
// Disable rendering of the system view. // Disable rendering of the system view.
if (getSystemListView()->getRenderView()) if (getSystemListView()->getRenderView())
getSystemListView()->setRenderView(false); getSystemListView()->setRenderView(false);
// If switching between gamelists, disable rendering of the current view. // If switching between gamelists, disable rendering of the current view.
if (mCurrentView) else if (mCurrentView)
mCurrentView->setRenderView(false); mCurrentView->setRenderView(false);
if (mState.viewing == SYSTEM_SELECT) { if (mState.viewing == SYSTEM_SELECT) {
@ -329,8 +328,6 @@ void ViewController::launch(FileData* game, Vector3f center)
while (NavigationSounds::getInstance()->isPlayingThemeNavigationSound(LAUNCHSOUND)); while (NavigationSounds::getInstance()->isPlayingThemeNavigationSound(LAUNCHSOUND));
game->launchGame(mWindow); game->launchGame(mWindow);
onFileChanged(game, FILE_METADATA_CHANGED); onFileChanged(game, FILE_METADATA_CHANGED);
if (mCurrentView)
mCurrentView->onShow();
// This is a workaround so that any key or button presses used for exiting the emulator // This is a workaround so that any key or button presses used for exiting the emulator
// are not captured upon returning to ES. // are not captured upon returning to ES.
setAnimation(new LambdaAnimation([](float t){}, 1), 0, [this] { setAnimation(new LambdaAnimation([](float t){}, 1), 0, [this] {

View file

@ -136,6 +136,8 @@ void Window::textInput(const char* text)
void Window::input(InputConfig* config, Input input) void Window::input(InputConfig* config, Input input)
{ {
mTimeSinceLastInput = 0;
if (Settings::getInstance()->getBool("Debug")) if (Settings::getInstance()->getBool("Debug"))
logInput(config, input); logInput(config, input);
@ -168,17 +170,17 @@ void Window::input(InputConfig* config, Input input)
if (mSleeping) { if (mSleeping) {
// Wake up. // Wake up.
mTimeSinceLastInput = 0;
cancelScreenSaver(); cancelScreenSaver();
mSleeping = false; mSleeping = false;
onWake(); onWake();
return; return;
} }
mTimeSinceLastInput = 0; // Any keypress cancels the screensaver.
if (!config->isMappedTo("select", input)) if (input.value != 0 && isScreenSaverActive()) {
if (cancelScreenSaver()) cancelScreenSaver();
return; return;
}
if (config->getDeviceId() == DEVICE_KEYBOARD && input.value && input.id == SDLK_g && if (config->getDeviceId() == DEVICE_KEYBOARD && input.value && input.id == SDLK_g &&
SDL_GetModState() & KMOD_LCTRL && Settings::getInstance()->getBool("Debug")) { SDL_GetModState() & KMOD_LCTRL && Settings::getInstance()->getBool("Debug")) {