multiple fixes for device configs

This commit is contained in:
vaxerski 2022-08-20 18:47:48 +02:00
parent 45a0e69286
commit 132c96f867

View file

@ -912,6 +912,7 @@ void CConfigManager::parseLine(std::string& line) {
if (line.contains(" {")) { if (line.contains(" {")) {
auto cat = line.substr(0, line.find(" {")); auto cat = line.substr(0, line.find(" {"));
transform(cat.begin(), cat.end(), cat.begin(), ::tolower); transform(cat.begin(), cat.end(), cat.begin(), ::tolower);
std::replace(cat.begin(), cat.end(), ' ', '-');
if (currentCategory.length() != 0) { if (currentCategory.length() != 0) {
currentCategory.push_back(':'); currentCategory.push_back(':');
currentCategory.append(cat); currentCategory.append(cat);
@ -1140,9 +1141,13 @@ SConfigValue CConfigManager::getConfigValueSafe(const std::string& val) {
SConfigValue CConfigManager::getConfigValueSafeDevice(const std::string& dev, const std::string& val) { SConfigValue CConfigManager::getConfigValueSafeDevice(const std::string& dev, const std::string& val) {
std::lock_guard<std::mutex> lg(configmtx); std::lock_guard<std::mutex> lg(configmtx);
const auto it = deviceConfigs.find(dev); auto devcopy = dev;
std::replace(devcopy.begin(), devcopy.end(), ' ', '-');
const auto it = deviceConfigs.find(devcopy);
if (it == deviceConfigs.end()) { if (it == deviceConfigs.end()) {
Debug::log(ERR, "getConfigValueSafeDevice: No device config for %s found???", devcopy.c_str());
return SConfigValue(); return SConfigValue();
} }
@ -1155,7 +1160,7 @@ SConfigValue CConfigManager::getConfigValueSafeDevice(const std::string& dev, co
if (foundIt == std::string::npos) if (foundIt == std::string::npos)
continue; continue;
if (foundIt == cv.first.length() - val.length()) { if (cv.first == "input:" + val || cv.first == "input:touchpad:" + cv.first) {
copy = cv.second; copy = cv.second;
} }
} }
@ -1334,7 +1339,10 @@ SConfigValue* CConfigManager::getConfigValuePtrSafe(std::string val) {
} }
bool CConfigManager::deviceConfigExists(const std::string& dev) { bool CConfigManager::deviceConfigExists(const std::string& dev) {
const auto it = deviceConfigs.find(dev); auto copy = dev;
std::replace(copy.begin(), copy.end(), ' ', '-');
const auto it = deviceConfigs.find(copy);
return it != deviceConfigs.end(); return it != deviceConfigs.end();
} }