Merge branch 'TaruKonga'

The DK Bongos are just a standard controller in disguise (ie, it uses your GCPad input mapping):
Clap Sensor = Analog R Trigger
start = start
Top of Left Bongo = Y Button
Bottom of Left Bongo = B Button
Top of Right Bongo = X Button
Bottom of Right Bongo = A Button
This commit is contained in:
Shawn Hoffman 2011-10-23 13:37:10 -07:00
commit 7bac36d455
13 changed files with 114 additions and 87 deletions

View File

@ -366,7 +366,7 @@ void SConfig::LoadSettings()
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
{ {
sprintf(sidevicenum, "SIDevice%i", i); sprintf(sidevicenum, "SIDevice%i", i);
ini.Get("Core", sidevicenum, (u32*)&m_SIDevice[i], i==0 ? SI_GC_CONTROLLER:SI_NONE); ini.Get("Core", sidevicenum, (u32*)&m_SIDevice[i], (i == 0) ? SIDEVICE_GC_CONTROLLER : SIDEVICE_NONE);
} }
ini.Get("Core", "WiiSDCard", &m_WiiSDCard, false); ini.Get("Core", "WiiSDCard", &m_WiiSDCard, false);

View File

@ -52,7 +52,7 @@ struct SConfig : NonCopyable
//this is necessary to save after loading a savestate //this is necessary to save after loading a savestate
bool b_reloadMCOnState; bool b_reloadMCOnState;
TEXIDevices m_EXIDevice[3]; TEXIDevices m_EXIDevice[3];
TSIDevices m_SIDevice[4]; SIDevices m_SIDevice[4];
std::string m_bba_mac; std::string m_bba_mac;
// interface language // interface language

View File

@ -522,7 +522,7 @@ void GenerateDIInterrupt(DI_InterruptType _DVDInterrupt)
void ExecuteCommand(UDICR& _DICR) void ExecuteCommand(UDICR& _DICR)
{ {
// _dbg_assert_(DVDINTERFACE, _DICR.RW == 0); // only DVD to Memory // _dbg_assert_(DVDINTERFACE, _DICR.RW == 0); // only DVD to Memory
int GCAM = ((SConfig::GetInstance().m_SIDevice[0] == SI_AM_BASEBOARD) int GCAM = ((SConfig::GetInstance().m_SIDevice[0] == SIDEVICE_AM_BASEBOARD)
&& (SConfig::GetInstance().m_EXIDevice[2] == EXIDEVICE_AM_BASEBOARD)) && (SConfig::GetInstance().m_EXIDevice[2] == EXIDEVICE_AM_BASEBOARD))
? 1 : 0; ? 1 : 0;

View File

@ -62,8 +62,6 @@ void GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
{ {
memset(_pPADStatus, 0, sizeof(*_pPADStatus)); memset(_pPADStatus, 0, sizeof(*_pPADStatus));
_pPADStatus->err = PAD_ERR_NONE; _pPADStatus->err = PAD_ERR_NONE;
// wtf is this?
_pPADStatus->button = PAD_USE_ORIGIN;
std::unique_lock<std::recursive_mutex> lk(g_plugin.controls_lock, std::try_to_lock); std::unique_lock<std::recursive_mutex> lk(g_plugin.controls_lock, std::try_to_lock);

View File

@ -247,9 +247,9 @@ void Init()
g_Channel[i].m_InLo.Hex = 0; g_Channel[i].m_InLo.Hex = 0;
if (Movie::IsUsingPad(i)) if (Movie::IsUsingPad(i))
AddDevice(SI_GC_CONTROLLER, i); AddDevice(SIDEVICE_GC_CONTROLLER, i);
else if (Movie::IsRecordingInput() || Movie::IsPlayingInput()) else if (Movie::IsRecordingInput() || Movie::IsPlayingInput())
AddDevice(SI_NONE, i); AddDevice(SIDEVICE_NONE, i);
else else
AddDevice(SConfig::GetInstance().m_SIDevice[i], i); AddDevice(SConfig::GetInstance().m_SIDevice[i], i);
} }
@ -538,7 +538,7 @@ void RemoveDevice(int _iDeviceNumber)
g_Channel[_iDeviceNumber].m_pDevice = NULL; g_Channel[_iDeviceNumber].m_pDevice = NULL;
} }
void AddDevice(const TSIDevices _device, int _iDeviceNumber) void AddDevice(const SIDevices _device, int _iDeviceNumber)
{ {
//_dbg_assert_(SERIALINTERFACE, _iDeviceNumber < NUMBER_OF_CHANNELS); //_dbg_assert_(SERIALINTERFACE, _iDeviceNumber < NUMBER_OF_CHANNELS);
@ -572,14 +572,14 @@ void ChangeDeviceCallback(u64 userdata, int cyclesLate)
SetNoResponse(channel); SetNoResponse(channel);
AddDevice((TSIDevices)(u32)userdata, channel); AddDevice((SIDevices)(u32)userdata, channel);
} }
void ChangeDevice(TSIDevices device, int channel) void ChangeDevice(SIDevices device, int channel)
{ {
// Called from GUI, so we need to make it thread safe. // Called from GUI, so we need to make it thread safe.
// Let the hardware see no device for .5b cycles // Let the hardware see no device for .5b cycles
CoreTiming::ScheduleEvent_Threadsafe(0, changeDevice, ((u64)channel << 32) | SI_NONE); CoreTiming::ScheduleEvent_Threadsafe(0, changeDevice, ((u64)channel << 32) | SIDEVICE_NONE);
CoreTiming::ScheduleEvent_Threadsafe(500000000, changeDevice, ((u64)channel << 32) | device); CoreTiming::ScheduleEvent_Threadsafe(500000000, changeDevice, ((u64)channel << 32) | device);
} }

