ControllerEmu: Reorganize stick reshaping code and use it for emu wiimote tilt as well. Also make the tilt mapping indicator pretty.

This commit is contained in:
Jordan Woyak
2018-12-29 16:06:03 -06:00
parent 6a6195f53c
commit c3dc3c106c
8 changed files with 189 additions and 164 deletions

View File

@ -10,35 +10,17 @@
namespace ControllerEmu
{
class AnalogStick : public ControlGroup
class AnalogStick : public ReshapableInput
{
public:
enum
{
SETTING_INPUT_RADIUS,
SETTING_INPUT_SHAPE,
SETTING_DEADZONE,
};
struct StateData
{
ControlState x{};
ControlState y{};
};
AnalogStick(const char* name, std::unique_ptr<StickGate>&& stick_gate);
AnalogStick(const char* name, const char* ui_name, std::unique_ptr<StickGate>&& stick_gate);
StateData GetState(bool adjusted = true);
StateData GetState(bool adjusted = true) override;
// Angle is in radians and should be non-negative
ControlState GetGateRadiusAtAngle(double ang) const;
ControlState GetDeadzoneRadiusAtAngle(double ang) const;
ControlState GetInputRadiusAtAngle(double ang) const;
ControlState GetGateRadiusAtAngle(double ang) const override;
private:
ControlState CalculateInputShapeRadiusAtAngle(double ang) const;
std::unique_ptr<StickGate> m_stick_gate;
};