diff --git a/es-core/src/guis/GuiDetectDevice.cpp b/es-core/src/guis/GuiDetectDevice.cpp index 95deea1ea..d185183d8 100644 --- a/es-core/src/guis/GuiDetectDevice.cpp +++ b/es-core/src/guis/GuiDetectDevice.cpp @@ -8,11 +8,15 @@ #include #include #include "Util.h" +#include +#include #define HOLD_TIME 1000 using namespace Eigen; +namespace fs = boost::filesystem; + GuiDetectDevice::GuiDetectDevice(Window* window, bool firstRun, const std::function& doneCallback) : GuiComponent(window), mFirstRun(firstRun), mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 5)) { @@ -100,15 +104,26 @@ void GuiDetectDevice::update(int deltaTime) { if(mHoldingConfig) { - mHoldTime -= deltaTime; - const float t = (float)mHoldTime / HOLD_TIME; - unsigned int c = (unsigned char)(t * 255); - mDeviceHeld->setColor((c << 24) | (c << 16) | (c << 8) | 0xFF); - if(mHoldTime <= 0) + // If ES starts and if a known device is connected after startup skip controller configuration + if(mFirstRun && fs::exists(InputManager::getConfigPath()) && InputManager::getInstance()->getNumConfiguredDevices() > 0) { - // picked one! - mWindow->pushGui(new GuiInputConfig(mWindow, mHoldingConfig, true, mDoneCallback)); - delete this; + InputManager::getInstance()->doOnFinish(); // execute possible onFinish commands + if(mDoneCallback) + mDoneCallback(); + delete this; // delete GUI element + } + else + { + mHoldTime -= deltaTime; + const float t = (float)mHoldTime / HOLD_TIME; + unsigned int c = (unsigned char)(t * 255); + mDeviceHeld->setColor((c << 24) | (c << 16) | (c << 8) | 0xFF); + if(mHoldTime <= 0) + { + // picked one! + mWindow->pushGui(new GuiInputConfig(mWindow, mHoldingConfig, true, mDoneCallback)); + delete this; + } } } }