Skip to content
Permalink
Browse files
Merge pull request #7644 from jordan-woyak/dk-bongos-fix
HW: DK Bongos clap fix and cleanup
  • Loading branch information
lioncash committed Dec 28, 2018
2 parents 2d37944 + 56256d8 commit dd1fc70
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 14 deletions.
@@ -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];
@@ -17,5 +17,10 @@ class CSIDevice_GCAdapter : public CSIDevice_GCController

GCPadStatus GetPadStatus() override;
int RunBuffer(u8* buffer, int length) override;

bool GetData(u32& hi, u32& low) override;

private:
bool m_simulate_konga{};
};
} // namespace SerialInterface
@@ -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
@@ -83,9 +83,6 @@ class CSIDevice_GCController : public ISIDevice
// 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 @@ class CSIDevice_GCController : public ISIDevice
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

0 comments on commit dd1fc70

Please sign in to comment.