AnalogController: Use range for large motor, add bias

Seems the bias is needed for FF8.
This commit is contained in:
Connor McLaughlin 2020-09-17 19:56:26 +10:00
parent 67d0bbedb1
commit debfd53618
2 changed files with 16 additions and 4 deletions

View file

@ -138,7 +138,12 @@ u32 AnalogController::GetVibrationMotorCount() const
float AnalogController::GetVibrationMotorStrength(u32 motor) float AnalogController::GetVibrationMotorStrength(u32 motor)
{ {
DebugAssert(motor < NUM_MOTORS); DebugAssert(motor < NUM_MOTORS);
return static_cast<float>(m_motor_state[motor]) * (1.0f / 255.0f); if (m_motor_state[motor] == 0)
return 0.0f;
return static_cast<float>(
std::min<u32>(static_cast<u32>(m_motor_state[motor]) + static_cast<u32>(m_rumble_bias), 255)) /
255.0f;
} }
void AnalogController::ResetTransferState() void AnalogController::ResetTransferState()
@ -282,7 +287,7 @@ bool AnalogController::Transfer(const u8 data_in, u8* data_out)
case State::GetStateButtonsMSB: case State::GetStateButtonsMSB:
{ {
if (m_rumble_unlocked) if (m_rumble_unlocked)
SetMotorState(0, (data_in != 0) ? 255 : 0); SetMotorState(0, data_in);
*data_out = Truncate8(m_button_state >> 8); *data_out = Truncate8(m_button_state >> 8);
m_state = m_analog_mode ? State::GetStateRightAxisX : State::Idle; m_state = m_analog_mode ? State::GetStateRightAxisX : State::Idle;
@ -500,7 +505,7 @@ u32 AnalogController::StaticGetVibrationMotorCount()
Controller::SettingList AnalogController::StaticGetSettings() Controller::SettingList AnalogController::StaticGetSettings()
{ {
static constexpr std::array<SettingInfo, 2> settings = { static constexpr std::array<SettingInfo, 3> settings = {
{{SettingInfo::Type::Boolean, "AutoEnableAnalog", TRANSLATABLE("AnalogController", "Enable Analog Mode on Reset"), {{SettingInfo::Type::Boolean, "AutoEnableAnalog", TRANSLATABLE("AnalogController", "Enable Analog Mode on Reset"),
TRANSLATABLE("AnalogController", "Automatically enables analog mode when the console is reset/powered on."), TRANSLATABLE("AnalogController", "Automatically enables analog mode when the console is reset/powered on."),
"false"}, "false"},
@ -509,7 +514,11 @@ Controller::SettingList AnalogController::StaticGetSettings()
"AnalogController", "AnalogController",
"Sets the analog stick axis scaling factor. A value between 1.30 and 1.40 is recommended when using recent " "Sets the analog stick axis scaling factor. A value between 1.30 and 1.40 is recommended when using recent "
"controllers, e.g. DualShock 4, Xbox One Controller."), "controllers, e.g. DualShock 4, Xbox One Controller."),
"1.00f", "0.01f", "1.50f", "0.01f"}}}; "1.00f", "0.01f", "1.50f", "0.01f"},
{SettingInfo::Type::Integer, "VibrationBias", TRANSLATABLE("AnalogController", "Vibration Bias"),
TRANSLATABLE("AnalogController", "Sets the rumble bias value. If rumble in some games is too weak or not "
"functioning, try increasing this value."),
"8", "0", "255", "1"}}};
return SettingList(settings.begin(), settings.end()); return SettingList(settings.begin(), settings.end());
} }
@ -518,4 +527,6 @@ void AnalogController::LoadSettings(const char* section)
{ {
Controller::LoadSettings(section); Controller::LoadSettings(section);
m_auto_enable_analog = g_host_interface->GetBoolSettingValue(section, "AutoEnableAnalog", false); m_auto_enable_analog = g_host_interface->GetBoolSettingValue(section, "AutoEnableAnalog", false);
m_rumble_bias =
static_cast<u8>(std::min<u32>(g_host_interface->GetIntSettingValue(section, "VibrationBias", false), 255));
} }

View file

@ -135,6 +135,7 @@ private:
u32 m_index; u32 m_index;
bool m_auto_enable_analog = false; bool m_auto_enable_analog = false;
u8 m_rumble_bias = 8;
bool m_analog_mode = false; bool m_analog_mode = false;
bool m_analog_locked = false; bool m_analog_locked = false;