View File

@ -31,10 +31,10 @@ void DoState(PointerWrap &p);
void UpdateDevices(); void UpdateDevices();
void RemoveDevice(int _iDeviceNumber); void RemoveDevice(int _iDeviceNumber);
void AddDevice(const TSIDevices _device, int _iDeviceNumber); void AddDevice(const SIDevices _device, int _iDeviceNumber);
void ChangeDeviceCallback(u64 userdata, int cyclesLate); void ChangeDeviceCallback(u64 userdata, int cyclesLate);
void ChangeDevice(TSIDevices device, int channel); void ChangeDevice(SIDevices device, int channel);
void Read32(u32& _uReturnValue, const u32 _iAddress); void Read32(u32& _uReturnValue, const u32 _iAddress);
void Write32(const u32 _iValue, const u32 _iAddress); void Write32(const u32 _iValue, const u32 _iAddress);

View File

@ -68,25 +68,29 @@ public:
// F A C T O R Y // F A C T O R Y
ISIDevice* SIDevice_Create(TSIDevices _SIDevice, int _iDeviceNumber) ISIDevice* SIDevice_Create(const SIDevices device, const int port_number)
{ {
switch(_SIDevice) switch (device)
{ {
case SI_GC_CONTROLLER: case SIDEVICE_GC_CONTROLLER:
return new CSIDevice_GCController(_iDeviceNumber); return new CSIDevice_GCController(port_number);
break; break;
case SI_GBA: case SIDEVICE_GC_TARUKONGA:
return new CSIDevice_GBA(_iDeviceNumber); return new CSIDevice_TaruKonga(port_number);
break; break;
case SI_AM_BASEBOARD: case SIDEVICE_GC_GBA:
return new CSIDevice_AMBaseboard(_iDeviceNumber); return new CSIDevice_GBA(port_number);
break; break;
case SI_NONE: case SIDEVICE_AM_BASEBOARD:
return new CSIDevice_AMBaseboard(port_number);
break;
case SIDEVICE_NONE:
default: default:
return new CSIDevice_Null(_iDeviceNumber); return new CSIDevice_Null(port_number);
break; break;
} }
} }

View File

