mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05:38 +00:00
Controller input is now blocked during ROM directory rescans to avoid crashes
This commit is contained in:
parent
7467e8a7f9
commit
ca45ea6d08
|
@ -47,7 +47,6 @@ ViewController::ViewController() noexcept
|
|||
, mWrappedViews {false}
|
||||
, mFadeOpacity {0}
|
||||
, mCancelledTransition {false}
|
||||
, mLockInput {false}
|
||||
, mNextSystem {false}
|
||||
{
|
||||
mState.viewing = ViewMode::NOTHING;
|
||||
|
@ -920,7 +919,8 @@ void ViewController::launch(FileData* game)
|
|||
onFileChanged(game, true);
|
||||
// This is a workaround so that any keys or button presses used for exiting the emulator
|
||||
// are not captured upon returning.
|
||||
setAnimation(new LambdaAnimation([](float t) {}, 1), 0, [this] { mLockInput = false; });
|
||||
setAnimation(new LambdaAnimation([](float t) {}, 1), 0,
|
||||
[this] { mWindow->setBlockInput(false); });
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1069,9 +1069,6 @@ std::shared_ptr<SystemView> ViewController::getSystemListView()
|
|||
|
||||
bool ViewController::input(InputConfig* config, Input input)
|
||||
{
|
||||
if (mLockInput)
|
||||
return true;
|
||||
|
||||
// If using the %RUNINBACKGROUND% variable in a launch command or if enabling the
|
||||
// RunInBackground setting, ES-DE will run in the background while a game is launched.
|
||||
// If we're in this state and then register some input, it means that the user is back in ES-DE.
|
||||
|
@ -1411,6 +1408,8 @@ void ViewController::reloadAll()
|
|||
|
||||
void ViewController::rescanROMDirectory()
|
||||
{
|
||||
mWindow->setBlockInput(true);
|
||||
|
||||
mGamelistViews.clear();
|
||||
mSystemListView.reset();
|
||||
mCurrentView.reset();
|
||||
|
@ -1431,6 +1430,7 @@ void ViewController::rescanROMDirectory()
|
|||
|
||||
if (SystemData::sSystemVector.empty()) {
|
||||
// It's possible that there are no longer any games.
|
||||
mWindow->setBlockInput(false);
|
||||
mWindow->invalidateCachedBackground();
|
||||
noGamesDialog();
|
||||
}
|
||||
|
@ -1442,6 +1442,7 @@ void ViewController::rescanROMDirectory()
|
|||
SDL_PushEvent(&quit);
|
||||
return;
|
||||
}
|
||||
mWindow->setBlockInput(false);
|
||||
goToStart(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,9 +88,9 @@ public:
|
|||
void triggerGameLaunch(FileData* game)
|
||||
{
|
||||
mGameToLaunch = game;
|
||||
mLockInput = true;
|
||||
mWindow->setBlockInput(true);
|
||||
};
|
||||
bool getGameLaunchTriggered() { return (mGameToLaunch != nullptr); }
|
||||
const bool getGameLaunchTriggered() { return (mGameToLaunch != nullptr); }
|
||||
std::vector<std::string>& getGameEndEventParams() { return mGameEndEventParams; }
|
||||
|
||||
bool input(InputConfig* config, Input input) override;
|
||||
|
@ -192,7 +192,6 @@ private:
|
|||
float mWrapPreviousPositionX;
|
||||
float mFadeOpacity;
|
||||
bool mCancelledTransition; // Needed only for the Fade transition style.
|
||||
bool mLockInput;
|
||||
bool mNextSystem;
|
||||
};
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ Window::Window() noexcept
|
|||
, mFrameCountElapsed {0}
|
||||
, mAverageDeltaTime {10}
|
||||
, mTimeSinceLastInput {0}
|
||||
, mBlockInput {false}
|
||||
, mNormalizeNextUpdate {false}
|
||||
, mRenderScreensaver {false}
|
||||
, mRenderMediaViewer {false}
|
||||
|
@ -211,6 +212,9 @@ void Window::deinit()
|
|||
|
||||
void Window::input(InputConfig* config, Input input)
|
||||
{
|
||||
if (mBlockInput)
|
||||
return;
|
||||
|
||||
mTimeSinceLastInput = 0;
|
||||
|
||||
// The DebugSkipInputLogging option has to be set manually in es_settings.xml as
|
||||
|
|
|
@ -103,6 +103,7 @@ public:
|
|||
void update(int deltaTime);
|
||||
void render();
|
||||
|
||||
void setBlockInput(const bool state) { mBlockInput = state; }
|
||||
void normalizeNextUpdate() { mNormalizeNextUpdate = true; }
|
||||
|
||||
enum class SplashScreenState {
|
||||
|
@ -213,6 +214,7 @@ private:
|
|||
int mAverageDeltaTime;
|
||||
unsigned int mTimeSinceLastInput;
|
||||
|
||||
bool mBlockInput;
|
||||
bool mNormalizeNextUpdate;
|
||||
|
||||
bool mRenderScreensaver;
|
||||
|
|
Loading…
Reference in a new issue