Some fixes to last commit

- if autodetection fails, we still want to see what was set in properties
- if type is not set to 'AUTO', we don't want to autodetect at all
This commit is contained in:
Stephen Anthony 2019-02-25 09:31:14 -03:30
parent f15d1ec7a5
commit ae589e1655
1 changed files with 13 additions and 9 deletions

View File

@ -127,31 +127,35 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node)
bool swappedPorts = myProperties.get(Console_SwapPorts) == "YES";
// Load the image for controller auto detection
string left = myProperties.get(Controller_Left);
string right = myProperties.get(Controller_Right);
try
{
BytePtr image;
string md5 = myProperties.get(Cartridge_MD5);
uInt32 size = 0;
string left = myProperties.get(Controller_Left);
string right = myProperties.get(Controller_Right);
if(node.exists() && !node.isDirectory() &&
(image = instance().openROM(node, md5, size)) != nullptr)
{
left = ControllerDetector::detectName(image.get(), size, left,
!swappedPorts ? Controller::Jack::Left : Controller::Jack::Right,
instance().settings());
right = ControllerDetector::detectName(image.get(), size, right,
!swappedPorts ? Controller::Jack::Right : Controller::Jack::Left,
instance().settings());
if(BSPF::equalsIgnoreCase(left, "AUTO"))
left = ControllerDetector::detectName(image.get(), size, left,
!swappedPorts ? Controller::Jack::Left : Controller::Jack::Right,
instance().settings());
if(BSPF::equalsIgnoreCase(right, "AUTO"))
right = ControllerDetector::detectName(image.get(), size, right,
!swappedPorts ? Controller::Jack::Right : Controller::Jack::Left,
instance().settings());
}
myRomInfo.push_back("Controllers: " + (left + " (left), " + right + " (right)"));
}
catch(const runtime_error&)
{
// Do nothing; we simply don't update the controllers if openROM
// failed for any reason
left = right = "";
}
if(left != "" && right != "")
myRomInfo.push_back("Controllers: " + (left + " (left), " + right + " (right)"));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -