mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Merge pull request #7936 from jordan-woyak/numeric-setting-cleanup
InputCommon: Clean up how numeric settings are handled.
This commit is contained in:
@ -63,12 +63,10 @@ add_executable(dolphin-emu
|
||||
Config/Mapping/HotkeyTAS.cpp
|
||||
Config/Mapping/HotkeyWii.cpp
|
||||
Config/Mapping/IOWindow.cpp
|
||||
Config/Mapping/MappingBool.cpp
|
||||
Config/Mapping/MappingButton.cpp
|
||||
Config/Mapping/MappingCommon.cpp
|
||||
Config/Mapping/MappingIndicator.cpp
|
||||
Config/Mapping/MappingNumeric.cpp
|
||||
Config/Mapping/MappingRadio.cpp
|
||||
Config/Mapping/MappingWidget.cpp
|
||||
Config/Mapping/MappingWindow.cpp
|
||||
Config/Mapping/WiimoteEmuExtension.cpp
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "Core/HW/GCPad.h"
|
||||
#include "Core/HW/GCPadEmu.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
|
||||
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||
#include "InputCommon/InputConfig.h"
|
||||
|
||||
|
@ -1,29 +0,0 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "DolphinQt/Config/Mapping/MappingBool.h"
|
||||
|
||||
#include "DolphinQt/Config/Mapping/MappingWidget.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
|
||||
MappingBool::MappingBool(MappingWidget* parent, ControllerEmu::BooleanSetting* setting)
|
||||
: QCheckBox(tr(setting->m_ui_name.c_str())), m_setting(*setting)
|
||||
{
|
||||
connect(this, &QCheckBox::stateChanged, this, [this, parent](int value) {
|
||||
m_setting.SetValue(value);
|
||||
parent->SaveSettings();
|
||||
});
|
||||
|
||||
connect(parent, &MappingWidget::ConfigChanged, this, &MappingBool::ConfigChanged);
|
||||
}
|
||||
|
||||
void MappingBool::ConfigChanged()
|
||||
{
|
||||
const bool old_state = blockSignals(true);
|
||||
setChecked(m_setting.GetValue());
|
||||
blockSignals(old_state);
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QCheckBox>
|
||||
|
||||
class MappingWidget;
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class BooleanSetting;
|
||||
};
|
||||
|
||||
class MappingBool : public QCheckBox
|
||||
{
|
||||
public:
|
||||
MappingBool(MappingWidget* widget, ControllerEmu::BooleanSetting* setting);
|
||||
|
||||
private:
|
||||
void ConfigChanged();
|
||||
|
||||
ControllerEmu::BooleanSetting& m_setting;
|
||||
};
|
@ -158,7 +158,7 @@ void MappingIndicator::DrawCursor(ControllerEmu::Cursor& cursor)
|
||||
}
|
||||
|
||||
// Deadzone for Z (forward/backward):
|
||||
const double deadzone = cursor.numeric_settings[cursor.SETTING_DEADZONE]->GetValue();
|
||||
const double deadzone = cursor.GetDeadzonePercentage();
|
||||
if (deadzone > 0.0)
|
||||
{
|
||||
p.setPen(DEADZONE_COLOR);
|
||||
@ -181,23 +181,12 @@ void MappingIndicator::DrawCursor(ControllerEmu::Cursor& cursor)
|
||||
}
|
||||
|
||||
// TV screen or whatever you want to call this:
|
||||
constexpr double tv_scale = 0.75;
|
||||
constexpr double center_scale = 2.0 / 3.0;
|
||||
|
||||
const double tv_center = (cursor.numeric_settings[cursor.SETTING_CENTER]->GetValue() - 0.5);
|
||||
const double tv_width = cursor.numeric_settings[cursor.SETTING_WIDTH]->GetValue();
|
||||
const double tv_height = cursor.numeric_settings[cursor.SETTING_HEIGHT]->GetValue();
|
||||
constexpr double TV_SCALE = 0.75;
|
||||
|
||||
p.setPen(tv_pen_color);
|
||||
p.setBrush(tv_brush_color);
|
||||
auto gate_polygon = GetPolygonFromRadiusGetter(
|
||||
[&cursor](double ang) { return cursor.GetGateRadiusAtAngle(ang); }, scale);
|
||||
for (auto& pt : gate_polygon)
|
||||
{
|
||||
pt = {pt.x() * tv_width, pt.y() * tv_height + tv_center * center_scale * scale};
|
||||
pt *= tv_scale;
|
||||
}
|
||||
p.drawPolygon(gate_polygon);
|
||||
p.drawPolygon(GetPolygonFromRadiusGetter(
|
||||
[&cursor](double ang) { return cursor.GetGateRadiusAtAngle(ang); }, scale * TV_SCALE));
|
||||
|
||||
// Deadzone.
|
||||
p.setPen(DEADZONE_COLOR);
|
||||
@ -221,8 +210,8 @@ void MappingIndicator::DrawCursor(ControllerEmu::Cursor& cursor)
|
||||
{
|
||||
p.setPen(Qt::NoPen);
|
||||
p.setBrush(ADJ_INPUT_COLOR);
|
||||
const QPointF pt(adj_coord.x / 2.0, (adj_coord.y - tv_center) / 2.0 + tv_center * center_scale);
|
||||
p.drawEllipse(pt * scale * tv_scale, INPUT_DOT_RADIUS, INPUT_DOT_RADIUS);
|
||||
p.drawEllipse(QPointF{adj_coord.x, adj_coord.y} * scale * TV_SCALE, INPUT_DOT_RADIUS,
|
||||
INPUT_DOT_RADIUS);
|
||||
}
|
||||
}
|
||||
|
||||
@ -444,7 +433,7 @@ void MappingIndicator::DrawForce(ControllerEmu::Force& force)
|
||||
}
|
||||
|
||||
// Deadzone for Z (forward/backward):
|
||||
const double deadzone = force.numeric_settings[force.SETTING_DEADZONE]->GetValue();
|
||||
const double deadzone = force.GetDeadzonePercentage();
|
||||
if (deadzone > 0.0)
|
||||
{
|
||||
p.setPen(DEADZONE_COLOR);
|
||||
|
@ -16,7 +16,6 @@ class Control;
|
||||
class ControlGroup;
|
||||
class Cursor;
|
||||
class Force;
|
||||
class NumericSetting;
|
||||
} // namespace ControllerEmu
|
||||
|
||||
class QPainter;
|
||||
|
@ -7,26 +7,56 @@
|
||||
#include "DolphinQt/Config/Mapping/MappingWidget.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
|
||||
MappingNumeric::MappingNumeric(MappingWidget* parent, ControllerEmu::NumericSetting* setting)
|
||||
: m_setting(*setting)
|
||||
MappingDouble::MappingDouble(MappingWidget* parent, ControllerEmu::NumericSetting<double>* setting)
|
||||
: QDoubleSpinBox(parent), m_setting(*setting)
|
||||
{
|
||||
setRange(setting->m_low, setting->m_high);
|
||||
setRange(m_setting.GetMinValue(), m_setting.GetMaxValue());
|
||||
setDecimals(2);
|
||||
|
||||
connect(this, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this,
|
||||
[this, parent](int value) {
|
||||
m_setting.SetValue(static_cast<double>(value) / 100);
|
||||
if (const auto ui_suffix = m_setting.GetUISuffix())
|
||||
setSuffix(QStringLiteral(" ") + tr(ui_suffix));
|
||||
|
||||
if (const auto ui_description = m_setting.GetUIDescription())
|
||||
setToolTip(tr(ui_description));
|
||||
|
||||
connect(this, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this,
|
||||
[this, parent](double value) {
|
||||
m_setting.SetValue(value);
|
||||
parent->SaveSettings();
|
||||
});
|
||||
|
||||
connect(parent, &MappingWidget::ConfigChanged, this, &MappingNumeric::ConfigChanged);
|
||||
connect(parent, &MappingWidget::ConfigChanged, this, &MappingDouble::ConfigChanged);
|
||||
}
|
||||
|
||||
void MappingNumeric::ConfigChanged()
|
||||
// Overriding QDoubleSpinBox's fixup to set the default value when input is cleared.
|
||||
void MappingDouble::fixup(QString& input) const
|
||||
{
|
||||
input = QString::number(m_setting.GetDefaultValue());
|
||||
}
|
||||
|
||||
void MappingDouble::ConfigChanged()
|
||||
{
|
||||
const bool old_state = blockSignals(true);
|
||||
setValue(m_setting.GetValue() * 100);
|
||||
setValue(m_setting.GetValue());
|
||||
blockSignals(old_state);
|
||||
}
|
||||
|
||||
MappingBool::MappingBool(MappingWidget* parent, ControllerEmu::NumericSetting<bool>* setting)
|
||||
: QCheckBox(parent), m_setting(*setting)
|
||||
{
|
||||
connect(this, &QCheckBox::stateChanged, this, [this, parent](int value) {
|
||||
m_setting.SetValue(value != 0);
|
||||
parent->SaveSettings();
|
||||
});
|
||||
|
||||
connect(parent, &MappingWidget::ConfigChanged, this, &MappingBool::ConfigChanged);
|
||||
}
|
||||
|
||||
void MappingBool::ConfigChanged()
|
||||
{
|
||||
const bool old_state = blockSignals(true);
|
||||
setChecked(m_setting.GetValue());
|
||||
blockSignals(old_state);
|
||||
}
|
||||
|
@ -4,23 +4,34 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QSpinBox>
|
||||
#include <QCheckBox>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QString>
|
||||
|
||||
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||
|
||||
class MappingWidget;
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class NumericSetting;
|
||||
}
|
||||
|
||||
class MappingNumeric : public QSpinBox
|
||||
class MappingDouble : public QDoubleSpinBox
|
||||
{
|
||||
public:
|
||||
MappingNumeric(MappingWidget* widget, ControllerEmu::NumericSetting* ref);
|
||||
MappingDouble(MappingWidget* parent, ControllerEmu::NumericSetting<double>* setting);
|
||||
|
||||
private:
|
||||
void fixup(QString& input) const override;
|
||||
|
||||
void ConfigChanged();
|
||||
|
||||
ControllerEmu::NumericSetting<double>& m_setting;
|
||||
};
|
||||
|
||||
class MappingBool : public QCheckBox
|
||||
{
|
||||
public:
|
||||
MappingBool(MappingWidget* widget, ControllerEmu::NumericSetting<bool>* setting);
|
||||
|
||||
private:
|
||||
void ConfigChanged();
|
||||
|
||||
ControllerEmu::NumericSetting& m_setting;
|
||||
ControllerEmu::NumericSetting<bool>& m_setting;
|
||||
};
|
||||
|
@ -1,29 +0,0 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "DolphinQt/Config/Mapping/MappingRadio.h"
|
||||
|
||||
#include "DolphinQt/Config/Mapping/MappingWidget.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
|
||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||
|
||||
MappingRadio::MappingRadio(MappingWidget* parent, ControllerEmu::BooleanSetting* setting)
|
||||
: QRadioButton(tr(setting->m_ui_name.c_str())), m_setting(*setting)
|
||||
{
|
||||
connect(this, &QRadioButton::toggled, this, [this, parent](int value) {
|
||||
m_setting.SetValue(value);
|
||||
parent->SaveSettings();
|
||||
});
|
||||
|
||||
connect(parent, &MappingWidget::ConfigChanged, this, &MappingRadio::ConfigChanged);
|
||||
}
|
||||
|
||||
void MappingRadio::ConfigChanged()
|
||||
{
|
||||
const bool old_state = blockSignals(true);
|
||||
setChecked(m_setting.GetValue());
|
||||
blockSignals(old_state);
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
// Copyright 2017 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QRadioButton>
|
||||
|
||||
class MappingWidget;
|
||||
|
||||
namespace ControllerEmu
|
||||
{
|
||||
class BooleanSetting;
|
||||
};
|
||||
|
||||
class MappingRadio : public QRadioButton
|
||||
{
|
||||
public:
|
||||
MappingRadio(MappingWidget* widget, ControllerEmu::BooleanSetting* setting);
|
||||
|
||||
private:
|
||||
void ConfigChanged();
|
||||
|
||||
ControllerEmu::BooleanSetting& m_setting;
|
||||
};
|
@ -10,11 +10,9 @@
|
||||
#include <QTimer>
|
||||
|
||||
#include "DolphinQt/Config/Mapping/IOWindow.h"
|
||||
#include "DolphinQt/Config/Mapping/MappingBool.h"
|
||||
#include "DolphinQt/Config/Mapping/MappingButton.h"
|
||||
#include "DolphinQt/Config/Mapping/MappingIndicator.h"
|
||||
#include "DolphinQt/Config/Mapping/MappingNumeric.h"
|
||||
#include "DolphinQt/Config/Mapping/MappingRadio.h"
|
||||
#include "DolphinQt/Config/Mapping/MappingWindow.h"
|
||||
#include "DolphinQt/Settings.h"
|
||||
|
||||
@ -22,7 +20,6 @@
|
||||
#include "InputCommon/ControllerEmu/Control/Control.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
|
||||
#include "InputCommon/ControllerEmu/ControllerEmu.h"
|
||||
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
|
||||
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
|
||||
#include "InputCommon/ControllerEmu/StickGate.h"
|
||||
|
||||
@ -109,30 +106,25 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con
|
||||
m_buttons.push_back(button);
|
||||
}
|
||||
|
||||
for (auto& numeric : group->numeric_settings)
|
||||
for (auto& setting : group->numeric_settings)
|
||||
{
|
||||
auto* spinbox = new MappingNumeric(this, numeric.get());
|
||||
form_layout->addRow(tr(numeric->m_name.c_str()), spinbox);
|
||||
}
|
||||
QWidget* setting_widget = nullptr;
|
||||
|
||||
for (auto& boolean : group->boolean_settings)
|
||||
{
|
||||
if (!boolean->IsExclusive())
|
||||
continue;
|
||||
switch (setting->GetType())
|
||||
{
|
||||
case ControllerEmu::SettingType::Double:
|
||||
setting_widget = new MappingDouble(
|
||||
this, static_cast<ControllerEmu::NumericSetting<double>*>(setting.get()));
|
||||
break;
|
||||
|
||||
auto* checkbox = new MappingRadio(this, boolean.get());
|
||||
case ControllerEmu::SettingType::Bool:
|
||||
setting_widget =
|
||||
new MappingBool(this, static_cast<ControllerEmu::NumericSetting<bool>*>(setting.get()));
|
||||
break;
|
||||
}
|
||||
|
||||
form_layout->addRow(checkbox);
|
||||
}
|
||||
|
||||
for (auto& boolean : group->boolean_settings)
|
||||
{
|
||||
if (boolean->IsExclusive())
|
||||
continue;
|
||||
|
||||
auto* checkbox = new MappingBool(this, boolean.get());
|
||||
|
||||
form_layout->addRow(checkbox);
|
||||
if (setting_widget)
|
||||
form_layout->addRow(tr(setting->GetUIName()), setting_widget);
|
||||
}
|
||||
|
||||
if (need_indicator)
|
||||
|
@ -13,11 +13,9 @@
|
||||
class ControlGroupBox;
|
||||
class InputConfig;
|
||||
class IOWindow;
|
||||
class MappingBool;
|
||||
class MappingButton;
|
||||
class MappingNumeric;
|
||||
class MappingWindow;
|
||||
class MappingRadio;
|
||||
class QGroupBox;
|
||||
|
||||
namespace ControllerEmu
|
||||
|
@ -239,7 +239,7 @@ void MappingWindow::OnSaveProfilePressed()
|
||||
}
|
||||
}
|
||||
|
||||
void MappingWindow::OnSelectDevice(int index)
|
||||
void MappingWindow::OnSelectDevice(int)
|
||||
{
|
||||
if (IsMappingAllDevices())
|
||||
return;
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "DolphinQt/Config/Mapping/WiimoteEmuExtension.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Attachments.h"
|
||||
#include "InputCommon/ControllerEmu/Setting/BooleanSetting.h"
|
||||
#include "InputCommon/InputConfig.h"
|
||||
|
||||
WiimoteEmuGeneral::WiimoteEmuGeneral(MappingWindow* window, WiimoteEmuExtension* extension)
|
||||
|
@ -81,7 +81,6 @@
|
||||
<QtMoc Include="Config\Mapping\HotkeyTAS.h" />
|
||||
<QtMoc Include="Config\Mapping\HotkeyWii.h" />
|
||||
<QtMoc Include="Config\Mapping\IOWindow.h" />
|
||||
<QtMoc Include="Config\Mapping\MappingBool.h" />
|
||||
<QtMoc Include="Config\Mapping\MappingButton.h" />
|
||||
<QtMoc Include="Config\Mapping\MappingIndicator.h" />
|
||||
<QtMoc Include="Config\Mapping\MappingNumeric.h" />
|
||||
@ -239,7 +238,6 @@
|
||||
<ClCompile Include="$(QtMocOutPrefix)LogWidget.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)MD5Dialog.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)MainWindow.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)MappingBool.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)MappingButton.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)MappingIndicator.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)MappingNumeric.cpp" />
|
||||
@ -316,12 +314,10 @@
|
||||
<ClCompile Include="Config\Mapping\HotkeyTAS.cpp" />
|
||||
<ClCompile Include="Config\Mapping\HotkeyWii.cpp" />
|
||||
<ClCompile Include="Config\Mapping\IOWindow.cpp" />
|
||||
<ClCompile Include="Config\Mapping\MappingBool.cpp" />
|
||||
<ClCompile Include="Config\Mapping\MappingButton.cpp" />
|
||||
<ClCompile Include="Config\Mapping\MappingCommon.cpp" />
|
||||
<ClCompile Include="Config\Mapping\MappingIndicator.cpp" />
|
||||
<ClCompile Include="Config\Mapping\MappingNumeric.cpp" />
|
||||
<ClCompile Include="Config\Mapping\MappingRadio.cpp" />
|
||||
<ClCompile Include="Config\Mapping\MappingWidget.cpp" />
|
||||
<ClCompile Include="Config\Mapping\MappingWindow.cpp" />
|
||||
<ClCompile Include="Config\Mapping\WiimoteEmuExtension.cpp" />
|
||||
@ -402,7 +398,6 @@
|
||||
<!--Put standard C/C++ headers here. Headers that are listed in the QtMoc ItemGroup must NOT be listed here.-->
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Config\Mapping\MappingCommon.h" />
|
||||
<ClInclude Include="Config\Mapping\MappingRadio.h" />
|
||||
<ClInclude Include="Debugger\RegisterColumn.h" />
|
||||
<ClInclude Include="QtUtils\ActionHelper.h" />
|
||||
<ClInclude Include="QtUtils\ImageConverter.h" />
|
||||
|
Reference in New Issue
Block a user