AnalogController: Delay manual mode toggle to transfer state reset

This commit is contained in:
Albert Liu 2020-11-23 17:35:34 -08:00
parent ade61d6139
commit e4820bcbc1
2 changed files with 22 additions and 16 deletions

View File

@ -102,22 +102,7 @@ void AnalogController::SetButtonState(Button button, bool pressed)
{
// analog toggle
if (pressed)
{
if (m_analog_locked)
{
g_host_interface->AddFormattedOSDMessage(
5.0f,
m_analog_mode ? g_host_interface->TranslateString("AnalogController",
"Controller %u is locked to analog mode by the game.") :
g_host_interface->TranslateString("AnalogController",
"Controller %u is locked to digital mode by the game."),
m_index + 1u);
}
else
{
SetAnalogMode(!m_analog_mode);
}
}
m_analog_toggle_queued = true;
return;
}
@ -158,6 +143,25 @@ float AnalogController::GetVibrationMotorStrength(u32 motor)
void AnalogController::ResetTransferState()
{
if (m_analog_toggle_queued)
{
if (m_analog_locked)
{
g_host_interface->AddFormattedOSDMessage(
5.0f,
m_analog_mode ?
g_host_interface->TranslateString("AnalogController", "Controller %u is locked to analog mode by the game.") :
g_host_interface->TranslateString("AnalogController", "Controller %u is locked to digital mode by the game."),
m_index + 1u);
}
else
{
SetAnalogMode(!m_analog_mode);
}
m_analog_toggle_queued = false;
}
m_state = State::Idle;
}

View File

@ -149,6 +149,8 @@ private:
std::array<u8, static_cast<u8>(Axis::Count)> m_axis_state{};
bool m_analog_toggle_queued = false;
// buttons are active low
u16 m_button_state = UINT16_C(0xFFFF);