Fixed switch, pot & sliders config
This commit is contained in:
@@ -96,6 +96,10 @@ int YamlPotLookup::name2idx(const std::string& name)
|
|||||||
int idx = fw->getAnalogInputIndex(name.c_str());
|
int idx = fw->getAnalogInputIndex(name.c_str());
|
||||||
if (idx < 0) return idx;
|
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);
|
int pots = Boards::getCapability(fw->getBoard(), Board::Pots);
|
||||||
if (idx >= pots) return -1;
|
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);
|
unsigned int pots = Boards::getCapability(fw->getBoard(), Board::Pots);
|
||||||
if (idx >= pots) return std::string();
|
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)
|
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());
|
int idx = fw->getAnalogInputIndex(name.c_str());
|
||||||
if (idx < 0) return idx;
|
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);
|
int pots = Boards::getCapability(fw->getBoard(), Board::Pots);
|
||||||
if (idx < pots) return -1;
|
if (idx < pots) return -1;
|
||||||
idx -= pots;
|
idx -= pots;
|
||||||
@@ -130,9 +139,10 @@ int YamlSliderLookup::name2idx(const std::string& name)
|
|||||||
std::string YamlSliderLookup::idx2name(unsigned int idx)
|
std::string YamlSliderLookup::idx2name(unsigned int idx)
|
||||||
{
|
{
|
||||||
auto fw = getCurrentFirmware();
|
auto fw = getCurrentFirmware();
|
||||||
int pots = Boards::getCapability(fw->getBoard(), Board::Pots);
|
|
||||||
unsigned int sliders = Boards::getCapability(fw->getBoard(), Board::Sliders);
|
unsigned int sliders = Boards::getCapability(fw->getBoard(), Board::Sliders);
|
||||||
if (idx >= sliders) return std::string();
|
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;
|
Node node;
|
||||||
for (unsigned int i=0; i<N; i++) {
|
for (unsigned int i=0; i<N; i++) {
|
||||||
std::string name = name_lookup::idx2name(i);
|
std::string name = name_lookup::idx2name(i);
|
||||||
if (!name.empty()) {
|
if (!name.empty() && rhs.name[i][0]) {
|
||||||
node[name]["name"] = rhs.name[i];
|
node[name]["name"] = rhs.name[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,7 +137,7 @@ struct convert<YamlKnobConfig<N, name_lookup, cfg_lut> > {
|
|||||||
Node node;
|
Node node;
|
||||||
for (unsigned int i=0; i<N; i++) {
|
for (unsigned int i=0; i<N; i++) {
|
||||||
std::string name = name_lookup::idx2name(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]["type"] = cfg_lut << rhs.config[i];
|
||||||
node[name]["name"] = rhs.name[i];
|
node[name]["name"] = rhs.name[i];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user