From 31b41b9ec0daf5d44f9bb27551179921cc0a22f0 Mon Sep 17 00:00:00 2001 From: Albert Liu <45282415+ggrtk@users.noreply.github.com> Date: Wed, 25 Nov 2020 06:20:12 -0800 Subject: [PATCH] AnalogController: Output zeros for 0x43 when already in config mode --- src/core/analog_controller.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/analog_controller.cpp b/src/core/analog_controller.cpp index 135cfdc2e..d7c7ad0a3 100644 --- a/src/core/analog_controller.cpp +++ b/src/core/analog_controller.cpp @@ -350,10 +350,12 @@ bool AnalogController::Transfer(const u8 data_in, u8* data_out) case State::ConfigModeSetMode: { + // If 0x43 "enter/leave config mode" is called from within config mode, return all zeros Log_DebugPrintf("0x%02x(%s) config mode", data_in, data_in == 1 ? "enter" : "leave"); + bool prev_configuration_mode = m_configuration_mode; m_configuration_mode = (data_in == 1); - *data_out = Truncate8(m_button_state); - m_state = State::GetStateButtonsMSB; + *data_out = prev_configuration_mode ? 0x00 : Truncate8(m_button_state); + m_state = prev_configuration_mode ? State::Pad5Bytes : State::GetStateButtonsMSB; ack = true; } break;