Read I2C bus location more reliably

This commit is contained in:
Geoffrey Mon 2023-05-30 21:52:35 -05:00
parent cf46be2b1e
commit 7b286352da
No known key found for this signature in database
GPG key ID: 9692E2BEF6BD5CF9

View file

@ -228,11 +228,19 @@ bool ProfileManager::LoadDeviceFromListWithOptions
if(load_controller->location.find("HID: ") == 0)
{
location_check = true;
}
}
else if(load_controller->location.find("I2C: ") == 0)
{
std::string i2c_address = load_controller->location.substr(load_controller->location.find_last_of(", ") + 2);
location_check = temp_controller->location.find(i2c_address) != std::string::npos;
std::size_t loc = load_controller->location.rfind(", ");
if(loc == std::string::npos)
{
location_check = false;
}
else
{
std::string i2c_address = load_controller->location.substr(loc + 2);
location_check = temp_controller->location.find(i2c_address) != std::string::npos;
}
}
else
{