mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-13 00:58:29 +02:00
ControllerEmu::Cursor: Add input radius/shape settings to IR Cursor mappings to allow use of round inputs in absolute mode. Make relative input option obey the center/width/height settings. Make the mapping indicator pretty and actually show what the relative/center/w/h settings are doing.
This commit is contained in:
@ -10,6 +10,8 @@
|
||||
#include <string>
|
||||
|
||||
#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"
|
||||
@ -35,10 +37,10 @@ Tilt::Tilt(const std::string& name_)
|
||||
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Angle"), 0.9, 0, 180));
|
||||
}
|
||||
|
||||
Tilt::StateData Tilt::GetState(bool adjusted)
|
||||
Tilt::StateData Tilt::GetReshapableState(bool adjusted)
|
||||
{
|
||||
ControlState y = controls[0]->control_ref->State() - controls[1]->control_ref->State();
|
||||
ControlState x = controls[3]->control_ref->State() - controls[2]->control_ref->State();
|
||||
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();
|
||||
|
||||
// Return raw values. (used in UI)
|
||||
if (!adjusted)
|
||||
@ -49,26 +51,37 @@ Tilt::StateData Tilt::GetState(bool adjusted)
|
||||
// Compute desired tilt:
|
||||
StateData target = Reshape(x, y, modifier);
|
||||
|
||||
// Step the simulation. This is pretty ugly being here.
|
||||
// Step the simulation. This is somewhat ugly being here.
|
||||
// We should be able to GetState without changing state.
|
||||
// State should be stored outside of this object inside the wiimote,
|
||||
// and separately inside the UI.
|
||||
|
||||
// We're using system time rather than ticks to step this.
|
||||
// I don't think that's too horrible as we can consider this part of user input.
|
||||
// And at least the Mapping UI will behave sanely this way.
|
||||
// TODO: when state is moved outside of this class have a separate Step()
|
||||
// function that takes a ms_passed argument
|
||||
const auto now = Clock::now();
|
||||
const auto ms_since_update =
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>(now - m_last_update).count();
|
||||
m_last_update = now;
|
||||
|
||||
constexpr int MAX_DEG_PER_SEC = 360 * 2;
|
||||
const double MAX_STEP = MAX_DEG_PER_SEC / 180.0 * ms_since_update / 1000;
|
||||
const double max_step = MAX_DEG_PER_SEC / 180.0 * ms_since_update / 1000;
|
||||
|
||||
// TODO: Allow wrap around from 1.0 to -1.0
|
||||
// (take the fastest route to target)
|
||||
|
||||
const double diff_x = (target.x - m_tilt.x);
|
||||
m_tilt.x += std::min(MAX_STEP, std::abs(diff_x)) * ((diff_x < 0) ? -1 : 1);
|
||||
const double diff_y = (target.y - m_tilt.y);
|
||||
m_tilt.y += std::min(MAX_STEP, std::abs(diff_y)) * ((diff_y < 0) ? -1 : 1);
|
||||
m_tilt.x += MathUtil::Clamp(target.x - m_tilt.x, -max_step, max_step);
|
||||
m_tilt.y += MathUtil::Clamp(target.y - m_tilt.y, -max_step, max_step);
|
||||
|
||||
return m_tilt;
|
||||
}
|
||||
|
||||
Tilt::StateData Tilt::GetState()
|
||||
{
|
||||
return GetReshapableState(true);
|
||||
}
|
||||
|
||||
ControlState Tilt::GetGateRadiusAtAngle(double ang) const
|
||||
{
|
||||
const ControlState max_tilt_angle = numeric_settings[SETTING_MAX_ANGLE]->GetValue() / 1.8;
|
||||
|
Reference in New Issue
Block a user