Skip controller config if known device is added after startup

Fix for problems like this:
http://blog.petrockblock.com/forums/topic/retropie-wont-recognize-ps3-controller-unless-ps-button-is-hit-before-es-start/
http://blog.petrockblock.com/forums/topic/elegent-method-of-detecting-wireless-controller-before-starting-es/

No controller found message pops up if no controller is connected. If a known controller is connected and any button is pressed system selection menu will show up instantly.
This commit is contained in:
gizmo98 2015-09-28 19:25:15 +02:00
parent 64a208ff59
commit cdda6f6dc1

View file

@ -8,11 +8,15 @@
#include <string> #include <string>
#include <sstream> #include <sstream>
#include "Util.h" #include "Util.h"
#include <boost/filesystem.hpp>
#include <boost/locale.hpp>
#define HOLD_TIME 1000 #define HOLD_TIME 1000
using namespace Eigen; using namespace Eigen;
namespace fs = boost::filesystem;
GuiDetectDevice::GuiDetectDevice(Window* window, bool firstRun, const std::function<void()>& doneCallback) : GuiComponent(window), mFirstRun(firstRun), GuiDetectDevice::GuiDetectDevice(Window* window, bool firstRun, const std::function<void()>& doneCallback) : GuiComponent(window), mFirstRun(firstRun),
mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 5)) mBackground(window, ":/frame.png"), mGrid(window, Vector2i(1, 5))
{ {
@ -99,6 +103,16 @@ bool GuiDetectDevice::input(InputConfig* config, Input input)
void GuiDetectDevice::update(int deltaTime) void GuiDetectDevice::update(int deltaTime)
{ {
if(mHoldingConfig) if(mHoldingConfig)
{
// 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)
{
InputManager::getInstance()->doOnFinish(); // execute possible onFinish commands
if(mDoneCallback)
mDoneCallback();
delete this; // delete GUI element
}
else
{ {
mHoldTime -= deltaTime; mHoldTime -= deltaTime;
const float t = (float)mHoldTime / HOLD_TIME; const float t = (float)mHoldTime / HOLD_TIME;
@ -111,4 +125,5 @@ void GuiDetectDevice::update(int deltaTime)
delete this; delete this;
} }
} }
}
} }