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);
}