From 56256d862493a83e5f7de2d1e2b313ac2a80dd3e Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Tue, 25 Dec 2018 11:24:09 -0600 Subject: [PATCH] HW: DK Bongos clap fix and cleanup --- Source/Core/Core/HW/SI/SI_DeviceGCAdapter.cpp | 12 ++++++++++ Source/Core/Core/HW/SI/SI_DeviceGCAdapter.h | 5 ++++ .../Core/Core/HW/SI/SI_DeviceGCController.cpp | 23 ++++++++++++++----- .../Core/Core/HW/SI/SI_DeviceGCController.h | 14 +++++------ 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/Source/Core/Core/HW/SI/SI_DeviceGCAdapter.cpp b/Source/Core/Core/HW/SI/SI_DeviceGCAdapter.cpp index a199e98a1b..0650a7c504 100644 --- a/Source/Core/Core/HW/SI/SI_DeviceGCAdapter.cpp +++ b/Source/Core/Core/HW/SI/SI_DeviceGCAdapter.cpp @@ -60,6 +60,18 @@ int CSIDevice_GCAdapter::RunBuffer(u8* buffer, int length) return CSIDevice_GCController::RunBuffer(buffer, length); } +bool CSIDevice_GCAdapter::GetData(u32& hi, u32& low) +{ + CSIDevice_GCController::GetData(hi, low); + + if (m_simulate_konga) + { + hi &= CSIDevice_TaruKonga::BUTTON_MASK; + } + + return true; +} + void CSIDevice_GCController::Rumble(int pad_num, ControlState strength) { SIDevices device = SConfig::GetInstance().m_SIDevice[pad_num]; diff --git a/Source/Core/Core/HW/SI/SI_DeviceGCAdapter.h b/Source/Core/Core/HW/SI/SI_DeviceGCAdapter.h index 30e464dee0..aa34ff5d84 100644 --- a/Source/Core/Core/HW/SI/SI_DeviceGCAdapter.h +++ b/Source/Core/Core/HW/SI/SI_DeviceGCAdapter.h @@ -17,5 +17,10 @@ public: GCPadStatus GetPadStatus() override; int RunBuffer(u8* buffer, int length) override; + + bool GetData(u32& hi, u32& low) override; + +private: + bool m_simulate_konga{}; }; } // namespace SerialInterface diff --git a/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp b/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp index e9adac7e5b..994b068a1d 100644 --- a/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp +++ b/Source/Core/Core/HW/SI/SI_DeviceGCController.cpp @@ -231,12 +231,6 @@ bool CSIDevice_GCController::GetData(u32& hi, u32& low) low |= pad_status.substickX << 24; // All 8 bits } - // Unset all bits except those that represent - // A, B, X, Y, Start and the error bits, as they - // are not used. - if (m_simulate_konga) - hi &= ~0x20FFFFFF; - return true; } @@ -349,4 +343,21 @@ void CSIDevice_GCController::DoState(PointerWrap& p) p.Do(m_timer_button_combo); p.Do(m_last_button_combo); } + +CSIDevice_TaruKonga::CSIDevice_TaruKonga(SIDevices device, int device_number) + : CSIDevice_GCController(device, device_number) +{ +} + +bool CSIDevice_TaruKonga::GetData(u32& hi, u32& low) +{ + CSIDevice_GCController::GetData(hi, low); + + // Unsets the first 16 bits (StickX/Y), PAD_USE_ORIGIN, + // and all buttons except: A, B, X, Y, Start, R + hi &= BUTTON_MASK; + + return true; +} + } // namespace SerialInterface diff --git a/Source/Core/Core/HW/SI/SI_DeviceGCController.h b/Source/Core/Core/HW/SI/SI_DeviceGCController.h index 2732608f3e..87d6197819 100644 --- a/Source/Core/Core/HW/SI/SI_DeviceGCController.h +++ b/Source/Core/Core/HW/SI/SI_DeviceGCController.h @@ -83,9 +83,6 @@ protected: // Type of button combo from the last/current poll EButtonCombo m_last_button_combo = COMBO_NONE; - // Set this if we want to simulate the "TaruKonga" DK Bongo controller - bool m_simulate_konga = false; - public: // Constructor CSIDevice_GCController(SIDevices device, int device_number); @@ -122,10 +119,11 @@ protected: class CSIDevice_TaruKonga : public CSIDevice_GCController { public: - CSIDevice_TaruKonga(SIDevices device, int device_number) - : CSIDevice_GCController(device, device_number) - { - m_simulate_konga = true; - } + CSIDevice_TaruKonga(SIDevices device, int device_number); + + bool GetData(u32& hi, u32& low) override; + + static const u32 BUTTON_MASK = (PAD_BUTTON_A | PAD_BUTTON_B | PAD_BUTTON_X | PAD_BUTTON_Y | + PAD_BUTTON_START | PAD_TRIGGER_R); }; } // namespace SerialInterface