summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp
diff options
context:
space:
mode:
authorJordan Woyak <jordan.woyak@gmail.com>2020-02-23 13:34:05 -0600
committerJordan Woyak <jordan.woyak@gmail.com>2020-02-24 16:25:06 -0600
commit38f36be9aed3e4079d08437a96ac7606167cfbf8 (patch)
treefa3b746c8b6f8d79b3348f3e4e54d09fe5b93626 /Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp
parent7accd9825f50527a4fdf369df46349f341c2fc95 (diff)
DolphinQt: Break mapping indicators into separate classes. Ensure "state lock" is held on redraw.
Diffstat (limited to 'Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp')
-rw-r--r--Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp80
1 files changed, 46 insertions, 34 deletions
diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp
index eb39bac64f..160c914a63 100644
--- a/Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp
+++ b/Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp
@@ -19,6 +19,7 @@
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerEmu/Control/Control.h"
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
+#include "InputCommon/ControllerEmu/ControlGroup/MixedTriggers.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h"
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
#include "InputCommon/ControllerEmu/StickGate.h"
@@ -52,52 +53,63 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con
group_box->setLayout(form_layout);
- const bool need_indicator = group->type == ControllerEmu::GroupType::Cursor ||
- group->type == ControllerEmu::GroupType::Stick ||
- group->type == ControllerEmu::GroupType::Tilt ||
- group->type == ControllerEmu::GroupType::MixedTriggers ||
- group->type == ControllerEmu::GroupType::Force ||
- group->type == ControllerEmu::GroupType::IMUAccelerometer ||
- group->type == ControllerEmu::GroupType::IMUGyroscope ||
- group->type == ControllerEmu::GroupType::Shake;
-
- const bool need_calibration = group->type == ControllerEmu::GroupType::Cursor ||
- group->type == ControllerEmu::GroupType::Stick ||
- group->type == ControllerEmu::GroupType::Tilt ||
- group->type == ControllerEmu::GroupType::Force;
-
- if (need_indicator)
+ MappingIndicator* indicator = nullptr;
+
+ switch (group->type)
{
- MappingIndicator* indicator;
+ case ControllerEmu::GroupType::Shake:
+ indicator = new ShakeMappingIndicator(*static_cast<ControllerEmu::Shake*>(group));
+ break;
- switch (group->type)
- {
- case ControllerEmu::GroupType::Shake:
- indicator = new ShakeMappingIndicator(static_cast<ControllerEmu::Shake*>(group));
- break;
+ case ControllerEmu::GroupType::MixedTriggers:
+ indicator = new MixedTriggersIndicator(*static_cast<ControllerEmu::MixedTriggers*>(group));
+ break;
- case ControllerEmu::GroupType::IMUAccelerometer:
- indicator =
- new AccelerometerMappingIndicator(static_cast<ControllerEmu::IMUAccelerometer*>(group));
- break;
+ case ControllerEmu::GroupType::Tilt:
+ indicator = new TiltIndicator(*static_cast<ControllerEmu::Tilt*>(group));
+ break;
- case ControllerEmu::GroupType::IMUGyroscope:
- indicator = new GyroMappingIndicator(static_cast<ControllerEmu::IMUGyroscope*>(group));
- break;
+ case ControllerEmu::GroupType::Cursor:
+ indicator = new CursorIndicator(*static_cast<ControllerEmu::Cursor*>(group));
+ break;
- default:
- indicator = new MappingIndicator(group);
- break;
- }
+ case ControllerEmu::GroupType::Force:
+ indicator = new SwingIndicator(*static_cast<ControllerEmu::Force*>(group));
+ break;
+ case ControllerEmu::GroupType::IMUAccelerometer:
+ indicator =
+ new AccelerometerMappingIndicator(*static_cast<ControllerEmu::IMUAccelerometer*>(group));
+ break;
+
+ case ControllerEmu::GroupType::IMUGyroscope:
+ indicator = new GyroMappingIndicator(*static_cast<ControllerEmu::IMUGyroscope*>(group));
+ break;
+
+ case ControllerEmu::GroupType::Stick:
+ indicator = new AnalogStickIndicator(*static_cast<ControllerEmu::ReshapableInput*>(group));
+ break;
+
+ default:
+ break;
+ }
+
+ if (indicator)
+ {
form_layout->addRow(indicator);
connect(this, &MappingWidget::Update, indicator, QOverload<>::of(&MappingIndicator::update));
+ const bool need_calibration = group->type == ControllerEmu::GroupType::Cursor ||
+ group->type == ControllerEmu::GroupType::Stick ||
+ group->type == ControllerEmu::GroupType::Tilt ||
+ group->type == ControllerEmu::GroupType::Force;
+
if (need_calibration)
{
const auto calibrate =
- new CalibrationWidget(*static_cast<ControllerEmu::ReshapableInput*>(group), *indicator);
+ new CalibrationWidget(*static_cast<ControllerEmu::ReshapableInput*>(group),
+ *static_cast<ReshapableInputIndicator*>(indicator));
form_layout->addRow(calibrate);
}
@@ -105,7 +117,7 @@ QGroupBox* MappingWidget::CreateGroupBox(const QString& name, ControllerEmu::Con
for (auto& control : group->controls)
{
- auto* button = new MappingButton(this, control->control_ref.get(), !need_indicator);
+ auto* button = new MappingButton(this, control->control_ref.get(), !indicator);
button->setMinimumWidth(100);
button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);