From 5c11e0ddcd254a6a54cb53b003ec8adaeaa68c66 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Mon, 30 Jun 2014 18:06:00 -0500 Subject: [PATCH] Autostart --- es-app/src/main.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/es-app/src/main.cpp b/es-app/src/main.cpp index 88aec5c..7310905 100644 --- a/es-app/src/main.cpp +++ b/es-app/src/main.cpp @@ -221,6 +221,9 @@ int main(int argc, char* argv[]) int lastTime = SDL_GetTicks(); bool running = true; + bool canAutoStart = true; + int autoStartTimer = 0; + while(running) { SDL_Event event; @@ -238,7 +241,9 @@ int main(int argc, char* argv[]) case SDL_TEXTEDITING: case SDL_JOYDEVICEADDED: case SDL_JOYDEVICEREMOVED: - InputManager::getInstance()->parseEvent(event, &window); + if(InputManager::getInstance()->parseEvent(event, &window)) + canAutoStart = false; + break; case SDL_QUIT: running = false; @@ -257,6 +262,27 @@ int main(int argc, char* argv[]) int deltaTime = curTime - lastTime; lastTime = curTime; + if(canAutoStart) + { + autoStartTimer += deltaTime; + if(autoStartTimer > 5000) // time to autostart after, in ms + { + canAutoStart = false; + + // launch the first game for the first system + SystemData* sys = SystemData::sSystemVector.front(); + sys->launchGame(&window, sys->getRootFolder()->getFilesRecursive(true).front()); + + // alternatively, to use a particular shell command, instead of the two SystemData lines above you can do: + // window.deinit(); // shut down the renderer/SDL + // system("shell command here"); // (e.g. system("startx");) + // window.init(); // restart the renderer/SDL + + // go back to the start of the run loop + continue; + } + } + // cap deltaTime at 1000 if(deltaTime > 1000 || deltaTime < 0) deltaTime = 1000; -- 1.8.4.msysgit.0