diff options
| author | JosJuice <josjuice@gmail.com> | 2020-06-28 23:32:36 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2020-06-29 01:20:02 +0200 |
| commit | db75509ec5d2cd15036a5cda629f952c2b860d6e (patch) | |
| tree | 43b6be00a008f361e1eedf2aa70cc291ff6fbbd0 /Source/Core/InputCommon/ControllerInterface/Touch/ButtonManager.cpp | |
| parent | 961f93701065f099ba68fb610f699f89b804a2b4 (diff) | |
Android: Enfore correct stick gate in overlay
Currently, the touch controller overlay uses a square gate for
sticks. This commit changes that so that it instead uses the
stick gate configured in the INI, which ensures that the values
sent to the core are appropriately scaled regardless of what
is configured in the INI and makes the overlay look nicer
if the INI is set to a stick gate that matches the graphics.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/Touch/ButtonManager.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/Touch/ButtonManager.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/Touch/ButtonManager.cpp b/Source/Core/InputCommon/ControllerInterface/Touch/ButtonManager.cpp index 22b05952f6..75f69b8823 100644 --- a/Source/Core/InputCommon/ControllerInterface/Touch/ButtonManager.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Touch/ButtonManager.cpp @@ -8,10 +8,22 @@ #include <unordered_map> #include <vector> +#include "Common/Assert.h" #include "Common/FileUtil.h" #include "Common/IniFile.h" #include "Common/StringUtil.h" #include "Common/Thread.h" + +#include "Core/Core.h" +#include "Core/HW/GCPad.h" +#include "Core/HW/GCPadEmu.h" +#include "Core/HW/Wiimote.h" +#include "Core/HW/WiimoteEmu/Extension/Classic.h" +#include "Core/HW/WiimoteEmu/Extension/Nunchuk.h" +#include "Core/HW/WiimoteEmu/WiimoteEmu.h" + +#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h" +#include "InputCommon/ControllerEmu/StickGate.h" #include "InputCommon/ControllerInterface/Touch/ButtonManager.h" namespace ButtonManager @@ -688,6 +700,39 @@ float GetAxisValue(int pad_id, ButtonType axis) return value; } +double GetInputRadiusAtAngle(int pad_id, ButtonType stick, double angle) +{ + // To avoid a crash, don't access controllers before they've been initialized by the boot process + if (!Core::IsRunningAndStarted()) + return 0; + + ControllerEmu::ControlGroup* group; + + switch (stick) + { + case STICK_MAIN: + group = Pad::GetGroup(pad_id, PadGroup::MainStick); + break; + case STICK_C: + group = Pad::GetGroup(pad_id, PadGroup::CStick); + break; + case NUNCHUK_STICK: + group = Wiimote::GetNunchukGroup(pad_id, WiimoteEmu::NunchukGroup::Stick); + break; + case CLASSIC_STICK_LEFT: + group = Wiimote::GetClassicGroup(pad_id, WiimoteEmu::ClassicGroup::LeftStick); + break; + case CLASSIC_STICK_RIGHT: + group = Wiimote::GetClassicGroup(pad_id, WiimoteEmu::ClassicGroup::RightStick); + break; + default: + ASSERT(false); + return 0; + } + + return static_cast<ControllerEmu::ReshapableInput*>(group)->GetInputRadiusAtAngle(angle); +} + bool GamepadEvent(const std::string& dev, int button, int action) { auto it = m_controllers.find(dev); |
