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"
|
2018-05-13 19:17:46 +00:00
|
|
|
|
|
|
|
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
2017-05-20 15:53:17 +00:00
|
|
|
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
2018-05-13 19:17:46 +00:00
|
|
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
2017-05-20 15:53:17 +00:00
|
|
|
|
|
|
|
MappingNumeric::MappingNumeric(MappingWidget* widget, ControllerEmu::NumericSetting* setting)
|
2018-04-28 10:32:23 +00:00
|
|
|
: m_parent(widget), m_setting(setting)
|
2017-05-20 15:53:17 +00:00
|
|
|
{
|
|
|
|
setRange(setting->m_low, setting->m_high);
|
2017-11-03 20:28:45 +00:00
|
|
|
Update();
|
2017-05-20 15:53:17 +00:00
|
|
|
Connect();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MappingNumeric::Connect()
|
|
|
|
{
|
|
|
|
connect(this, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
|
|
|
|
[this](int value) {
|
2018-04-28 10:32:23 +00:00
|
|
|
m_setting->SetValue(static_cast<double>(value) / 100);
|
2017-11-03 20:28:45 +00:00
|
|
|
m_parent->SaveSettings();
|
2018-05-13 19:17:46 +00:00
|
|
|
m_parent->GetController()->UpdateReferences(g_controller_interface);
|
2017-05-20 15:53:17 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void MappingNumeric::Clear()
|
|
|
|
{
|
2018-04-28 11:02:26 +00:00
|
|
|
m_setting->SetValue(m_setting->m_default_value);
|
2017-11-03 20:28:45 +00:00
|
|
|
m_parent->SaveSettings();
|
2017-05-20 15:53:17 +00:00
|
|
|
Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MappingNumeric::Update()
|
|
|
|
{
|
2018-04-28 10:32:23 +00:00
|
|
|
setValue(m_setting->GetValue() * 100);
|
2017-05-20 15:53:17 +00:00
|
|
|
}
|