Qt/MappingNumeric: Calculate values properly

This commit is contained in:
spycrab 2018-04-28 12:32:23 +02:00
parent cf1adfbe20
commit 1fb188a7d9
2 changed files with 3 additions and 4 deletions

View File

@ -8,7 +8,7 @@
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h" #include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
MappingNumeric::MappingNumeric(MappingWidget* widget, ControllerEmu::NumericSetting* setting) MappingNumeric::MappingNumeric(MappingWidget* widget, ControllerEmu::NumericSetting* setting)
: m_parent(widget), m_setting(setting), m_range(setting->m_high - setting->m_low) : m_parent(widget), m_setting(setting)
{ {
setRange(setting->m_low, setting->m_high); setRange(setting->m_low, setting->m_high);
Update(); Update();
@ -19,7 +19,7 @@ void MappingNumeric::Connect()
{ {
connect(this, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, connect(this, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
[this](int value) { [this](int value) {
m_setting->SetValue(static_cast<double>(value - m_setting->m_low) / m_range); m_setting->SetValue(static_cast<double>(value) / 100);
m_parent->SaveSettings(); m_parent->SaveSettings();
}); });
} }
@ -33,5 +33,5 @@ void MappingNumeric::Clear()
void MappingNumeric::Update() void MappingNumeric::Update()
{ {
setValue(m_setting->m_low + m_setting->GetValue() * m_range); setValue(m_setting->GetValue() * 100);
} }

View File

@ -27,5 +27,4 @@ private:
MappingWidget* m_parent; MappingWidget* m_parent;
ControllerEmu::NumericSetting* m_setting; ControllerEmu::NumericSetting* m_setting;
double m_range;
}; };