ControllerEmu: code cleanup.

This commit is contained in:
Jordan Woyak
2018-12-30 10:52:45 -06:00
parent 1c24bef594
commit 7efa96eda9
9 changed files with 41 additions and 36 deletions

View File

@ -37,7 +37,7 @@ AnalogStick::AnalogStick(const char* const name_, const char* const ui_name_,
AddReshapingSettings(GetGateRadiusAtAngle(0.0), 0.0, 50);
}
AnalogStick::StateData AnalogStick::GetReshapableState(bool adjusted)
AnalogStick::ReshapeData AnalogStick::GetReshapableState(bool adjusted)
{
const ControlState y = controls[0]->control_ref->State() - controls[1]->control_ref->State();
const ControlState x = controls[3]->control_ref->State() - controls[2]->control_ref->State();

View File

@ -13,12 +13,12 @@ namespace ControllerEmu
class AnalogStick : public ReshapableInput
{
public:
typedef ReshapeData StateData;
using StateData = ReshapeData;
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 GetReshapableState(bool adjusted) final override;
ReshapeData GetReshapableState(bool adjusted) final override;
ControlState GetGateRadiusAtAngle(double ang) const override;
StateData GetState();

View File

@ -43,7 +43,7 @@ Cursor::Cursor(const std::string& name_)
boolean_settings.emplace_back(std::make_unique<BooleanSetting>(_trans("Auto-Hide"), false));
}
ReshapableInput::ReshapeData Cursor::GetReshapableState(bool adjusted)
Cursor::ReshapeData Cursor::GetReshapableState(bool adjusted)
{
const ControlState y = controls[0]->control_ref->State() - controls[1]->control_ref->State();
const ControlState x = controls[3]->control_ref->State() - controls[2]->control_ref->State();

View File

@ -57,7 +57,7 @@ private:
int m_auto_hide_timer = AUTO_HIDE_MS;
typedef std::chrono::steady_clock Clock;
using Clock = std::chrono::steady_clock;
Clock::time_point m_last_update;
};
} // namespace ControllerEmu

View File

@ -26,7 +26,7 @@ MixedTriggers::MixedTriggers(const std::string& name_)
}
void MixedTriggers::GetState(u16* const digital, const u16* bitmasks, ControlState* analog,
bool adjusted)
bool adjusted) const
{
const ControlState threshold = numeric_settings[SETTING_THRESHOLD]->GetValue();
ControlState deadzone = numeric_settings[SETTING_DEADZONE]->GetValue();

View File

@ -13,17 +13,19 @@ namespace ControllerEmu
class MixedTriggers : public ControlGroup
{
public:
explicit MixedTriggers(const std::string& name);
void GetState(u16* digital, const u16* bitmasks, ControlState* analog,
bool adjusted = true) const;
ControlState GetDeadzone() const;
ControlState GetThreshold() const;
private:
enum
{
SETTING_THRESHOLD,
SETTING_DEADZONE,
};
explicit MixedTriggers(const std::string& name);
void GetState(u16* digital, const u16* bitmasks, ControlState* analog, bool adjusted = true);
ControlState GetDeadzone() const;
ControlState GetThreshold() const;
};
} // namespace ControllerEmu

View File

@ -37,7 +37,7 @@ Tilt::Tilt(const std::string& name_)
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Angle"), 0.9, 0, 180));
}
Tilt::StateData Tilt::GetReshapableState(bool adjusted)
Tilt::ReshapeData Tilt::GetReshapableState(bool adjusted)
{
const ControlState y = controls[0]->control_ref->State() - controls[1]->control_ref->State();
const ControlState x = controls[3]->control_ref->State() - controls[2]->control_ref->State();

View File

@ -15,26 +15,26 @@ namespace ControllerEmu
class Tilt : public ReshapableInput
{
public:
typedef ReshapeData StateData;
enum
{
SETTING_MAX_ANGLE = ReshapableInput::SETTING_COUNT,
};
using StateData = ReshapeData;
explicit Tilt(const std::string& name);
StateData GetReshapableState(bool adjusted) final override;
ReshapeData GetReshapableState(bool adjusted) final override;
ControlState GetGateRadiusAtAngle(double ang) const override;
StateData GetState();
private:
enum
{
SETTING_MAX_ANGLE = ReshapableInput::SETTING_COUNT,
};
static constexpr int MAX_DEG_PER_SEC = 360 * 6;
StateData m_tilt;
typedef std::chrono::steady_clock Clock;
using Clock = std::chrono::steady_clock;
Clock::time_point m_last_update;
};
} // namespace ControllerEmu