summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authormasken <masken3@gmail.com>2008-09-20 15:34:20 +0000
committermasken <masken3@gmail.com>2008-09-20 15:34:20 +0000
commit66011849cd5f66c53b7e046bfbffe41711c835d3 (patch)
tree315261236f2c9ce4abfb043462f83ceb9821417b /Source
parentae948f1a2359932d6f486c9ad86e5ab9bd566647 (diff)
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
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h13
-rw-r--r--Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp15
-rw-r--r--Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h1
-rw-r--r--Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp9
-rw-r--r--Source/Core/Core/Src/Plugins/Plugin_Wiimote.cpp5
-rw-r--r--Source/Core/Core/Src/Plugins/Plugin_Wiimote.h2
-rw-r--r--Source/PluginSpecs/pluginspecs_wiimote.h8
-rw-r--r--Source/Plugins/Plugin_Wiimote_Test/Plugin_Wiimote_Test.vcproj4
-rw-r--r--Source/Plugins/Plugin_Wiimote_Test/Src/Wiimote_Test.cpp41
9 files changed, 82 insertions, 16 deletions
diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h
index e94552d084..bb0c12579f 100644
--- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h
+++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h
@@ -64,17 +64,24 @@ 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);
- }
+ }
}
// STATE_TO_SAVE
diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp
index 05413d2015..d2975e61fd 100644
--- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp
+++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp
@@ -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;
}
diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h
index eaabfa3be9..e73a95c700 100644
--- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h
+++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h
@@ -162,6 +162,7 @@ private:
};
EState m_State;
+ u32 m_UpdateWaitCount;
bdaddr_t m_StateTempBD;
u16 m_StateTempConnectionHandle;
diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp
index 7d4db2a573..14224c27eb 100644
--- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp
+++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp
@@ -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)
{
diff --git a/Source/Core/Core/Src/Plugins/Plugin_Wiimote.cpp b/Source/Core/Core/Src/Plugins/Plugin_Wiimote.cpp
index 5300ab8a3b..c24da0fe5c 100644
--- a/Source/Core/Core/Src/Plugins/Plugin_Wiimote.cpp
+++ b/Source/Core/Core/Src/Plugins/Plugin_Wiimote.cpp
@@ -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))
{
diff --git a/Source/Core/Core/Src/Plugins/Plugin_Wiimote.h b/Source/Core/Core/Src/Plugins/Plugin_Wiimote.h
index d076580da2..fe0abea0ea 100644
--- a/Source/Core/Core/Src/Plugins/Plugin_Wiimote.h
+++ b/Source/Core/Core/Src/Plugins/Plugin_Wiimote.h
@@ -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;
diff --git a/Source/PluginSpecs/pluginspecs_wiimote.h b/Source/PluginSpecs/pluginspecs_wiimote.h
index 420656c103..70ff95a63a 100644
--- a/Source/PluginSpecs/pluginspecs_wiimote.h
+++ b/Source/PluginSpecs/pluginspecs_wiimote.h
@@ -83,6 +83,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)
// input: none
diff --git a/Source/Plugins/Plugin_Wiimote_Test/Plugin_Wiimote_Test.vcproj b/Source/Plugins/Plugin_Wiimote_Test/Plugin_Wiimote_Test.vcproj
index 26b7d957f4..f05e611ca5 100644
--- a/Source/Plugins/Plugin_Wiimote_Test/Plugin_Wiimote_Test.vcproj
+++ b/Source/Plugins/Plugin_Wiimote_Test/Plugin_Wiimote_Test.vcproj
@@ -513,6 +513,10 @@
</References>
<Files>
<File
+ RelativePath="..\..\PluginSpecs\pluginspecs_wiimote.h"
+ >
+ </File>
+ <File
RelativePath=".\Src\wiimote_hid.h"
>
</File>
diff --git a/Source/Plugins/Plugin_Wiimote_Test/Src/Wiimote_Test.cpp b/Source/Plugins/Plugin_Wiimote_Test/Src/Wiimote_Test.cpp
index b2b58f6140..2962102067 100644
--- a/Source/Plugins/Plugin_Wiimote_Test/Src/Wiimote_Test.cpp
+++ b/Source/Plugins/Plugin_Wiimote_Test/Src/Wiimote_Test.cpp
@@ -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()");