InputManager: Support inverted full axis

i.e. pedals
This commit is contained in:
Connor McLaughlin
2023-01-15 14:00:51 +10:00
parent 01270bac35
commit 395e9a934b
39 changed files with 1022 additions and 366 deletions

View File

@ -3,6 +3,7 @@
#include "layered_settings_interface.h"
#include "common/assert.h"
#include <unordered_set>
LayeredSettingsInterface::LayeredSettingsInterface() = default;
@ -190,3 +191,35 @@ bool LayeredSettingsInterface::AddToStringList(const char* section, const char*
Panic("Attempt to call AddToStringList() on layered settings interface");
return true;
}
std::vector<std::pair<std::string, std::string>> LayeredSettingsInterface::GetKeyValueList(const char* section) const
{
std::unordered_set<std::string_view> seen;
std::vector<std::pair<std::string, std::string>> ret;
for (u32 layer = FIRST_LAYER; layer <= LAST_LAYER; layer++)
{
if (SettingsInterface* sif = m_layers[layer])
{
const size_t newly_added_begin = ret.size();
std::vector<std::pair<std::string, std::string>> entries = sif->GetKeyValueList(section);
for (std::pair<std::string, std::string>& entry : entries)
{
if (seen.find(entry.first) != seen.end())
continue;
ret.push_back(std::move(entry));
}
// Mark keys as seen after processing all entries in case the layer has multiple entries for a specific key
for (auto cur = ret.begin() + newly_added_begin, end = ret.end(); cur < end; cur++)
seen.insert(cur->first);
}
}
return ret;
}
void LayeredSettingsInterface::SetKeyValueList(const char* section,
const std::vector<std::pair<std::string, std::string>>& items)
{
Panic("Attempt to call SetKeyValueList() on layered settings interface");
}