@ -57,7 +57,7 @@ public:
virtual void SendCommand(u32 _Cmd, u8 _Poll) = 0; virtual void SendCommand(u32 _Cmd, u8 _Poll) = 0;
}; };
// SI Device IDs // SI Device IDs for emulator use
enum TSIDevices enum TSIDevices
{ {
SI_NONE = SI_ERROR_NO_RESPONSE, SI_NONE = SI_ERROR_NO_RESPONSE,
@ -72,6 +72,22 @@ enum TSIDevices
SI_AM_BASEBOARD = 0x10110800 // gets ORd with dipswitch state SI_AM_BASEBOARD = 0x10110800 // gets ORd with dipswitch state
}; };
extern ISIDevice* SIDevice_Create(TSIDevices _SIDevice, int _iDeviceNumber); // For configuration use, since some devices can have the same SI Device ID
enum SIDevices
{
SIDEVICE_NONE,
SIDEVICE_N64_MIC,
SIDEVICE_N64_KEYBOARD,
SIDEVICE_N64_MOUSE,
SIDEVICE_N64_CONTROLLER,
SIDEVICE_GC_GBA,
SIDEVICE_GC_CONTROLLER,
SIDEVICE_GC_KEYBOARD,
SIDEVICE_GC_STEERING,
SIDEVICE_GC_TARUKONGA,
SIDEVICE_AM_BASEBOARD
};
extern ISIDevice* SIDevice_Create(const SIDevices device, const int port_number);
#endif #endif

View File

@ -59,60 +59,49 @@ int CSIDevice_GCController::RunBuffer(u8* _pBuffer, int _iLength)
// For debug logging only // For debug logging only
ISIDevice::RunBuffer(_pBuffer, _iLength); ISIDevice::RunBuffer(_pBuffer, _iLength);
int iPosition = 0; // Read the command
while (iPosition < _iLength) EBufferCommands command = static_cast<EBufferCommands>(_pBuffer[3]);
// Handle it
switch (command)
{ {
// Read the command case CMD_RESET:
EBufferCommands command = static_cast<EBufferCommands>(_pBuffer[iPosition ^ 3]); *(u32*)&_pBuffer[0] = SI_GC_CONTROLLER;
iPosition++; break;
// Handle it case CMD_ORIGIN:
switch (command)
{ {
case CMD_RESET: INFO_LOG(SERIALINTERFACE, "PAD - Get Origin");
u8* pCalibration = reinterpret_cast<u8*>(&m_Origin);
for (int i = 0; i < (int)sizeof(SOrigin); i++)
{ {
*(u32*)&_pBuffer[0] = SI_GC_CONTROLLER; _pBuffer[i ^ 3] = *pCalibration++;
iPosition = _iLength; // Break the while loop
} }
break;
case CMD_ORIGIN:
{
INFO_LOG(SERIALINTERFACE, "PAD - Get Origin");
u8* pCalibration = reinterpret_cast<u8*>(&m_Origin);
for (int i = 0; i < (int)sizeof(SOrigin); i++)
{
_pBuffer[i ^ 3] = *pCalibration++;
}
}
iPosition = _iLength;
break;
// Recalibrate (FiRES: i am not 100 percent sure about this)
case CMD_RECALIBRATE:
{
INFO_LOG(SERIALINTERFACE, "PAD - Recalibrate");
u8* pCalibration = reinterpret_cast<u8*>(&m_Origin);
for (int i = 0; i < (int)sizeof(SOrigin); i++)
{
_pBuffer[i ^ 3] = *pCalibration++;
}
}
iPosition = _iLength;
break;
// DEFAULT
default:
{
ERROR_LOG(SERIALINTERFACE, "unknown SI command (0x%x)", command);
PanicAlert("SI: Unknown command");
iPosition = _iLength;
}
break;
} }
break;
// Recalibrate (FiRES: i am not 100 percent sure about this)
case CMD_RECALIBRATE:
{
INFO_LOG(SERIALINTERFACE, "PAD - Recalibrate");
u8* pCalibration = reinterpret_cast<u8*>(&m_Origin);
for (int i = 0; i < (int)sizeof(SOrigin); i++)
{
_pBuffer[i ^ 3] = *pCalibration++;
}
}
break;
// DEFAULT
default:
{
ERROR_LOG(SERIALINTERFACE, "unknown SI command (0x%x)", command);
PanicAlert("SI: Unknown command");
}
break;
} }
return iPosition; return _iLength;
} }
@ -156,9 +145,7 @@ bool CSIDevice_GCController::GetData(u32& _Hi, u32& _Low)
// Thankfully changing mode does not change the high bits ;) // Thankfully changing mode does not change the high bits ;)
_Hi = (u32)((u8)PadStatus.stickY); _Hi = (u32)((u8)PadStatus.stickY);
_Hi |= (u32)((u8)PadStatus.stickX << 8); _Hi |= (u32)((u8)PadStatus.stickX << 8);
_Hi |= (u32)((u16)PadStatus.button << 16); _Hi |= (u32)((u16)(PadStatus.button | PAD_USE_ORIGIN) << 16);
_Hi |= 0x00800000; // F|RES: means that the pad must be "combined" with the origin to match the "final" OSPad-Struct
//_Hi |= 0x20000000; // ?
// Low bits are packed differently per mode // Low bits are packed differently per mode
if (m_Mode == 0 || m_Mode == 5 || m_Mode == 6 || m_Mode == 7) if (m_Mode == 0 || m_Mode == 5 || m_Mode == 6 || m_Mode == 7)

