Commit 43d8cab4 authored by Bkg2k's avatar Bkg2k

fix(demo): get controller config only once before context deinit

parent 483d538b
......@@ -132,10 +132,11 @@ void DemoMode::runDemo()
{
if (!hasDemoMode()) return;
SystemData* system = nullptr;
FileData* game = nullptr;
int duration = 0;
bool Initialized = false;
SystemData* system = nullptr;
std::string controllerConfigs;
while(getRandomGame(game, duration))
{
......@@ -144,11 +145,11 @@ void DemoMode::runDemo()
// Initialize (shutdown ES display)
if (!Initialized)
{
system->demoInitialize(mWindow);
controllerConfigs = system->demoInitialize(mWindow);
Initialized = true;
}
// Run game
if (system->demoLaunchGame(game, duration))
if (system->demoLaunchGame(game, duration, controllerConfigs))
{
mWindow.doWake();
break;
......
......@@ -229,14 +229,19 @@ void SystemData::launchGame(Window* window, FileData* game, const std::string& n
game->Metadata().SetLastplayedNow();
}
void SystemData::demoInitialize(Window& window)
std::string SystemData::demoInitialize(Window& window)
{
LOG(LogInfo) << "Entering demo mode...";
std::string controlersConfig = InputManager::getInstance()->configureEmulators();
LOG(LogInfo) << "Controllers config : " << controlersConfig;
AudioManager::getInstance()->deinit();
VolumeControl::getInstance()->deinit();
window.deinit();
return controlersConfig;
}
void SystemData::demoFinalize(Window& window)
......@@ -248,10 +253,8 @@ void SystemData::demoFinalize(Window& window)
window.normalizeNextUpdate();
}
bool SystemData::demoLaunchGame(FileData* game, int duration)
bool SystemData::demoLaunchGame(FileData* game, int duration, const std::string& controlersConfig)
{
std::string controlersConfig = InputManager::getInstance()->configureEmulators();
LOG(LogInfo) << "Controllers config : " << controlersConfig;
std::string command = mLaunchCommand;
......
......@@ -154,7 +154,7 @@ class SystemData
static std::string getUserConfigurationAbsolutePath() { return RootFolders::DataRootFolder + "/system/.emulationstation/es_systems.cfg"; }
static std::string getTemplateConfigurationAbsolutePath() { return RootFolders::TemplateRootFolder + "/system/.emulationstation/es_systems.cfg"; }
void demoInitialize(Window& window);
std::string demoInitialize(Window& window);
void demoFinalize(Window& window);
bool demoLaunchGame(FileData* game, int duration);
bool demoLaunchGame(FileData* game, int duration, const std::string& controlersConfig);
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment