diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2019-10-28 16:39:10 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-28 16:39:10 +0100 |
| commit | 1f3d1a9b7fa2d4729ddadfc0fc923c7730a00a49 (patch) | |
| tree | 59c9aac33c104d3dc5b4039773b876cd6c389b4f /Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp | |
| parent | a825e7e09f8a39772b10c83db5322dc88e0f591f (diff) | |
| parent | da1f153b47a3f3f4eb9b976670bfddf68108bae9 (diff) | |
Merge pull request #8352 from rlnilsen/motion-controller-support-via-cemuhook-protocol
Support for motion controllers like the DualShock 4
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp new file mode 100644 index 0000000000..7bae049fff --- /dev/null +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.cpp @@ -0,0 +1,44 @@ +// Copyright 2019 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "InputCommon/ControllerEmu/ControlGroup/IMUGyroscope.h" + +#include "Common/Common.h" +#include "Common/MathUtil.h" + +#include "Core/HW/WiimoteEmu/WiimoteEmu.h" + +#include "InputCommon/ControlReference/ControlReference.h" +#include "InputCommon/ControllerEmu/Control/Control.h" +#include "InputCommon/ControllerEmu/Control/Input.h" +#include "InputCommon/ControllerEmu/ControllerEmu.h" +#include "InputCommon/ControllerEmu/Setting/NumericSetting.h" + +namespace ControllerEmu +{ +IMUGyroscope::IMUGyroscope(std::string name, std::string ui_name) + : ControlGroup(std::move(name), std::move(ui_name), GroupType::IMUGyroscope) +{ + controls.emplace_back(std::make_unique<Input>(Translate, _trans("Pitch Up"))); + controls.emplace_back(std::make_unique<Input>(Translate, _trans("Pitch Down"))); + controls.emplace_back(std::make_unique<Input>(Translate, _trans("Roll Left"))); + controls.emplace_back(std::make_unique<Input>(Translate, _trans("Roll Right"))); + controls.emplace_back(std::make_unique<Input>(Translate, _trans("Yaw Left"))); + controls.emplace_back(std::make_unique<Input>(Translate, _trans("Yaw Right"))); +} + +std::optional<IMUGyroscope::StateData> IMUGyroscope::GetState() const +{ + StateData state; + state.x = (controls[1]->control_ref->State() - controls[0]->control_ref->State()); + state.y = (controls[2]->control_ref->State() - controls[3]->control_ref->State()); + state.z = (controls[4]->control_ref->State() - controls[5]->control_ref->State()); + + if (controls[0]->control_ref->BoundCount() != 0) + return state; + else + return std::nullopt; +} + +} // namespace ControllerEmu |