View File

@ -30,7 +30,6 @@ private:
// Commands // Commands
enum EBufferCommands enum EBufferCommands
{ {
CMD_INVALID = 0xFFFFFFFF,
CMD_RESET = 0x00, CMD_RESET = 0x00,
CMD_ORIGIN = 0x41, CMD_ORIGIN = 0x41,
CMD_RECALIBRATE = 0x42, CMD_RECALIBRATE = 0x42,
@ -111,4 +110,20 @@ public:
// Send a command directly // Send a command directly
virtual void SendCommand(u32 _Cmd, u8 _Poll); virtual void SendCommand(u32 _Cmd, u8 _Poll);
}; };
// "TaruKonga", the DK Bongo controller
class CSIDevice_TaruKonga : public CSIDevice_GCController
{
public:
CSIDevice_TaruKonga(int _iDeviceNumber) : CSIDevice_GCController(_iDeviceNumber) { }
virtual bool GetData(u32& _Hi, u32& _Low)
{
CSIDevice_GCController::GetData(_Hi, _Low);
_Hi &= ~PAD_USE_ORIGIN << 16;
return true;
}
};
#endif #endif

View File

@ -181,7 +181,7 @@ void ChangePads(bool instantly)
int controllers = 0; int controllers = 0;
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
if (SConfig::GetInstance().m_SIDevice[i] == SI_GC_CONTROLLER) if (SConfig::GetInstance().m_SIDevice[i] == SIDEVICE_GC_CONTROLLER)
controllers |= (1 << i); controllers |= (1 << i);
if (instantly && (g_numPads & 0x0F) == controllers) if (instantly && (g_numPads & 0x0F) == controllers)
@ -189,9 +189,9 @@ void ChangePads(bool instantly)
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
if (instantly) // Changes from savestates need to be instantaneous if (instantly) // Changes from savestates need to be instantaneous
SerialInterface::AddDevice(IsUsingPad(i) ? SI_GC_CONTROLLER : SI_NONE, i); SerialInterface::AddDevice(IsUsingPad(i) ? SIDEVICE_GC_CONTROLLER : SIDEVICE_NONE, i);
else else
SerialInterface::ChangeDevice(IsUsingPad(i) ? SI_GC_CONTROLLER : SI_NONE, i); SerialInterface::ChangeDevice(IsUsingPad(i) ? SIDEVICE_GC_CONTROLLER : SIDEVICE_NONE, i);
} }
void ChangeWiiPads(bool instantly) void ChangeWiiPads(bool instantly)

View File

