Wiimote: Ignored faulty L2CAP packets, allowing libogc's demo to run unaltered. Found raw data representing pointing to the screen.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@588 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
masken 2008-09-20 15:34:20 +00:00
parent ae948f1a23
commit 66011849cd
9 changed files with 82 additions and 16 deletions

View File

@ -64,15 +64,22 @@ protected:
for (u32 i=0; i<NumberInBuffer; i++)
{
SBuffer Buffer;
Buffer.m_Address = Memory::Read_U32(BufferVectorOffset); BufferVectorOffset += 4;
Buffer.m_Address = Memory::Read_U32(BufferVectorOffset);
//restore cached address, mauled by emulatee's ioctl functions.
Memory::Write_U32(Buffer.m_Address | 0x80000000, BufferVectorOffset);
BufferVectorOffset += 4;
Buffer.m_Size = Memory::Read_U32(BufferVectorOffset); BufferVectorOffset += 4;
LOG(WII_IPC_HLE, "SIOCtlVBuffer in%i: 0x%08x, 0x%x", i, Buffer.m_Address, Buffer.m_Size);
InBuffer.push_back(Buffer);
}
for (u32 i=0; i<NumberPayloadBuffer; i++)
{
SBuffer Buffer;
Buffer.m_Address = Memory::Read_U32(BufferVectorOffset); BufferVectorOffset += 4;
Buffer.m_Address = Memory::Read_U32(BufferVectorOffset);
Memory::Write_U32(Buffer.m_Address | 0x80000000, BufferVectorOffset);
BufferVectorOffset += 4;
Buffer.m_Size = Memory::Read_U32(BufferVectorOffset); BufferVectorOffset += 4;
LOG(WII_IPC_HLE, "SIOCtlVBuffer io%i: 0x%08x, 0x%x", i, Buffer.m_Address, Buffer.m_Size);
PayloadBuffer.push_back(Buffer);
}
}

View File

@ -16,6 +16,7 @@
// http://code.google.com/p/dolphin-emu/
#include "WII_IPC_HLE_Device_usb.h"
#include "../Plugins/Plugin_Wiimote.h"
#include <vector>
CWII_IPC_HLE_Device_usb_oh1_57e_305::CWII_IPC_HLE_Device_usb_oh1_57e_305(u32 _DeviceID, const std::string& _rDeviceName)
@ -24,6 +25,7 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305::CWII_IPC_HLE_Device_usb_oh1_57e_305(u32 _De
, m_pACLBuffer(NULL)
, m_pHCIBuffer(NULL)
, m_State(STATE_NONE)
, m_UpdateWaitCount(0)
, scan_enable(0)
, m_DelayedEvent(EVENT_NONE)
{
@ -190,8 +192,6 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::IOCtlV(u32 _CommandAddress)
return true;
}
extern void SendFrame(CWII_IPC_HLE_Device_usb_oh1_57e_305* _pDevice, u16 _ConnectionHandle, u8* _pData, u32 _Size);
void CWII_IPC_HLE_Device_usb_oh1_57e_305::SendToDevice(u16 _ConnectionHandle, u8* _pData, u32 _Size)
{
CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_ConnectionHandle);
@ -234,6 +234,15 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::SendACLFrame(u16 _ConnectionHandle, u8
u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
{
#if 0
if(m_UpdateWaitCount < 5) {
m_UpdateWaitCount++;
return 0;
} else {
m_UpdateWaitCount = 0;
}
#endif
//LOG(WIIMOTE, "Update() %i 0x%08x",
//m_HCICommandMessageQueue.size(), m_pHCIBuffer);
// check state machine
@ -366,6 +375,8 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
return Addr;
}
PluginWiimote::Wiimote_Update();
return 0;
}

View File

@ -162,6 +162,7 @@ private:
};
EState m_State;
u32 m_UpdateWaitCount;
bdaddr_t m_StateTempBD;
u16 m_StateTempConnectionHandle;

View File

