mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-21 07:15:40 -04:00
InputManager: Support inverted full axis
i.e. pedals
This commit is contained in:
@ -72,6 +72,32 @@ UnorderedStringMapFind(UnorderedStringMap<ValueType>& map, const KeyType& key)
|
||||
{
|
||||
return map.find(key);
|
||||
}
|
||||
template<typename KeyType, typename ValueType>
|
||||
ALWAYS_INLINE typename UnorderedStringMultimap<ValueType>::const_iterator
|
||||
UnorderedStringMultiMapFind(const UnorderedStringMultimap<ValueType>& map, const KeyType& key)
|
||||
{
|
||||
return map.find(key);
|
||||
}
|
||||
template<typename KeyType, typename ValueType>
|
||||
ALWAYS_INLINE std::pair<typename UnorderedStringMultimap<ValueType>::const_iterator,
|
||||
typename UnorderedStringMultimap<ValueType>::const_iterator>
|
||||
UnorderedStringMultiMapEqualRange(const UnorderedStringMultimap<ValueType>& map, const KeyType& key)
|
||||
{
|
||||
return map.equal_range(key);
|
||||
}
|
||||
template<typename KeyType, typename ValueType>
|
||||
ALWAYS_INLINE typename UnorderedStringMultimap<ValueType>::iterator
|
||||
UnorderedStringMultiMapFind(UnorderedStringMultimap<ValueType>& map, const KeyType& key)
|
||||
{
|
||||
return map.find(key);
|
||||
}
|
||||
template<typename KeyType, typename ValueType>
|
||||
ALWAYS_INLINE std::pair<typename UnorderedStringMultimap<ValueType>::iterator,
|
||||
typename UnorderedStringMultimap<ValueType>::iterator>
|
||||
UnorderedStringMultiMapEqualRange(UnorderedStringMultimap<ValueType>& map, const KeyType& key)
|
||||
{
|
||||
return map.equal_range(key);
|
||||
}
|
||||
#else
|
||||
template<typename ValueType>
|
||||
using UnorderedStringMap = std::unordered_map<std::string, ValueType>;
|
||||
@ -81,15 +107,43 @@ using UnorderedStringSet = std::unordered_set<std::string>;
|
||||
using UnorderedStringMultiSet = std::unordered_multiset<std::string>;
|
||||
|
||||
template<typename KeyType, typename ValueType>
|
||||
ALWAYS_INLINE typename UnorderedStringMap<ValueType>::const_iterator UnorderedStringMapFind(const UnorderedStringMap<ValueType>& map, const KeyType& key)
|
||||
ALWAYS_INLINE typename UnorderedStringMap<ValueType>::const_iterator
|
||||
UnorderedStringMapFind(const UnorderedStringMap<ValueType>& map, const KeyType& key)
|
||||
{
|
||||
return map.find(std::string(key));
|
||||
}
|
||||
template<typename KeyType, typename ValueType>
|
||||
ALWAYS_INLINE typename UnorderedStringMap<ValueType>::iterator UnorderedStringMapFind(UnorderedStringMap<ValueType>& map, const KeyType& key)
|
||||
ALWAYS_INLINE typename UnorderedStringMap<ValueType>::iterator
|
||||
UnorderedStringMapFind(UnorderedStringMap<ValueType>& map, const KeyType& key)
|
||||
{
|
||||
return map.find(std::string(key));
|
||||
}
|
||||
template<typename KeyType, typename ValueType>
|
||||
ALWAYS_INLINE typename UnorderedStringMultimap<ValueType>::const_iterator
|
||||
UnorderedStringMultiMapFind(const UnorderedStringMultimap<ValueType>& map, const KeyType& key)
|
||||
{
|
||||
return map.find(std::string(key));
|
||||
}
|
||||
template<typename KeyType, typename ValueType>
|
||||
ALWAYS_INLINE std::pair<typename UnorderedStringMultimap<ValueType>::const_iterator,
|
||||
typename UnorderedStringMultimap<ValueType>::const_iterator>
|
||||
UnorderedStringMultiMapEqualRange(const UnorderedStringMultimap<ValueType>& map, const KeyType& key)
|
||||
{
|
||||
return map.equal_range(std::string(key));
|
||||
}
|
||||
template<typename KeyType, typename ValueType>
|
||||
ALWAYS_INLINE typename UnorderedStringMultimap<ValueType>::iterator
|
||||
UnorderedStringMultiMapFind(UnorderedStringMultimap<ValueType>& map, const KeyType& key)
|
||||
{
|
||||
return map.find(std::string(key));
|
||||
}
|
||||
template<typename KeyType, typename ValueType>
|
||||
ALWAYS_INLINE std::pair<typename UnorderedStringMultimap<ValueType>::iterator,
|
||||
typename UnorderedStringMultimap<ValueType>::iterator>
|
||||
UnorderedStringMultiMapEqualRange(UnorderedStringMultimap<ValueType>& map, const KeyType& key)
|
||||
{
|
||||
return map.equal_range(std::string(key));
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename ValueType>
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -49,6 +49,9 @@ public:
|
||||
bool RemoveFromStringList(const char* section, const char* key, const char* item) override;
|
||||
bool AddToStringList(const char* section, const char* key, const char* item) override;
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> GetKeyValueList(const char* section) const override;
|
||||
void SetKeyValueList(const char* section, const std::vector<std::pair<std::string, std::string>>& items) override;
|
||||
|
||||
// default parameter overloads
|
||||
using SettingsInterface::GetBoolValue;
|
||||
using SettingsInterface::GetDoubleValue;
|
||||
@ -62,4 +65,4 @@ private:
|
||||
static constexpr Layer LAST_LAYER = LAYER_BASE;
|
||||
|
||||
std::array<SettingsInterface*, NUM_LAYERS> m_layers{};
|
||||
};
|
||||
};
|
@ -21,7 +21,7 @@ void MemorySettingsInterface::Clear()
|
||||
|
||||
bool MemorySettingsInterface::GetIntValue(const char* section, const char* key, s32* value) const
|
||||
{
|
||||
const auto sit = m_sections.find(section);
|
||||
const auto sit = UnorderedStringMapFind(m_sections, section);
|
||||
if (sit == m_sections.end())
|
||||
return false;
|
||||
|
||||
@ -39,11 +39,11 @@ bool MemorySettingsInterface::GetIntValue(const char* section, const char* key,
|
||||
|
||||
bool MemorySettingsInterface::GetUIntValue(const char* section, const char* key, u32* value) const
|
||||
{
|
||||
const auto sit = m_sections.find(section);
|
||||
const auto sit = UnorderedStringMapFind(m_sections, section);
|
||||
if (sit == m_sections.end())
|
||||
return false;
|
||||
|
||||
const auto iter = sit->second.find(key);
|
||||
const auto iter = UnorderedStringMultiMapFind(sit->second, key);
|
||||
if (iter == sit->second.end())
|
||||
return false;
|
||||
|
||||
@ -57,11 +57,11 @@ bool MemorySettingsInterface::GetUIntValue(const char* section, const char* key,
|
||||
|
||||
bool MemorySettingsInterface::GetFloatValue(const char* section, const char* key, float* value) const
|
||||
{
|
||||
const auto sit = m_sections.find(section);
|
||||
const auto sit = UnorderedStringMapFind(m_sections, section);
|
||||
if (sit == m_sections.end())
|
||||
return false;
|
||||
|
||||
const auto iter = sit->second.find(key);
|
||||
const auto iter = UnorderedStringMultiMapFind(sit->second, key);
|
||||
if (iter == sit->second.end())
|
||||
return false;
|
||||
|
||||
@ -75,11 +75,11 @@ bool MemorySettingsInterface::GetFloatValue(const char* section, const char* key
|
||||
|
||||
bool MemorySettingsInterface::GetDoubleValue(const char* section, const char* key, double* value) const
|
||||
{
|
||||
const auto sit = m_sections.find(section);
|
||||
const auto sit = UnorderedStringMapFind(m_sections, section);
|
||||
if (sit == m_sections.end())
|
||||
return false;
|
||||
|
||||
const auto iter = sit->second.find(key);
|
||||
const auto iter = UnorderedStringMultiMapFind(sit->second, key);
|
||||
if (iter == sit->second.end())
|
||||
return false;
|
||||
|
||||
@ -93,11 +93,11 @@ bool MemorySettingsInterface::GetDoubleValue(const char* section, const char* ke
|
||||
|
||||
bool MemorySettingsInterface::GetBoolValue(const char* section, const char* key, bool* value) const
|
||||
{
|
||||
const auto sit = m_sections.find(section);
|
||||
const auto sit = UnorderedStringMapFind(m_sections, section);
|
||||
if (sit == m_sections.end())
|
||||
return false;
|
||||
|
||||
const auto iter = sit->second.find(key);
|
||||
const auto iter = UnorderedStringMultiMapFind(sit->second, key);
|
||||
if (iter == sit->second.end())
|
||||
return false;
|
||||
|
||||
@ -111,11 +111,11 @@ bool MemorySettingsInterface::GetBoolValue(const char* section, const char* key,
|
||||
|
||||
bool MemorySettingsInterface::GetStringValue(const char* section, const char* key, std::string* value) const
|
||||
{
|
||||
const auto sit = m_sections.find(section);
|
||||
const auto sit = UnorderedStringMapFind(m_sections, section);
|
||||
if (sit == m_sections.end())
|
||||
return false;
|
||||
|
||||
const auto iter = sit->second.find(key);
|
||||
const auto iter = UnorderedStringMultiMapFind(sit->second, key);
|
||||
if (iter == sit->second.end())
|
||||
return false;
|
||||
|
||||
@ -153,13 +153,34 @@ void MemorySettingsInterface::SetStringValue(const char* section, const char* ke
|
||||
SetValue(section, key, value);
|
||||
}
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> MemorySettingsInterface::GetKeyValueList(const char* section) const
|
||||
{
|
||||
std::vector<std::pair<std::string, std::string>> output;
|
||||
auto sit = UnorderedStringMapFind(m_sections, section);
|
||||
if (sit != m_sections.end())
|
||||
{
|
||||
for (const auto& it : sit->second)
|
||||
output.emplace_back(it.first, it.second);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
void MemorySettingsInterface::SetKeyValueList(const char* section,
|
||||
const std::vector<std::pair<std::string, std::string>>& items)
|
||||
{
|
||||
auto sit = UnorderedStringMapFind(m_sections, section);
|
||||
sit->second.clear();
|
||||
for (const auto& [key, value] : items)
|
||||
sit->second.emplace(key, value);
|
||||
}
|
||||
|
||||
void MemorySettingsInterface::SetValue(const char* section, const char* key, std::string value)
|
||||
{
|
||||
auto sit = m_sections.find(section);
|
||||
auto sit = UnorderedStringMapFind(m_sections, section);
|
||||
if (sit == m_sections.end())
|
||||
sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first;
|
||||
|
||||
const auto range = sit->second.equal_range(key);
|
||||
const auto range = UnorderedStringMultiMapEqualRange(sit->second, key);
|
||||
if (range.first == sit->second.end())
|
||||
{
|
||||
sit->second.emplace(std::string(key), std::move(value));
|
||||
@ -182,10 +203,10 @@ std::vector<std::string> MemorySettingsInterface::GetStringList(const char* sect
|
||||
{
|
||||
std::vector<std::string> ret;
|
||||
|
||||
const auto sit = m_sections.find(section);
|
||||
const auto sit = UnorderedStringMapFind(m_sections, section);
|
||||
if (sit != m_sections.end())
|
||||
{
|
||||
const auto range = sit->second.equal_range(key);
|
||||
const auto range = UnorderedStringMultiMapEqualRange(sit->second, key);
|
||||
for (auto iter = range.first; iter != range.second; ++iter)
|
||||
ret.emplace_back(iter->second);
|
||||
}
|
||||
@ -195,11 +216,11 @@ std::vector<std::string> MemorySettingsInterface::GetStringList(const char* sect
|
||||
|
||||
void MemorySettingsInterface::SetStringList(const char* section, const char* key, const std::vector<std::string>& items)
|
||||
{
|
||||
auto sit = m_sections.find(section);
|
||||
auto sit = UnorderedStringMapFind(m_sections, section);
|
||||
if (sit == m_sections.end())
|
||||
sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first;
|
||||
|
||||
const auto range = sit->second.equal_range(key);
|
||||
const auto range = UnorderedStringMultiMapEqualRange(sit->second, key);
|
||||
for (auto iter = range.first; iter != range.second;)
|
||||
sit->second.erase(iter++);
|
||||
|
||||
@ -210,11 +231,11 @@ void MemorySettingsInterface::SetStringList(const char* section, const char* key
|
||||
|
||||
bool MemorySettingsInterface::RemoveFromStringList(const char* section, const char* key, const char* item)
|
||||
{
|
||||
auto sit = m_sections.find(section);
|
||||
auto sit = UnorderedStringMapFind(m_sections, section);
|
||||
if (sit == m_sections.end())
|
||||
sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first;
|
||||
|
||||
const auto range = sit->second.equal_range(key);
|
||||
const auto range = UnorderedStringMultiMapEqualRange(sit->second, key);
|
||||
bool result = false;
|
||||
for (auto iter = range.first; iter != range.second;)
|
||||
{
|
||||
@ -234,11 +255,11 @@ bool MemorySettingsInterface::RemoveFromStringList(const char* section, const ch
|
||||
|
||||
bool MemorySettingsInterface::AddToStringList(const char* section, const char* key, const char* item)
|
||||
{
|
||||
auto sit = m_sections.find(section);
|
||||
auto sit = UnorderedStringMapFind(m_sections, section);
|
||||
if (sit == m_sections.end())
|
||||
sit = m_sections.emplace(std::make_pair(std::string(section), KeyMap())).first;
|
||||
|
||||
const auto range = sit->second.equal_range(key);
|
||||
const auto range = UnorderedStringMultiMapEqualRange(sit->second, key);
|
||||
for (auto iter = range.first; iter != range.second; ++iter)
|
||||
{
|
||||
if (iter->second == item)
|
||||
@ -251,7 +272,7 @@ bool MemorySettingsInterface::AddToStringList(const char* section, const char* k
|
||||
|
||||
bool MemorySettingsInterface::ContainsValue(const char* section, const char* key) const
|
||||
{
|
||||
const auto sit = m_sections.find(section);
|
||||
const auto sit = UnorderedStringMapFind(m_sections, section);
|
||||
if (sit == m_sections.end())
|
||||
return false;
|
||||
|
||||
@ -260,18 +281,18 @@ bool MemorySettingsInterface::ContainsValue(const char* section, const char* key
|
||||
|
||||
void MemorySettingsInterface::DeleteValue(const char* section, const char* key)
|
||||
{
|
||||
auto sit = m_sections.find(section);
|
||||
auto sit = UnorderedStringMapFind(m_sections, section);
|
||||
if (sit == m_sections.end())
|
||||
return;
|
||||
|
||||
const auto range = sit->second.equal_range(key);
|
||||
const auto range = UnorderedStringMultiMapEqualRange(sit->second, key);
|
||||
for (auto iter = range.first; iter != range.second;)
|
||||
sit->second.erase(iter++);
|
||||
}
|
||||
|
||||
void MemorySettingsInterface::ClearSection(const char* section)
|
||||
{
|
||||
auto sit = m_sections.find(section);
|
||||
auto sit = UnorderedStringMapFind(m_sections, section);
|
||||
if (sit == m_sections.end())
|
||||
return;
|
||||
|
||||
|
@ -29,6 +29,10 @@ public:
|
||||
void SetDoubleValue(const char* section, const char* key, double value) override;
|
||||
void SetBoolValue(const char* section, const char* key, bool value) override;
|
||||
void SetStringValue(const char* section, const char* key, const char* value) override;
|
||||
|
||||
std::vector<std::pair<std::string, std::string>> GetKeyValueList(const char* section) const override;
|
||||
void SetKeyValueList(const char* section, const std::vector<std::pair<std::string, std::string>>& items) override;
|
||||
|
||||
bool ContainsValue(const char* section, const char* key) const override;
|
||||
void DeleteValue(const char* section, const char* key) override;
|
||||
void ClearSection(const char* section) override;
|
||||
|
@ -35,6 +35,9 @@ public:
|
||||
virtual bool RemoveFromStringList(const char* section, const char* key, const char* item) = 0;
|
||||
virtual bool AddToStringList(const char* section, const char* key, const char* item) = 0;
|
||||
|
||||
virtual std::vector<std::pair<std::string, std::string>> GetKeyValueList(const char* section) const = 0;
|
||||
virtual void SetKeyValueList(const char* section, const std::vector<std::pair<std::string, std::string>>& items) = 0;
|
||||
|
||||
virtual bool ContainsValue(const char* section, const char* key) const = 0;
|
||||
virtual void DeleteValue(const char* section, const char* key) = 0;
|
||||
virtual void ClearSection(const char* section) = 0;
|
||||
|
Reference in New Issue
Block a user