@ -78,6 +78,7 @@ static const wxLanguage langIds[] =
#define DEV_DUMMY_STR _trans("Dummy") #define DEV_DUMMY_STR _trans("Dummy")
#define SIDEV_STDCONT_STR _trans("Standard Controller") #define SIDEV_STDCONT_STR _trans("Standard Controller")
#define SIDEV_BONGO_STR _trans("TaruKonga (Bongos)")
#define SIDEV_GBA_STR "GBA" #define SIDEV_GBA_STR "GBA"
#define SIDEV_AM_BB_STR _trans("AM-Baseboard") #define SIDEV_AM_BB_STR _trans("AM-Baseboard")
@ -388,6 +389,7 @@ void CConfigMain::InitializeGUIValues()
wxArrayString SIDevices; wxArrayString SIDevices;
SIDevices.Add(_(DEV_NONE_STR)); SIDevices.Add(_(DEV_NONE_STR));
SIDevices.Add(_(SIDEV_STDCONT_STR)); SIDevices.Add(_(SIDEV_STDCONT_STR));
SIDevices.Add(_(SIDEV_BONGO_STR));
SIDevices.Add(_(SIDEV_GBA_STR)); SIDevices.Add(_(SIDEV_GBA_STR));
SIDevices.Add(_(SIDEV_AM_BB_STR)); SIDevices.Add(_(SIDEV_AM_BB_STR));
@ -436,15 +438,18 @@ void CConfigMain::InitializeGUIValues()
switch (SConfig::GetInstance().m_SIDevice[i]) switch (SConfig::GetInstance().m_SIDevice[i])
{ {
case SI_GC_CONTROLLER: case SIDEVICE_GC_CONTROLLER:
GCSIDevice[i]->SetStringSelection(SIDevices[1]); GCSIDevice[i]->SetStringSelection(SIDevices[1]);
break; break;
case SI_GBA: case SIDEVICE_GC_TARUKONGA:
GCSIDevice[i]->SetStringSelection(SIDevices[2]); GCSIDevice[i]->SetStringSelection(SIDevices[2]);
break; break;
case SI_AM_BASEBOARD: case SIDEVICE_GC_GBA:
GCSIDevice[i]->SetStringSelection(SIDevices[3]); GCSIDevice[i]->SetStringSelection(SIDevices[3]);
break; break;
case SIDEVICE_AM_BASEBOARD:
GCSIDevice[i]->SetStringSelection(SIDevices[4]);
break;
default: default:
GCSIDevice[i]->SetStringSelection(SIDevices[0]); GCSIDevice[i]->SetStringSelection(SIDevices[0]);
break; break;
@ -1043,15 +1048,17 @@ void CConfigMain::ChooseMemcardPath(std::string& strMemcard, bool isSlotA)
void CConfigMain::ChooseSIDevice(std::string deviceName, int deviceNum) void CConfigMain::ChooseSIDevice(std::string deviceName, int deviceNum)
{ {
TSIDevices tempType; SIDevices tempType;
if (!deviceName.compare(CSTR_TRANS(SIDEV_STDCONT_STR))) if (!deviceName.compare(CSTR_TRANS(SIDEV_STDCONT_STR)))
tempType = SI_GC_CONTROLLER; tempType = SIDEVICE_GC_CONTROLLER;
else if (!deviceName.compare(CSTR_TRANS(SIDEV_BONGO_STR)))
tempType = SIDEVICE_GC_TARUKONGA;
else if (!deviceName.compare(SIDEV_GBA_STR)) else if (!deviceName.compare(SIDEV_GBA_STR))
tempType = SI_GBA; tempType = SIDEVICE_GC_GBA;
else if (!deviceName.compare(CSTR_TRANS(SIDEV_AM_BB_STR))) else if (!deviceName.compare(CSTR_TRANS(SIDEV_AM_BB_STR)))
tempType = SI_AM_BASEBOARD; tempType = SIDEVICE_AM_BASEBOARD;
else else
tempType = SI_NONE; tempType = SIDEVICE_NONE;
SConfig::GetInstance().m_SIDevice[deviceNum] = tempType; SConfig::GetInstance().m_SIDevice[deviceNum] = tempType;

View File

@ -723,7 +723,7 @@ void CFrame::OnRecord(wxCommandEvent& WXUNUSED (event))
} }
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
if (SConfig::GetInstance().m_SIDevice[i] == SI_GC_CONTROLLER) if (SConfig::GetInstance().m_SIDevice[i] == SIDEVICE_GC_CONTROLLER)
controllers |= (1 << i); controllers |= (1 << i);
if (g_wiimote_sources[i] != WIIMOTE_SRC_NONE) if (g_wiimote_sources[i] != WIIMOTE_SRC_NONE)