Fixed switch, pot & sliders config

This commit is contained in:
Raphael Coeffic
2021-12-31 10:53:11 +01:00
parent 2659abf216
commit 2ccbb7f343
2 changed files with 15 additions and 5 deletions
@@ -96,6 +96,10 @@ int YamlPotLookup::name2idx(const std::string& name)
int idx = fw->getAnalogInputIndex(name.c_str());
if (idx < 0) return idx;
int sticks = Boards::getCapability(fw->getBoard(), Board::Sticks);
if (idx < sticks) return -1;
idx -= sticks;
int pots = Boards::getCapability(fw->getBoard(), Board::Pots);
if (idx >= pots) return -1;
@@ -108,7 +112,8 @@ std::string YamlPotLookup::idx2name(unsigned int idx)
unsigned int pots = Boards::getCapability(fw->getBoard(), Board::Pots);
if (idx >= pots) return std::string();
return fw->getAnalogInputTag(idx);
unsigned int sticks = Boards::getCapability(fw->getBoard(), Board::Sticks);
return fw->getAnalogInputTag(idx + sticks);
}
int YamlSliderLookup::name2idx(const std::string& name)
@@ -117,6 +122,10 @@ int YamlSliderLookup::name2idx(const std::string& name)
int idx = fw->getAnalogInputIndex(name.c_str());
if (idx < 0) return idx;
int sticks = Boards::getCapability(fw->getBoard(), Board::Sticks);
if (idx < sticks) return -1;
idx -= sticks;
int pots = Boards::getCapability(fw->getBoard(), Board::Pots);
if (idx < pots) return -1;
idx -= pots;
@@ -130,9 +139,10 @@ int YamlSliderLookup::name2idx(const std::string& name)
std::string YamlSliderLookup::idx2name(unsigned int idx)
{
auto fw = getCurrentFirmware();
int pots = Boards::getCapability(fw->getBoard(), Board::Pots);
unsigned int sliders = Boards::getCapability(fw->getBoard(), Board::Sliders);
if (idx >= sliders) return std::string();
return fw->getAnalogInputTag(idx + pots);
unsigned int sticks = Boards::getCapability(fw->getBoard(), Board::Sticks);
unsigned int pots = Boards::getCapability(fw->getBoard(), Board::Pots);
return fw->getAnalogInputTag(idx + pots + sticks);
}
@@ -110,7 +110,7 @@ struct convert<YamlNameConfig<N, name_lookup> > {
Node node;
for (unsigned int i=0; i<N; i++) {
std::string name = name_lookup::idx2name(i);
if (!name.empty()) {
if (!name.empty() && rhs.name[i][0]) {
node[name]["name"] = rhs.name[i];
}
}
@@ -137,7 +137,7 @@ struct convert<YamlKnobConfig<N, name_lookup, cfg_lut> > {
Node node;
for (unsigned int i=0; i<N; i++) {
std::string name = name_lookup::idx2name(i);
if (!name.empty()) {
if (!name.empty() && (rhs.config[i] || rhs.name[i][0])) {
node[name]["type"] = cfg_lut << rhs.config[i];
node[name]["name"] = rhs.name[i];
}