dolphin/Source/Core/DolphinQt/Config/Mapping/MappingNumeric.cpp

33 lines
1.0 KiB
C++
Raw Normal View History

2017-05-20 15:53:17 +00:00
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
2018-07-06 22:40:15 +00:00
#include "DolphinQt/Config/Mapping/MappingNumeric.h"
2017-05-20 15:53:17 +00:00
2018-07-06 22:40:15 +00:00
#include "DolphinQt/Config/Mapping/MappingWidget.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h"
2017-05-20 15:53:17 +00:00
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
2017-05-20 15:53:17 +00:00
2019-03-15 01:27:49 +00:00
MappingNumeric::MappingNumeric(MappingWidget* parent, ControllerEmu::NumericSetting* setting)
: m_setting(*setting)
2017-05-20 15:53:17 +00:00
{
setRange(setting->m_low, setting->m_high);
connect(this, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
2019-03-15 01:27:49 +00:00
[this, parent](int value) {
m_setting.SetValue(static_cast<double>(value) / 100);
parent->SaveSettings();
2017-05-20 15:53:17 +00:00
});
2019-03-15 01:27:49 +00:00
connect(parent, &MappingWidget::ConfigChanged, this, &MappingNumeric::ConfigChanged);
2017-05-20 15:53:17 +00:00
}
2019-03-15 01:27:49 +00:00
void MappingNumeric::ConfigChanged()
2017-05-20 15:53:17 +00:00
{
2019-03-15 01:27:49 +00:00
const bool old_state = blockSignals(true);
setValue(m_setting.GetValue() * 100);
blockSignals(old_state);
2017-05-20 15:53:17 +00:00
}