Some cleanups to the internal Wiimote configuration handling. No functional change.
Patch by lpfaint99. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7691 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
986825124e
commit
c351743986
|
@ -26,9 +26,6 @@
|
|||
#include "../ConfigManager.h"
|
||||
#include "CoreTiming.h"
|
||||
|
||||
#define WIIMOTESIZE 0x46
|
||||
#define BTDINFSIZE WIIMOTESIZE * 0x10
|
||||
|
||||
// The device class
|
||||
CWII_IPC_HLE_Device_usb_oh1_57e_305::CWII_IPC_HLE_Device_usb_oh1_57e_305(u32 _DeviceID, const std::string& _rDeviceName)
|
||||
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
|
||||
|
@ -38,46 +35,42 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305::CWII_IPC_HLE_Device_usb_oh1_57e_305(u32 _De
|
|||
, m_last_ticks(0)
|
||||
{
|
||||
// Activate only first Wiimote by default
|
||||
|
||||
u8 BT_DINF[BTDINFSIZE];
|
||||
u8 maxWM = 0;
|
||||
if (!SConfig::GetInstance().m_SYSCONF->GetArrayData("BT.DINF", BT_DINF, BTDINFSIZE))
|
||||
|
||||
_conf_pads BT_DINF;
|
||||
|
||||
if (!SConfig::GetInstance().m_SYSCONF->GetArrayData("BT.DINF", (u8*)&BT_DINF, sizeof(_conf_pads)))
|
||||
{
|
||||
PanicAlertT("Trying to read from invalid SYSCONF\nWiimote bt ids are not available");
|
||||
}
|
||||
else
|
||||
{
|
||||
// BT_DINF first has num wiimotes at 0
|
||||
// 10 potential wiimotes 0x46 each from 1 - 0x2be
|
||||
// 4 currently connected wiimotes bt address only at 0x2bf-0x3d6 0x46 each
|
||||
// verified by http://devkitpro.svn.sourceforge.net/viewvc/devkitpro?view=revision&revision=3013
|
||||
maxWM = BT_DINF[0];
|
||||
u8 maxWM = min<u8>(BT_DINF.num_registered, CONF_PAD_MAX_ACTIVE);
|
||||
bdaddr_t tmpBD = BDADDR_ANY;
|
||||
u8 i = 0;
|
||||
while (i < maxWM)
|
||||
{
|
||||
tmpBD.b[5] = BT_DINF[1 + ((0xa+i) * WIIMOTESIZE)] = BT_DINF[1 + (i * WIIMOTESIZE)];
|
||||
tmpBD.b[4] = BT_DINF[2 + ((0xa+i) * WIIMOTESIZE)] = BT_DINF[2 + (i * WIIMOTESIZE)];
|
||||
tmpBD.b[3] = BT_DINF[3 + ((0xa+i) * WIIMOTESIZE)] = BT_DINF[3 + (i * WIIMOTESIZE)];
|
||||
tmpBD.b[2] = BT_DINF[4 + ((0xa+i) * WIIMOTESIZE)] = BT_DINF[4 + (i * WIIMOTESIZE)];
|
||||
tmpBD.b[1] = BT_DINF[5 + ((0xa+i) * WIIMOTESIZE)] = BT_DINF[5 + (i * WIIMOTESIZE)];
|
||||
tmpBD.b[0] = BT_DINF[6 + ((0xa+i) * WIIMOTESIZE)] = BT_DINF[6 + (i * WIIMOTESIZE)];
|
||||
tmpBD.b[5] = BT_DINF.active[i].bdaddr[0] = BT_DINF.registered[i].bdaddr[0];
|
||||
tmpBD.b[4] = BT_DINF.active[i].bdaddr[1] = BT_DINF.registered[i].bdaddr[1];
|
||||
tmpBD.b[3] = BT_DINF.active[i].bdaddr[2] = BT_DINF.registered[i].bdaddr[2];
|
||||
tmpBD.b[2] = BT_DINF.active[i].bdaddr[3] = BT_DINF.registered[i].bdaddr[3];
|
||||
tmpBD.b[1] = BT_DINF.active[i].bdaddr[4] = BT_DINF.registered[i].bdaddr[4];
|
||||
tmpBD.b[0] = BT_DINF.active[i].bdaddr[5] = BT_DINF.registered[i].bdaddr[5];
|
||||
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Wiimote %d BT ID %x,%x,%x,%x,%x,%x", i, tmpBD.b[0], tmpBD.b[1], tmpBD.b[2], tmpBD.b[3], tmpBD.b[4], tmpBD.b[5]);
|
||||
m_WiiMotes.push_back(CWII_IPC_HLE_WiiMote(this, i, tmpBD, false));
|
||||
i++;
|
||||
}
|
||||
while (i < 4)
|
||||
while (i < CONF_PAD_MAX_ACTIVE)
|
||||
{
|
||||
const char * wmName = "Nintendo RVL-CNT-01";
|
||||
BT_DINF[0] = 4;
|
||||
BT_DINF[1 + ((0xa+i) * WIIMOTESIZE)] = BT_DINF[1 + (i * WIIMOTESIZE)] = tmpBD.b[5] = i;
|
||||
BT_DINF[2 + ((0xa+i) * WIIMOTESIZE)] = BT_DINF[2 + (i * WIIMOTESIZE)] = tmpBD.b[4] = 0x00;
|
||||
BT_DINF[3 + ((0xa+i) * WIIMOTESIZE)] = BT_DINF[3 + (i * WIIMOTESIZE)] = tmpBD.b[3] = 0x79;
|
||||
BT_DINF[4 + ((0xa+i) * WIIMOTESIZE)] = BT_DINF[4 + (i * WIIMOTESIZE)] = tmpBD.b[2] = 0x19;
|
||||
BT_DINF[5 + ((0xa+i) * WIIMOTESIZE)] = BT_DINF[5 + (i * WIIMOTESIZE)] = tmpBD.b[1] = 0x02;
|
||||
BT_DINF[6 + ((0xa+i) * WIIMOTESIZE)] = BT_DINF[6 + (i * WIIMOTESIZE)] = tmpBD.b[0] = 0x11;
|
||||
memcpy((BT_DINF+7 + (i * WIIMOTESIZE)), wmName, 20);
|
||||
++BT_DINF.num_registered;
|
||||
BT_DINF.active[i].bdaddr[0] = BT_DINF.registered[i].bdaddr[0] = tmpBD.b[5] = i;
|
||||
BT_DINF.active[i].bdaddr[1] = BT_DINF.registered[i].bdaddr[1] = tmpBD.b[4] = 0;
|
||||
BT_DINF.active[i].bdaddr[2] = BT_DINF.registered[i].bdaddr[2] = tmpBD.b[3] = 0x79;
|
||||
BT_DINF.active[i].bdaddr[3] = BT_DINF.registered[i].bdaddr[3] = tmpBD.b[2] = 0x19;
|
||||
BT_DINF.active[i].bdaddr[4] = BT_DINF.registered[i].bdaddr[4] = tmpBD.b[1] = 2;
|
||||
BT_DINF.active[i].bdaddr[5] = BT_DINF.registered[i].bdaddr[5] = tmpBD.b[0] = 0x11;
|
||||
memcpy(BT_DINF.registered[i].name, wmName, 20);
|
||||
|
||||
INFO_LOG(WII_IPC_WIIMOTE, "Adding to SYSConf Wiimote %d BT ID %x,%x,%x,%x,%x,%x", i, tmpBD.b[0], tmpBD.b[1], tmpBD.b[2], tmpBD.b[3], tmpBD.b[4], tmpBD.b[5]);
|
||||
m_WiiMotes.push_back(CWII_IPC_HLE_WiiMote(this, i, tmpBD, false));
|
||||
|
@ -86,9 +79,8 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305::CWII_IPC_HLE_Device_usb_oh1_57e_305(u32 _De
|
|||
|
||||
// save now so that when games load sysconf file it includes the new wiimotes
|
||||
// and the correct order for connected wiimotes
|
||||
if (!SConfig::GetInstance().m_SYSCONF->SetArrayData("BT.DINF", BT_DINF, BTDINFSIZE) || !SConfig::GetInstance().m_SYSCONF->Save())
|
||||
if (!SConfig::GetInstance().m_SYSCONF->SetArrayData("BT.DINF", (u8*)&BT_DINF, sizeof(_conf_pads)) || !SConfig::GetInstance().m_SYSCONF->Save())
|
||||
PanicAlertT("Failed to write BT.DINF to SYSCONF");
|
||||
|
||||
}
|
||||
|
||||
// The BCM2045's btaddr:
|
||||
|
|
|
@ -307,4 +307,25 @@ private:
|
|||
|
||||
// Debugging
|
||||
void LOG_LinkKey(const u8* _pLinkKey);
|
||||
|
||||
#pragma pack(push,1)
|
||||
#define CONF_PAD_MAX_REGISTERED 10
|
||||
#define CONF_PAD_MAX_ACTIVE 4
|
||||
|
||||
struct _conf_pad_device
|
||||
{
|
||||
u8 bdaddr[6];
|
||||
char name[0x40];
|
||||
};
|
||||
|
||||
struct _conf_pads
|
||||
{
|
||||
u8 num_registered;
|
||||
_conf_pad_device registered[CONF_PAD_MAX_REGISTERED];
|
||||
_conf_pad_device active[CONF_PAD_MAX_ACTIVE];
|
||||
_conf_pad_device balance_board;
|
||||
u8 unknown[0x45];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue