mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
Merge pull request #8907 from JosJuice/android-overlay-stick-gate
Android: Use octagonal stick gate in overlay
This commit is contained in:
@ -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);
|
||||
|
@ -268,9 +268,16 @@ public:
|
||||
};
|
||||
|
||||
void Init(const std::string&);
|
||||
|
||||
// pad_id is numbered 0 to 3 for GC pads and 4 to 7 for Wiimotes
|
||||
bool GetButtonPressed(int pad_id, ButtonType button);
|
||||
float GetAxisValue(int pad_id, ButtonType axis);
|
||||
|
||||
// emu_pad_id is numbered 0 to 3 for both GC pads and Wiimotes
|
||||
double GetInputRadiusAtAngle(int emu_pad_id, ButtonType stick, double angle);
|
||||
|
||||
bool GamepadEvent(const std::string& dev, int button, int action);
|
||||
void GamepadAxisEvent(const std::string& dev, int axis, float value);
|
||||
|
||||
void Shutdown();
|
||||
} // namespace ButtonManager
|
||||
|
Reference in New Issue
Block a user