Merge pull request #1045 from ggrtk/analog-controller

AnalogController: Implement legacy rumble method
This commit is contained in:
Connor McLaughlin 2020-11-08 00:13:57 +10:00 committed by GitHub
commit 9cf38a5740
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -302,6 +302,10 @@ bool AnalogController::Transfer(const u8 data_in, u8* data_out)
{
if (m_rumble_unlocked)
SetMotorState(1, ((data_in & 0x01) != 0) ? 255 : 0);
else if (data_in >= 0x40 && data_in <= 0x7F)
m_legacy_rumble_unlocked = true;
else
SetMotorState(1, 0);
*data_out = Truncate8(m_button_state) & GetExtraButtonMaskLSB();
m_state = State::GetStateButtonsMSB;
@ -313,6 +317,11 @@ bool AnalogController::Transfer(const u8 data_in, u8* data_out)
{
if (m_rumble_unlocked)
SetMotorState(0, data_in);
else if (m_legacy_rumble_unlocked)
{
SetMotorState(1, ((data_in & 0x01) != 0) ? 255 : 0);
m_legacy_rumble_unlocked = false;
}
*data_out = Truncate8(m_button_state >> 8);
m_state = m_analog_mode ? State::GetStateRightAxisX : State::Idle;

View file

@ -142,6 +142,7 @@ private:
bool m_analog_mode = false;
bool m_analog_locked = false;
bool m_rumble_unlocked = false;
bool m_legacy_rumble_unlocked = false;
bool m_configuration_mode = false;
u8 m_command_param = 0;