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

@ -5,6 +5,7 @@
#pragma once
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
namespace ControllerEmu
{
@ -52,4 +53,40 @@ private:
const ControlState m_half_width;
};
class ReshapableInput : public ControlGroup
{
public:
ReshapableInput(std::string name, std::string ui_name, GroupType type);
struct StateData
{
ControlState x{};
ControlState y{};
};
enum
{
SETTING_INPUT_RADIUS,
SETTING_INPUT_SHAPE,
SETTING_DEADZONE,
SETTING_COUNT,
};
// Angle is in radians and should be non-negative
ControlState GetDeadzoneRadiusAtAngle(double ang) const;
ControlState GetInputRadiusAtAngle(double ang) const;
virtual ControlState GetGateRadiusAtAngle(double ang) const = 0;
virtual StateData GetState(bool adjusted = true) = 0;
protected:
void AddReshapingSettings(ControlState default_radius, ControlState default_shape,
int max_deadzone);
StateData Reshape(ControlState x, ControlState y, ControlState modifier = 0.0);
private:
ControlState CalculateInputShapeRadiusAtAngle(double ang) const;
};
} // namespace ControllerEmu