mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-03 19:42:45 +01:00
Merge pull request #5460 from spycrab/qt_fix_rounding_errors
Qt: Fix rounding errors
This commit is contained in:
commit
1072da11fe
@ -10,8 +10,8 @@
|
|||||||
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), m_range(setting->m_high - setting->m_low)
|
||||||
{
|
{
|
||||||
setValue(setting->GetValue() * m_range);
|
|
||||||
setRange(setting->m_low, setting->m_high);
|
setRange(setting->m_low, setting->m_high);
|
||||||
|
setValue(setting->m_low + setting->GetValue() * m_range);
|
||||||
Connect();
|
Connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,19 +19,19 @@ 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_range);
|
m_setting->SetValue(static_cast<double>(value - m_setting->m_low) / m_range);
|
||||||
Update();
|
Update();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingNumeric::Clear()
|
void MappingNumeric::Clear()
|
||||||
{
|
{
|
||||||
setValue((m_setting->m_low + m_setting->m_high) / 2);
|
setValue(m_setting->m_low + (m_setting->m_low + m_setting->m_high) / 2);
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MappingNumeric::Update()
|
void MappingNumeric::Update()
|
||||||
{
|
{
|
||||||
setValue(m_setting->GetValue() * m_range);
|
setValue(m_setting->m_low + m_setting->GetValue() * m_range);
|
||||||
m_parent->SaveSettings();
|
m_parent->SaveSettings();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user