Added support for reboot key.

This commit is contained in:
Pieter Hulshoff 2020-04-19 12:37:04 +02:00
parent 902cc0a8a5
commit 7153df848a
8 changed files with 44 additions and 20 deletions

View File

@ -75,6 +75,7 @@ bool UserInput::initialize()
MapKey("removePlaylist", KeyCodeRemovePlaylist, false);
MapKey("random", KeyCodeRandom, false);
MapKey("menu", KeyCodeMenu, false);
MapKey("reboot", KeyCodeReboot, false);
bool retVal = true;

View File

@ -62,6 +62,7 @@ public:
KeyCodeAdminMode,
KeyCodeHideItem,
KeyCodeQuit,
KeyCodeReboot,
KeyCodeMax
};

View File

@ -96,6 +96,13 @@ void Configuration::initialize()
}
}
void Configuration::clearProperties( )
{
properties_.clear( );
}
bool Configuration::import(std::string keyPrefix, std::string file)
{
return import("", keyPrefix, file);

View File

@ -27,6 +27,7 @@ public:
static void initialize();
static std::string convertToAbsolutePath(std::string prefix, std::string path);
static std::string trimEnds(std::string str);
void clearProperties( );
// gets the global configuration
bool import(std::string keyPrefix, std::string file);
bool import(std::string collection, std::string keyPrefix, std::string file, bool mustExist = true);

View File

@ -90,19 +90,22 @@ int main(int argc, char **argv)
return 0;
}
if(!ImportConfiguration(&config))
while (true)
{
// Exit with a heads up...
std::string logFile = Utils::combinePath(Configuration::absolutePath, "log.txt");
fprintf(stderr, "RetroFE has failed to start due to configuration error.\nCheck log for details: %s\n", logFile.c_str());
return -1;
if(!ImportConfiguration(&config))
{
// Exit with a heads up...
std::string logFile = Utils::combinePath(Configuration::absolutePath, "log.txt");
fprintf(stderr, "RetroFE has failed to start due to configuration error.\nCheck log for details: %s\n", logFile.c_str());
return -1;
}
RetroFE p(config);
if (p.run()) // Check if we need to reboot after running
config.clearProperties( );
else
break;
}
RetroFE p(config);
p.run();
Logger::deInitialize();
return 0;

View File

@ -69,6 +69,7 @@ RetroFE::RetroFE( Configuration &c )
, lastLaunchReturnTime_(0)
, keyLastTime_(0)
, keyDelayTime_(.3f)
, reboot_(false)
{
menuMode_ = false;
attractMode_ = false;
@ -260,18 +261,21 @@ bool RetroFE::deInitialize( )
initialized = false;
Logger::write( Logger::ZONE_INFO, "RetroFE", "Exiting" );
if ( reboot_ )
Logger::write( Logger::ZONE_INFO, "RetroFE", "Rebooting" );
else
Logger::write( Logger::ZONE_INFO, "RetroFE", "Exiting" );
return retVal;
}
// Run RetroFE
void RetroFE::run( )
bool RetroFE::run( )
{
// Initialize SDL
if(! SDL::initialize( config_ ) ) return;
if(! SDL::initialize( config_ ) ) return false;
fontcache_.initialize( );
// Define control configuration
@ -279,7 +283,7 @@ void RetroFE::run( )
if ( !config_.import( "controls", controlsConfPath ) )
{
Logger::write( Logger::ZONE_ERROR, "RetroFE", "Could not import \"" + controlsConfPath + "\"" );
return;
return false;
}
float preloadTime = 0;
@ -299,7 +303,7 @@ void RetroFE::run( )
if ( !initializeThread )
{
Logger::write( Logger::ZONE_INFO, "RetroFE", "Could not initialize RetroFE" );
return;
return false;
}
int attractModeTime = 0;
@ -1172,9 +1176,7 @@ void RetroFE::run( )
// Wait for onExit animation to finish before quitting RetroFE
case RETROFE_QUIT:
if ( currentPage_->isGraphicsIdle( ) )
{
running = false;
}
running = false;
break;
}
@ -1252,6 +1254,7 @@ void RetroFE::run( )
render( );
}
}
return reboot_;
}
@ -1515,6 +1518,13 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput( Page *page )
attract_.reset( );
state = RETROFE_QUIT_REQUEST;
}
else if (input_.keystate(UserInput::KeyCodeReboot))
{
attract_.reset( );
reboot_ = true;
state = RETROFE_QUIT_REQUEST;
}
}
// Check if we're done scrolling

View File

@ -44,7 +44,7 @@ public:
RetroFE( Configuration &c );
virtual ~RetroFE( );
bool deInitialize( );
void run( );
bool run( );
void freeGraphicsMemory( );
void allocateGraphicsMemory( );
void launchEnter( );
@ -134,6 +134,7 @@ private:
AttractMode attract_;
bool menuMode_;
bool attractMode_;
bool reboot_;
std::map<std::string, unsigned int> lastMenuOffsets_;
std::map<std::string, std::string> lastMenuPlaylists_;

View File

@ -21,7 +21,7 @@
std::string retrofe_version_major = "0";
std::string retrofe_version_minor = "9";
std::string retrofe_version_build = "32";
std::string retrofe_version_build = "33";
std::string Version::getString( )