InputCommon: Use value of "Modifier" button "Range" setting rather than always applying 50%.
Make "Clear" button reset "Modifier" "Range" settings to 50%.
This commit is contained in:
parent
953eb49cd8
commit
78a9bdf04a
|
@ -198,10 +198,6 @@ void GCPad::LoadDefaults(const ControllerInterface& ciface)
|
||||||
m_buttons->SetControlExpression(5, "`Return`");
|
m_buttons->SetControlExpression(5, "`Return`");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// stick modifiers to 50 %
|
|
||||||
m_main_stick->controls[4]->control_ref->range = 0.5f;
|
|
||||||
m_c_stick->controls[4]->control_ref->range = 0.5f;
|
|
||||||
|
|
||||||
// D-Pad
|
// D-Pad
|
||||||
m_dpad->SetControlExpression(0, "`T`"); // Up
|
m_dpad->SetControlExpression(0, "`T`"); // Up
|
||||||
m_dpad->SetControlExpression(1, "`G`"); // Down
|
m_dpad->SetControlExpression(1, "`G`"); // Down
|
||||||
|
|
|
@ -40,9 +40,7 @@ AnalogStick::ReshapeData AnalogStick::GetReshapableState(bool adjusted) const
|
||||||
if (!adjusted)
|
if (!adjusted)
|
||||||
return {x, y};
|
return {x, y};
|
||||||
|
|
||||||
const ControlState modifier = controls[4]->GetState();
|
return Reshape(x, y, GetModifierInput()->GetState());
|
||||||
|
|
||||||
return Reshape(x, y, modifier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AnalogStick::StateData AnalogStick::GetState() const
|
AnalogStick::StateData AnalogStick::GetState() const
|
||||||
|
@ -55,6 +53,11 @@ ControlState AnalogStick::GetGateRadiusAtAngle(double ang) const
|
||||||
return m_stick_gate->GetRadiusAtAngle(ang);
|
return m_stick_gate->GetRadiusAtAngle(ang);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Control* AnalogStick::GetModifierInput() const
|
||||||
|
{
|
||||||
|
return controls[4].get();
|
||||||
|
}
|
||||||
|
|
||||||
OctagonAnalogStick::OctagonAnalogStick(const char* name_, ControlState gate_radius)
|
OctagonAnalogStick::OctagonAnalogStick(const char* name_, ControlState gate_radius)
|
||||||
: OctagonAnalogStick(name_, name_, gate_radius)
|
: OctagonAnalogStick(name_, name_, gate_radius)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,6 +23,8 @@ public:
|
||||||
StateData GetState() const;
|
StateData GetState() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Control* GetModifierInput() const override;
|
||||||
|
|
||||||
std::unique_ptr<StickGate> m_stick_gate;
|
std::unique_ptr<StickGate> m_stick_gate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -50,9 +50,7 @@ Tilt::ReshapeData Tilt::GetReshapableState(bool adjusted) const
|
||||||
if (!adjusted)
|
if (!adjusted)
|
||||||
return {x, y};
|
return {x, y};
|
||||||
|
|
||||||
const ControlState modifier = controls[4]->GetState();
|
return Reshape(x, y, GetModifierInput()->GetState());
|
||||||
|
|
||||||
return Reshape(x, y, modifier);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Tilt::StateData Tilt::GetState() const
|
Tilt::StateData Tilt::GetState() const
|
||||||
|
@ -76,4 +74,9 @@ ControlState Tilt::GetMaxRotationalVelocity() const
|
||||||
return m_max_rotational_velocity.GetValue() * MathUtil::TAU;
|
return m_max_rotational_velocity.GetValue() * MathUtil::TAU;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Control* Tilt::GetModifierInput() const
|
||||||
|
{
|
||||||
|
return controls[4].get();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ControllerEmu
|
} // namespace ControllerEmu
|
||||||
|
|
|
@ -31,6 +31,8 @@ public:
|
||||||
ControlState GetMaxRotationalVelocity() const;
|
ControlState GetMaxRotationalVelocity() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Control* GetModifierInput() const override;
|
||||||
|
|
||||||
SettingValue<double> m_max_angle_setting;
|
SettingValue<double> m_max_angle_setting;
|
||||||
SettingValue<double> m_max_rotational_velocity;
|
SettingValue<double> m_max_rotational_velocity;
|
||||||
};
|
};
|
||||||
|
|
|
@ -232,6 +232,15 @@ void ReshapableInput::LoadConfig(IniFile::Section* section, const std::string& d
|
||||||
ControlGroup::LoadConfig(section, default_device, base_name);
|
ControlGroup::LoadConfig(section, default_device, base_name);
|
||||||
|
|
||||||
const std::string group(base_name + name + '/');
|
const std::string group(base_name + name + '/');
|
||||||
|
|
||||||
|
// Special handling for "Modifier" button "Range" settings which default to 50% instead of 100%.
|
||||||
|
if (const auto* modifier_input = GetModifierInput())
|
||||||
|
{
|
||||||
|
section->Get(group + modifier_input->name + "/Range", &modifier_input->control_ref->range,
|
||||||
|
50.0);
|
||||||
|
modifier_input->control_ref->range /= 100;
|
||||||
|
}
|
||||||
|
|
||||||
std::string load_str;
|
std::string load_str;
|
||||||
section->Get(group + CALIBRATION_CONFIG_NAME, &load_str, "");
|
section->Get(group + CALIBRATION_CONFIG_NAME, &load_str, "");
|
||||||
const auto load_data = SplitString(load_str, ' ');
|
const auto load_data = SplitString(load_str, ' ');
|
||||||
|
@ -313,11 +322,7 @@ ReshapableInput::ReshapeData ReshapableInput::Reshape(ControlState x, ControlSta
|
||||||
// This is affected by the modifier's "range" setting which defaults to 50%.
|
// This is affected by the modifier's "range" setting which defaults to 50%.
|
||||||
if (modifier)
|
if (modifier)
|
||||||
{
|
{
|
||||||
// TODO: Modifier's range setting gets reset to 100% when the clear button is clicked.
|
dist *= modifier;
|
||||||
// This causes the modifier to not behave how a user might suspect.
|
|
||||||
// Retaining the old scale-by-50% behavior until range is fixed to clear to 50%.
|
|
||||||
dist *= 0.5;
|
|
||||||
// dist *= modifier;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply deadzone as a percentage of the user-defined calibration shape/size:
|
// Apply deadzone as a percentage of the user-defined calibration shape/size:
|
||||||
|
@ -330,4 +335,9 @@ ReshapableInput::ReshapeData ReshapableInput::Reshape(ControlState x, ControlSta
|
||||||
std::clamp(std::sin(angle) * dist, -clamp, clamp)};
|
std::clamp(std::sin(angle) * dist, -clamp, clamp)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Control* ReshapableInput::GetModifierInput() const
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ControllerEmu
|
} // namespace ControllerEmu
|
||||||
|
|
|
@ -110,6 +110,8 @@ protected:
|
||||||
ReshapeData Reshape(ControlState x, ControlState y, ControlState modifier = 0.0,
|
ReshapeData Reshape(ControlState x, ControlState y, ControlState modifier = 0.0,
|
||||||
ControlState clamp = 1.0) const;
|
ControlState clamp = 1.0) const;
|
||||||
|
|
||||||
|
virtual Control* GetModifierInput() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void LoadConfig(IniFile::Section*, const std::string&, const std::string&) override;
|
void LoadConfig(IniFile::Section*, const std::string&, const std::string&) override;
|
||||||
void SaveConfig(IniFile::Section*, const std::string&, const std::string&) override;
|
void SaveConfig(IniFile::Section*, const std::string&, const std::string&) override;
|
||||||
|
|
Loading…
Reference in New Issue