-added WiiDRC_Connected that can be used to detect if the wii vc was started with drc on or off when using a r570 or r590 fw.img

This commit is contained in:
FIX94 2017-09-18 23:40:12 +02:00
parent 516ee534cb
commit 0572b2d93d
No known key found for this signature in database
GPG Key ID: CE39016A19D8EADA
2 changed files with 32 additions and 0 deletions

View File

@ -44,6 +44,7 @@ bool WiiDRC_Init();
bool WiiDRC_Inited(); bool WiiDRC_Inited();
bool WiiDRC_Recalibrate(); bool WiiDRC_Recalibrate();
bool WiiDRC_ScanPads(); bool WiiDRC_ScanPads();
bool WiiDRC_Connected();
const u8 *WiiDRC_GetRawI2CAddr(); const u8 *WiiDRC_GetRawI2CAddr();
const struct WiiDRCData *WiiDRC_Data(); const struct WiiDRCData *WiiDRC_Data();
u32 WiiDRC_ButtonsUp(); u32 WiiDRC_ButtonsUp();

View File

@ -16,6 +16,7 @@ static struct WiiDRCButtons __WiiDRC_PadButtons;
static u32 __WiiDRC_Inited = 0; static u32 __WiiDRC_Inited = 0;
static u8 *__WiiDRC_I2CBuf = NULL; static u8 *__WiiDRC_I2CBuf = NULL;
static u8 *__WiiDRC_DRCStateBuf = NULL;
static bool __WiiDRC_SetI2CBuf() static bool __WiiDRC_SetI2CBuf()
{ {
@ -39,12 +40,32 @@ static bool __WiiDRC_SetI2CBuf()
return false; return false;
} }
static bool __WiiDRC_SetDRCStateBuf()
{
//TODO r569
DCInvalidateRange((void*)0x938B563C, 4);
if(*(vu32*)0x938B563C == 0x138BE770) //r570
{
__WiiDRC_DRCStateBuf = (u8*)0x938BE770;
return true;
}
DCInvalidateRange((void*)0x938B5724, 4);
if(*(vu32*)0x938B5724 == 0x138BD770) //r590
{
__WiiDRC_DRCStateBuf = (u8*)0x938BD770;
return true;
}
return false;
}
bool WiiDRC_Init() bool WiiDRC_Init()
{ {
if(__WiiDRC_Inited == 1) if(__WiiDRC_Inited == 1)
return false; return false;
if(!__WiiDRC_SetI2CBuf()) if(!__WiiDRC_SetI2CBuf())
return false; return false;
//can fail on r569 for now
__WiiDRC_SetDRCStateBuf();
__WiiDRC_Inited = 1; __WiiDRC_Inited = 1;
@ -98,6 +119,16 @@ bool WiiDRC_ScanPads()
return true; return true;
} }
bool WiiDRC_Connected()
{
if(__WiiDRC_DRCStateBuf)
{
DCInvalidateRange(__WiiDRC_DRCStateBuf, 4);
return !!(*(vu32*)__WiiDRC_DRCStateBuf);
}
return true; //default connect
}
const u8 *WiiDRC_GetRawI2CAddr() const u8 *WiiDRC_GetRawI2CAddr()
{ {
return __WiiDRC_I2CBuf; return __WiiDRC_I2CBuf;