diff options
| author | Scott Mansell <phiren@gmail.com> | 2016-09-07 14:20:02 +1200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-09-07 14:20:02 +1200 |
| commit | 62d7a698da178307c43a54f1342754277380417f (patch) | |
| tree | e9536b7b6aaf20e9eff7366950dbe1b8b5e20eed /Source/Core/InputCommon/ControllerEmu.cpp | |
| parent | 7311cd8b6e7ad616c1e4fd813ebc76448f7ed8e9 (diff) | |
| parent | 3266bf052a2e5d26b62a98548d1b126f052b5d78 (diff) | |
Merge pull request #4145 from tenthmile/WiiOrientationModifier
Emulated Wiimote Orientation Modifier
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerEmu.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu.cpp b/Source/Core/InputCommon/ControllerEmu.cpp index b3b13b796a..2fd85b3fac 100644 --- a/Source/Core/InputCommon/ControllerEmu.cpp +++ b/Source/Core/InputCommon/ControllerEmu.cpp @@ -5,6 +5,7 @@ #include "InputCommon/ControllerEmu.h" #include <memory> #include "Common/Common.h" +#include "VideoCommon/OnScreenDisplay.h" // This should be called before calling GetState() or State() on a control reference // to prevent a race condition. @@ -191,6 +192,51 @@ ControllerEmu::Buttons::Buttons(const std::string& _name) : ControlGroup(_name, numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.5)); } +ControllerEmu::ModifySettingsButton::ModifySettingsButton(std::string button_name) + : Buttons(std::move(button_name)) +{ + numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Threshold"), 0.5)); +} + +void ControllerEmu::ModifySettingsButton::AddInput(std::string button_name, bool toggle) +{ + controls.emplace_back(new ControlGroup::Input(std::move(button_name))); + threshold_exceeded.emplace_back(false); + associated_settings.emplace_back(false); + associated_settings_toggle.emplace_back(toggle); +} + +void ControllerEmu::ModifySettingsButton::GetState() +{ + for (size_t i = 0; i < controls.size(); ++i) + { + ControlState state = controls[i]->control_ref->State(); + + if (!associated_settings_toggle[i]) + { + // not toggled + associated_settings[i] = state > numeric_settings[0]->GetValue(); + } + else + { + // toggle (loading savestates does not en-/disable toggle) + // after we passed the threshold, we en-/disable. but after that, we don't change it + // anymore + if (!threshold_exceeded[i] && state > numeric_settings[0]->GetValue()) + { + associated_settings[i] = !associated_settings[i]; + if (associated_settings[i]) + OSD::AddMessage(controls[i]->name + ": " + _trans("on")); + else + OSD::AddMessage(controls[i]->name + ": " + _trans("off")); + threshold_exceeded[i] = true; + } + if (state < numeric_settings[0]->GetValue()) + threshold_exceeded[i] = false; + } + } +} + ControllerEmu::MixedTriggers::MixedTriggers(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_MIXED_TRIGGERS) { |
