mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-06 19:45:33 +00:00
Controller: Add GetVibrationMotorState()
This commit is contained in:
parent
aaf2a4b614
commit
dd7fd32501
@ -171,6 +171,11 @@ float AnalogController::GetBindState(u32 index) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float AnalogController::GetVibrationMotorState(u32 index) const
|
||||||
|
{
|
||||||
|
return ((index < m_motor_state.size()) ? m_motor_state[index] : 0) * (1.0f / 255.0f);
|
||||||
|
}
|
||||||
|
|
||||||
void AnalogController::SetBindState(u32 index, float value)
|
void AnalogController::SetBindState(u32 index, float value)
|
||||||
{
|
{
|
||||||
if (index == static_cast<s32>(Button::Analog))
|
if (index == static_cast<s32>(Button::Analog))
|
||||||
|
@ -72,6 +72,7 @@ public:
|
|||||||
bool DoState(StateWrapper& sw, bool ignore_input_state) override;
|
bool DoState(StateWrapper& sw, bool ignore_input_state) override;
|
||||||
|
|
||||||
float GetBindState(u32 index) const override;
|
float GetBindState(u32 index) const override;
|
||||||
|
float GetVibrationMotorState(u32 index) const override;
|
||||||
void SetBindState(u32 index, float value) override;
|
void SetBindState(u32 index, float value) override;
|
||||||
u32 GetButtonStateBits() const override;
|
u32 GetButtonStateBits() const override;
|
||||||
std::optional<u32> GetAnalogInputBytes() const override;
|
std::optional<u32> GetAnalogInputBytes() const override;
|
||||||
|
@ -90,6 +90,11 @@ u32 Controller::GetButtonStateBits() const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Controller::GetVibrationMotorState(u32 index) const
|
||||||
|
{
|
||||||
|
return 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
bool Controller::InAnalogMode() const
|
bool Controller::InAnalogMode() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -78,6 +78,9 @@ public:
|
|||||||
/// Returns a bitmask of the current button states, 1 = on.
|
/// Returns a bitmask of the current button states, 1 = on.
|
||||||
virtual u32 GetButtonStateBits() const;
|
virtual u32 GetButtonStateBits() const;
|
||||||
|
|
||||||
|
/// Returns the current state of the specified vibration motor.
|
||||||
|
virtual float GetVibrationMotorState(u32 index) const;
|
||||||
|
|
||||||
/// Returns true if the controller supports analog mode, and it is active.
|
/// Returns true if the controller supports analog mode, and it is active.
|
||||||
virtual bool InAnalogMode() const;
|
virtual bool InAnalogMode() const;
|
||||||
|
|
||||||
|
@ -96,6 +96,11 @@ float JogCon::GetBindState(u32 index) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float JogCon::GetVibrationMotorState(u32 index) const
|
||||||
|
{
|
||||||
|
return (index == 0) ? m_last_strength : 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
void JogCon::SetBindState(u32 index, float value)
|
void JogCon::SetBindState(u32 index, float value)
|
||||||
{
|
{
|
||||||
if (index == static_cast<u32>(Button::Mode))
|
if (index == static_cast<u32>(Button::Mode))
|
||||||
@ -275,7 +280,13 @@ void JogCon::SetMotorDirection(u8 direction_command, u8 strength)
|
|||||||
DEV_LOG("Stop motor");
|
DEV_LOG("Stop motor");
|
||||||
if (m_force_feedback_device)
|
if (m_force_feedback_device)
|
||||||
m_force_feedback_device->DisableForce(ForceFeedbackDevice::Effect::Constant);
|
m_force_feedback_device->DisableForce(ForceFeedbackDevice::Effect::Constant);
|
||||||
|
|
||||||
|
if (m_last_strength != 0.0f)
|
||||||
|
{
|
||||||
|
m_last_strength = 0.0f;
|
||||||
InputManager::SetPadVibrationIntensity(m_index, 0.0f, 0.0f);
|
InputManager::SetPadVibrationIntensity(m_index, 0.0f, 0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,8 +301,12 @@ void JogCon::SetMotorDirection(u8 direction_command, u8 strength)
|
|||||||
m_force_feedback_device->SetConstantForce(ffb_value);
|
m_force_feedback_device->SetConstantForce(ffb_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (f_strength != m_last_strength)
|
||||||
|
{
|
||||||
|
m_last_strength = f_strength;
|
||||||
InputManager::SetPadVibrationIntensity(m_index, f_strength, 0.0f);
|
InputManager::SetPadVibrationIntensity(m_index, f_strength, 0.0f);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void JogCon::UpdateSteeringHold()
|
void JogCon::UpdateSteeringHold()
|
||||||
{
|
{
|
||||||
|
@ -54,6 +54,7 @@ public:
|
|||||||
bool DoState(StateWrapper& sw, bool apply_input_state) override;
|
bool DoState(StateWrapper& sw, bool apply_input_state) override;
|
||||||
|
|
||||||
float GetBindState(u32 index) const override;
|
float GetBindState(u32 index) const override;
|
||||||
|
float GetVibrationMotorState(u32 index) const override;
|
||||||
void SetBindState(u32 index, float value) override;
|
void SetBindState(u32 index, float value) override;
|
||||||
u32 GetButtonStateBits() const override;
|
u32 GetButtonStateBits() const override;
|
||||||
u32 GetInputOverlayIconColor() const override;
|
u32 GetInputOverlayIconColor() const override;
|
||||||
@ -146,6 +147,9 @@ private:
|
|||||||
float m_analog_sensitivity = 1.33f;
|
float m_analog_sensitivity = 1.33f;
|
||||||
float m_button_deadzone = 0.0f;
|
float m_button_deadzone = 0.0f;
|
||||||
|
|
||||||
std::string m_force_feedback_device_name;
|
float m_last_strength = 0.0f;
|
||||||
|
|
||||||
std::unique_ptr<ForceFeedbackDevice> m_force_feedback_device;
|
std::unique_ptr<ForceFeedbackDevice> m_force_feedback_device;
|
||||||
|
|
||||||
|
std::string m_force_feedback_device_name;
|
||||||
};
|
};
|
||||||
|
@ -141,6 +141,11 @@ float NeGconRumble::GetBindState(u32 index) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float NeGconRumble::GetVibrationMotorState(u32 index) const
|
||||||
|
{
|
||||||
|
return ((index < m_motor_state.size()) ? m_motor_state[index] : 0) * (1.0f / 255.0f);
|
||||||
|
}
|
||||||
|
|
||||||
void NeGconRumble::SetBindState(u32 index, float value)
|
void NeGconRumble::SetBindState(u32 index, float value)
|
||||||
{
|
{
|
||||||
if (index == static_cast<s32>(Button::Analog))
|
if (index == static_cast<s32>(Button::Analog))
|
||||||
|
@ -61,6 +61,7 @@ public:
|
|||||||
bool DoState(StateWrapper& sw, bool apply_input_state) override;
|
bool DoState(StateWrapper& sw, bool apply_input_state) override;
|
||||||
|
|
||||||
float GetBindState(u32 index) const override;
|
float GetBindState(u32 index) const override;
|
||||||
|
float GetVibrationMotorState(u32 index) const override;
|
||||||
void SetBindState(u32 index, float value) override;
|
void SetBindState(u32 index, float value) override;
|
||||||
|
|
||||||
void ResetTransferState() override;
|
void ResetTransferState() override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user