dolphin/Source/Core/InputCommon/ControllerEmu/ControlGroup/AnalogStick.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

71 lines
2.1 KiB
C++
Raw Normal View History

// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "InputCommon/ControllerEmu/ControlGroup/AnalogStick.h"
#include <cmath>
#include "Common/Common.h"
#include "Common/MathUtil.h"
#include "InputCommon/ControlReference/ControlReference.h"
#include "InputCommon/ControllerEmu/Control/Control.h"
#include "InputCommon/ControllerEmu/Control/Input.h"
#include "InputCommon/ControllerEmu/ControllerEmu.h"
#include "InputCommon/ControllerEmu/Setting/NumericSetting.h"
namespace ControllerEmu
{
AnalogStick::AnalogStick(const char* const name_, std::unique_ptr<StickGate>&& stick_gate)
: AnalogStick(name_, name_, std::move(stick_gate))
{
}
AnalogStick::AnalogStick(const char* const name_, const char* const ui_name_,
std::unique_ptr<StickGate>&& stick_gate)
: ReshapableInput(name_, ui_name_, GroupType::Stick), m_stick_gate(std::move(stick_gate))
{
for (auto& named_direction : named_directions)
AddInput(Translate, named_direction);
AddInput(Translate, _trans("Modifier"));
}
2018-12-30 16:52:45 +00:00
AnalogStick::ReshapeData AnalogStick::GetReshapableState(bool adjusted)
{
const ControlState y = controls[0]->GetState() - controls[1]->GetState();
const ControlState x = controls[3]->GetState() - controls[2]->GetState();
// Return raw values. (used in UI)
if (!adjusted)
return {x, y};
const ControlState modifier = controls[4]->GetState();
return Reshape(x, y, modifier);
}
AnalogStick::StateData AnalogStick::GetState()
{
return GetReshapableState(true);
}
ControlState AnalogStick::GetGateRadiusAtAngle(double ang) const
{
return m_stick_gate->GetRadiusAtAngle(ang);
}
2020-07-31 23:17:23 +00:00
OctagonAnalogStick::OctagonAnalogStick(const char* name_, ControlState gate_radius)
: OctagonAnalogStick(name_, name_, gate_radius)
{
}
2020-07-31 23:17:23 +00:00
OctagonAnalogStick::OctagonAnalogStick(const char* name_, const char* ui_name_,
ControlState gate_radius)
2020-07-31 23:17:23 +00:00
: AnalogStick(name_, ui_name_, std::make_unique<ControllerEmu::OctagonStickGate>(gate_radius))
{
}
} // namespace ControllerEmu