@ -177,10 +177,13 @@ void CWII_IPC_HLE_WiiMote::SendACLFrame(u8* _pData, u32 _Size)
u8* pData = _pData + sizeof(SL2CAP_Header);
u32 DataSize = _Size - sizeof(SL2CAP_Header);
LOG(WIIMOTE, "L2Cap-SendFrame: Len 0x%x, Channel 0x%04x",
pHeader->Length, pHeader->CID);
LOG(WIIMOTE, "L2Cap-SendFrame: Channel 0x%04x, Len 0x%x, DataSize 0x%x",
pHeader->CID, pHeader->Length, DataSize);
_dbg_assert_(WIIMOTE, pHeader->Length == DataSize);
if(pHeader->Length != DataSize) {
LOG(WIIMOTE, "Faulty packet. It is dropped.");
return;
}
switch (pHeader->CID)
{

View File

@ -29,6 +29,7 @@ namespace PluginWiimote
TWiimote_Initialize Wiimote_Initialize = 0;
TWiimote_Shutdown Wiimote_Shutdown = 0;
TWiimote_Output Wiimote_Output = 0;
TWiimote_Update Wiimote_Update = 0;
TWiimote_GetAttachedControllers Wiimote_GetAttachedControllers = 0;
TWiimote_DoState Wiimote_DoState = 0;
@ -51,6 +52,7 @@ namespace PluginWiimote
Wiimote_Initialize = 0;
Wiimote_Shutdown = 0;
Wiimote_Output = 0;
Wiimote_Update = 0;
Wiimote_GetAttachedControllers = 0;
Wiimote_DoState = 0;
}
@ -66,6 +68,7 @@ namespace PluginWiimote
Wiimote_Initialize = reinterpret_cast<TWiimote_Initialize> (plugin.Get("Wiimote_Initialize"));
Wiimote_Shutdown = reinterpret_cast<TWiimote_Shutdown> (plugin.Get("Wiimote_Shutdown"));
Wiimote_Output = reinterpret_cast<TWiimote_Output> (plugin.Get("Wiimote_Output"));
Wiimote_Update = reinterpret_cast<TWiimote_Update> (plugin.Get("Wiimote_Update"));
Wiimote_GetAttachedControllers = reinterpret_cast<TWiimote_GetAttachedControllers> (plugin.Get("Wiimote_GetAttachedControllers"));
Wiimote_DoState = reinterpret_cast<TWiimote_DoState> (plugin.Get("Wiimote_DoState"));
@ -75,12 +78,14 @@ namespace PluginWiimote
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_Initialize", Wiimote_Initialize);
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_Shutdown", Wiimote_Shutdown);
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_Output", Wiimote_Output);
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_Update", Wiimote_Update);
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_GetAttachedControllers", Wiimote_GetAttachedControllers);
LOG(MASTER_LOG, "%s: 0x%p", "Wiimote_DoState", Wiimote_DoState);
if ((GetDllInfo != 0) &&
(Wiimote_Initialize != 0) &&
(Wiimote_Shutdown != 0) &&
(Wiimote_Output != 0) &&
(Wiimote_Update != 0) &&
(Wiimote_GetAttachedControllers != 0) &&
(Wiimote_DoState != 0))
{

View File

@ -32,6 +32,7 @@ typedef void (__cdecl* TDllAbout)(HWND);
typedef void (__cdecl* TDllConfig)(HWND);
typedef void (__cdecl* TWiimote_Initialize)(SWiimoteInitialize);
typedef void (__cdecl* TWiimote_Shutdown)();
typedef void (__cdecl* TWiimote_Update)();
typedef void (__cdecl* TWiimote_Output)(const void* _pData, u32 _Size);
typedef unsigned int (__cdecl* TWiimote_GetAttachedControllers)();
typedef void (__cdecl* TWiimote_DoState)(void *ptr, int mode);
@ -43,6 +44,7 @@ extern TDllConfig DllConfig;
extern TWiimote_Initialize Wiimote_Initialize;
extern TWiimote_Shutdown Wiimote_Shutdown;
extern TWiimote_Output Wiimote_Output;
extern TWiimote_Update Wiimote_Update;
extern TWiimote_GetAttachedControllers Wiimote_GetAttachedControllers;
extern TWiimote_DoState Wiimote_DoState;

View File

@ -82,6 +82,14 @@ EXPORT void CALL Wiimote_Shutdown();
//
EXPORT void CALL Wiimote_Output(const void* _pData, u32 _Size);
// __________________________________________________________________________________________________
// Function: Wiimote_Update
// Purpose: This function is called periodically by the Core.
// input: none
// output: none
//
EXPORT void CALL Wiimote_Update();
// __________________________________________________________________________________________________
// Function: PAD_GetAttachedPads
// Purpose: Get mask of attached pads (eg: controller 1 & 4 -> 0x9)

View File

@ -512,6 +512,10 @@
<References>
</References>
<Files>
<File
RelativePath="..\..\PluginSpecs\pluginspecs_wiimote.h"
>
</File>
<File
RelativePath=".\Src\wiimote_hid.h"
>

View File

@ -26,6 +26,8 @@ u8 g_RegSpeaker[WIIMOTE_REG_SPEAKER_SIZE];
u8 g_RegExt[WIIMOTE_REG_EXT_SIZE];
u8 g_RegIr[WIIMOTE_REG_IR_SIZE];
u8 g_ReportingMode;
static const u8 EepromData_0[] = {
0xA1, 0xAA, 0x8B, 0x99, 0xAE, 0x9E, 0x78, 0x30,
0xA7, 0x74, 0xD3, 0xA1, 0xAA, 0x8B, 0x99, 0xAE,
@ -142,6 +144,7 @@ extern "C" void GetDllInfo (PLUGIN_INFO* _PluginInfo)
extern "C" void DllAbout(HWND _hParent)
{
wxAboutDialogInfo info;
info.SetName("Wiimote test plugin");
info.AddDeveloper(_T("masken (masken3@gmail.com)"));
info.SetDescription(_T("Wiimote test plugin"));
wxAboutBox(info);
@ -159,9 +162,12 @@ extern "C" void Wiimote_Initialize(SWiimoteInitialize _WiimoteInitialize)
memset(g_Eeprom, 0, WIIMOTE_EEPROM_SIZE);
memcpy(g_Eeprom, EepromData_0, sizeof(EepromData_0));
memcpy(g_Eeprom + 0x16D0, EepromData_16D0, sizeof(EepromData_16D0));
g_ReportingMode = 0;
}
extern "C" void Wiimote_DoState(void* ptr, int mode) {
//TODO: implement
}
extern "C" void Wiimote_Shutdown(void)
@ -194,6 +200,14 @@ extern "C" void Wiimote_Output(const void* _pData, u32 _Size) {
}
}
extern "C" void Wiimote_Update() {
//LOG(WIIMOTE, "Wiimote_Update");
if(g_ReportingMode == 0x33)
SendReportCoreAccelIr12();
else if(g_ReportingMode == 0x31)
SendReportCoreAccel();
}
extern "C" unsigned int Wiimote_GetAttachedControllers() {
return 1;
}
@ -246,10 +260,7 @@ void WmDataReporting(wm_data_reporting* dr) {
LOG(WIIMOTE, " Rumble: %x", dr->rumble);
LOG(WIIMOTE, " Mode: 0x%02x", dr->mode);
if(dr->mode == 0x33)
SendReportCoreAccelIr12();
else if(dr->mode == 0x31)
SendReportCoreAccel();
g_ReportingMode = dr->mode;
}
void SendReportCoreAccelIr12() {
@ -265,11 +276,25 @@ void SendReportCoreAccelIr12() {
pReport->a.y = 0x78;
pReport->a.z = 0xD9;
pReport->ir[0].x = 320 & 0xFF;
pReport->ir[0].y = 240;
int x = 600;
int y = 440;
x = 1023 - x;
pReport->ir[0].x = x & 0xFF;
pReport->ir[0].y = y & 0xFF;
pReport->ir[0].size = 10;
pReport->ir[0].xHi = 320 >> 8;
pReport->ir[0].yHi = 0;
pReport->ir[0].xHi = x >> 8;
pReport->ir[0].yHi = y >> 8;
x = 100;
y = 450;
x = 1023 - x;
pReport->ir[1].x = x;
pReport->ir[1].y = y & 0xFF;
pReport->ir[1].size = 5;
pReport->ir[1].xHi = x >> 8;
pReport->ir[1].yHi = y >> 8;
LOG(WIIMOTE, " SendReportCoreAccelIr12()");