Load the Controllers on startup
This commit is contained in:
parent
027b29af93
commit
93d59e8175
1 changed files with 25 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
#include "ControllerManager.h"
|
||||
#include "Controller.h"
|
||||
#include "TellStick.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
|
@ -14,6 +15,7 @@ public:
|
|||
ControllerManager::ControllerManager(){
|
||||
d = new PrivateData;
|
||||
d->lastControllerId = 0;
|
||||
this->loadControllers();
|
||||
}
|
||||
|
||||
ControllerManager::~ControllerManager(void) {
|
||||
|
@ -24,5 +26,27 @@ ControllerManager::~ControllerManager(void) {
|
|||
}
|
||||
|
||||
void ControllerManager::loadControllers() {
|
||||
//TODO: Do something
|
||||
while(1) {
|
||||
TellStick *controller = TellStick::findFirstDevice();
|
||||
if (!controller) {
|
||||
break; //All TellStick loaded
|
||||
}
|
||||
//Make sure this isn't already loaded
|
||||
bool found = false;
|
||||
for(ControllerMap::iterator it = d->controllers.begin(); it != d->controllers.end(); ++it) {
|
||||
TellStick *tellstick = reinterpret_cast<TellStick *>(it->second);
|
||||
if (!tellstick) { //No TellStick controller
|
||||
continue;
|
||||
}
|
||||
if (tellstick->serial().compare(controller->serial()) == 0) { //Found a duplicate
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
break;
|
||||
}
|
||||
d->lastControllerId--;
|
||||
d->controllers[d->lastControllerId] = controller;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue