InputCommon: Allow Wii remote extension to be set with an input expression.

This commit is contained in:
Jordan Woyak
2020-01-18 11:19:32 -06:00
parent e8152b700f
commit 0a1634bedf
12 changed files with 172 additions and 64 deletions

View File

@ -4,6 +4,8 @@
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
#include <sstream>
namespace ControllerEmu
{
NumericSettingBase::NumericSettingBase(const NumericSettingDetails& details) : m_details(details)
@ -25,6 +27,36 @@ const char* NumericSettingBase::GetUIDescription() const
return m_details.ui_description;
}
template <>
void NumericSetting<int>::SetExpressionFromValue()
{
m_value.m_input.SetExpression(ValueToString(GetValue()));
}
template <>
void NumericSetting<double>::SetExpressionFromValue()
{
// We must use a dot decimal separator for expression parser.
std::ostringstream ss;
ss.imbue(std::locale::classic());
ss << GetValue();
m_value.m_input.SetExpression(ss.str());
}
template <>
void NumericSetting<bool>::SetExpressionFromValue()
{
// Cast bool to prevent "true"/"false" strings.
m_value.m_input.SetExpression(ValueToString(int(GetValue())));
}
template <>
SettingType NumericSetting<int>::GetType() const
{
return SettingType::Int;
}
template <>
SettingType NumericSetting<double>::GetType() const
{