diff options
| author | spycrab <spycrab@users.noreply.github.com> | 2020-02-25 22:57:00 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-25 22:57:00 +0100 |
| commit | 459b47295dd0af91c24d921b4c8f1e17958e8c68 (patch) | |
| tree | b9bea54599dc20a0f36e087f00294a8ee2fe25c3 /Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp | |
| parent | 25d5f0d9efd2af58b5389a358794ff10359e0164 (diff) | |
| parent | 6b109bd2a6c288c4d4461d9fbdb3d691ee6a4e6d (diff) | |
Merge pull request #8643 from jordan-woyak/mapping-race-fix
InputCommon/DolphinQt: Mapping related race fixes and cleanups.
Diffstat (limited to 'Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp')
| -rw-r--r-- | Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp | 85 |
1 files changed, 50 insertions, 35 deletions
diff --git a/Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp b/Source/Core/DolphinQt/Config/Mapping/MappingWidget.cpp index eb39bac64f..09d136d0f9 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,66 @@ 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; - form_layout->addRow(indicator); + 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) + { + const auto indicator_layout = new QBoxLayout(QBoxLayout::Direction::Down); + indicator_layout->addWidget(indicator); + indicator_layout->setAlignment(Qt::AlignCenter); + form_layout->addRow(indicator_layout); 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 +120,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); |
