Minor optimization in creating controller device in Console.

This commit is contained in:
Stephen Anthony 2017-06-18 21:52:59 -02:30
parent 21195c20cb
commit 0bc8a928f0
1 changed files with 16 additions and 10 deletions

View File

@ -713,7 +713,14 @@ void Console::setControllers(const string& rommd5)
bool swapPaddles = myProperties.get(Controller_SwapPaddles) == "YES";
// Construct left controller
if(left == "BOOSTERGRIP")
if(left == "JOYSTICK")
{
// Already created in c'tor
// We save some time by not looking at all the other types
leftC = myLeftControl ? std::move(myLeftControl) :
make_ptr<Joystick>(Controller::Left, myEvent, *mySystem);
}
else if(left == "BOOSTERGRIP")
{
leftC = make_ptr<BoosterGrip>(Controller::Left, myEvent, *mySystem);
}
@ -757,13 +764,16 @@ void Console::setControllers(const string& rommd5)
{
leftC = make_ptr<MindLink>(Controller::Left, myEvent, *mySystem);
}
else
{
leftC = make_ptr<Joystick>(Controller::Left, myEvent, *mySystem);
}
// Construct right controller
if(right == "BOOSTERGRIP")
if(right == "JOYSTICK")
{
// Already created in c'tor
// We save some time by not looking at all the other types
rightC = myRightControl ? std::move(myRightControl) :
make_ptr<Joystick>(Controller::Right, myEvent, *mySystem);
}
else if(right == "BOOSTERGRIP")
{
rightC = make_ptr<BoosterGrip>(Controller::Right, myEvent, *mySystem);
}
@ -824,10 +834,6 @@ void Console::setControllers(const string& rommd5)
{
rightC = make_ptr<MindLink>(Controller::Right, myEvent, *mySystem);
}
else
{
rightC = make_ptr<Joystick>(Controller::Right, myEvent, *mySystem);
}
// Swap the ports if necessary
if(myProperties.get(Console_SwapPorts) == "NO")