Fixed the emulated Wiimote in Rayman Rabbids 1, Sonic Rings and Wii Sports

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1283 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson 2008-11-24 02:29:38 +00:00
parent b19859450e
commit 67087170ab
13 changed files with 202 additions and 199 deletions

View File

@ -221,6 +221,9 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _B
{
switch(_Parameter)
{
case GET_STATS:
PanicAlert("FS: GET_STATS not supported");
break;
case CREATE_DIR:
{
_dbg_assert_(WII_IPC_FILEIO, _BufferOutSize == 0);

View File

@ -43,6 +43,7 @@ private:
enum
{
GET_STATS = 0x02,
CREATE_DIR = 0x03,
IOCTL_READ_DIR = 0x04,
GET_ATTR = 0x06,

View File

@ -235,17 +235,33 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::SendToDevice(u16 _ConnectionHandle, u8
pWiiMote->SendACLFrame(_pData, _Size);
}
// ===================================================
/* Here we queue the ACL frames. They will consist of header + data. The header is
for example 07 00 41 00 which means size 0x0007 and channel 0x0041. */
// ----------------
void CWII_IPC_HLE_Device_usb_oh1_57e_305::SendACLFrame(u16 _ConnectionHandle, u8* _pData, u32 _Size)
{
LOGV(WII_IPC_WIIMOTE, 1, "Queing ACL frame.");
//queue the packet
// Queue the packet
ACLFrame frame;
frame.ConnectionHandle = _ConnectionHandle;
frame.data = new u8[_Size];
memcpy(frame.data, _pData, _Size);
frame.size = _Size;
m_AclFrameQue.push(frame);
/* Debugging
std::string Temp;
for (u32 j = 0; j < _Size; j++)
{
char Buffer[128];
sprintf(Buffer, "%02x ", frame.data[j]);
Temp.append(Buffer);
}
LOGV(WII_IPC_WIIMOTE, 1, " Size: 0x%08x", _Size);
LOGV(WII_IPC_WIIMOTE, 1, " Data: %s", Temp.c_str()); */
g_HCICount++;
}
@ -290,7 +306,9 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
pHeader->PBFlag = 2;
pHeader->Size = frame.size;
memcpy(Memory::GetPointer(m_pACLBuffer->PayloadBuffer[0].m_Address + sizeof(UACLHeader)), frame.data , frame.size);
// Write the fram to the PayloadBuffer
memcpy(Memory::GetPointer(m_pACLBuffer->PayloadBuffer[0].m_Address + sizeof(UACLHeader)),
frame.data, frame.size);
// return reply buffer size
Memory::Write_U32(sizeof(UACLHeader) + frame.size, m_pACLBuffer->m_Address + 0x4);
@ -302,6 +320,19 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
delete m_pACLBuffer;
m_pACLBuffer = NULL;
/* Debugging
std::string Temp;
for (u32 j = 0; j < frame.size; j++)
{
char Buffer[128];
sprintf(Buffer, "%02x ", frame.data[j]);
Temp.append(Buffer);
}
LOGV(WII_IPC_WIIMOTE, 1, " Size: 0x%08x", frame.size);
LOGV(WII_IPC_WIIMOTE, 1, " Size of UACLHeader: 0x%08x", sizeof(UACLHeader));
LOGV(WII_IPC_WIIMOTE, 1, " Data: %s", Temp.c_str()); */
return Addr;
}
@ -894,8 +925,9 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::ExecuteHCICommandMessage(const SHCICom
u16 ocf = HCI_OCF(pMsg->Opcode);
u16 ogf = HCI_OGF(pMsg->Opcode);
LOG(WII_IPC_WIIMOTE, "****************************** ExecuteHCICommandMessage(0x%04x)"
"(ocf: 0x%02x, ogf: 0x%02x)", pMsg->Opcode, ocf, ogf);
LOG(WII_IPC_WIIMOTE, "******************************");
LOG(WII_IPC_WIIMOTE, "ExecuteHCICommandMessage(0x%04x)(ocf: 0x%02x, ogf: 0x%02x)",
pMsg->Opcode, ocf, ogf);
switch(pMsg->Opcode)
{

View File

@ -311,6 +311,11 @@ void CWII_IPC_HLE_WiiMote::EventCommandWriteLinkPolicy()
//
/////////////////////////////////////////////////////////////////////////////////////////////////
// ===================================================
/* This function send ACL frams from the Wii to Wiimote_ControlChannel() in the Wiimote.
It's called from SendToDevice() in WII_IPC_HLE_Device_usb.cpp. */
// ----------------
void CWII_IPC_HLE_WiiMote::SendACLFrame(u8* _pData, u32 _Size)
{
// Debugger::PrintDataBuffer(LogTypes::WIIMOTE, _pData, _Size, "SendACLFrame: ");
@ -325,7 +330,7 @@ void CWII_IPC_HLE_WiiMote::SendACLFrame(u8* _pData, u32 _Size)
if(pHeader->Length != DataSize)
{
LOG(WII_IPC_WIIMOTE, "Faulty packet. It is dropped.");
LOGV(WII_IPC_WIIMOTE, 2, "Faulty packet. It is dropped.");
return;
}
@ -459,7 +464,7 @@ void CWII_IPC_HLE_WiiMote::CommandConnectionReq(u8 _Ident, u8* _pData, u32 _Size
void CWII_IPC_HLE_WiiMote::CommandCofigurationReq(u8 _Ident, u8* _pData, u32 _Size)
{
LOGV(WII_IPC_WIIMOTE, 1, "=======================================================");
LOGV(WII_IPC_WIIMOTE, 1, "*******************************************************");
u32 Offset = 0;
SL2CAP_CommandConfigurationReq* pCommandConfigReq = (SL2CAP_CommandConfigurationReq*)_pData;
@ -524,7 +529,7 @@ void CWII_IPC_HLE_WiiMote::CommandCofigurationReq(u8 _Ident, u8* _pData, u32 _Si
}
SendCommandToACL(_Ident, L2CAP_CONF_RSP, RespLen, TempBuffer);
LOGV(WII_IPC_WIIMOTE, 1, "=======================================================");
LOGV(WII_IPC_WIIMOTE, 1, "*******************************************************");
}
void CWII_IPC_HLE_WiiMote::CommandConnectionResponse(u8 _Ident, u8* _pData, u32 _Size)

View File

@ -27,8 +27,18 @@
[c.left etc] [c.a etc] acc.x y z ir0.x y ? ir1.x y ? ir2.x y ? ir3.x y ?
0x37
[c.left etc] [c.a etc] acc.x y z ir0.x1 y1 ? x2 y2 ir1.x1 y1 ? x2 y2 ext.jx jy ax ay az bt*/
[c.left etc] [c.a etc] acc.x y z ir0.x1 y1 ? x2 y2 ir1.x1 y1 ? x2 y2 ext.jx jy ax ay az bt
The Data Report's path from here is
WII_IPC_HLE_WiiMote.cpp:
Callback_WiimoteInput()
CWII_IPC_HLE_WiiMote::SendL2capData()
WII_IPC_HLE_Device_usb.cpp:
CWII_IPC_HLE_Device_usb_oh1_57e_305::SendACLFrame()
at that point the message is queued and will be sent by the next
CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() */
// ================
@ -40,6 +50,7 @@
#include <string>
#include "Common.h"
#include "wiimote_hid.h"
#include "EmuMain.h"
#include "EmuSubroutines.h"
#include "EmuDefinitions.h"
#include "Encryption.h" // for extension encryption
@ -66,7 +77,6 @@ void WmDataReporting(u16 _channelID, wm_data_reporting* dr)
LOG(WII_IPC_WIIMOTE, " Rumble: %x", dr->rumble);
LOG(WII_IPC_WIIMOTE, " Continuous: %x", dr->continuous);
LOG(WII_IPC_WIIMOTE, " All The Time: %x (not only on data change)", dr->all_the_time);
LOG(WII_IPC_WIIMOTE, " Rumble: %x", dr->rumble);
LOG(WII_IPC_WIIMOTE, " Mode: 0x%02x", dr->mode);
wprintf("\nData reporting mode: 0x%02x", dr->mode);
wprintf("\nData reporting channel: 0x%04x\n", _channelID);
@ -127,20 +137,18 @@ void SendReportCoreAccel(u16 _channelID)
FillReportInfo(pReport->c);
FillReportAcc(pReport->a);
LOGV(WII_IPC_WIIMOTE, 2, " SendReportCoreAccel()");
LOGV(WII_IPC_WIIMOTE, 2, " SendReportCoreAccel (0x31)");
LOGV(WII_IPC_WIIMOTE, 2, " Channel: %04x", _channelID);
LOGV(WII_IPC_WIIMOTE, 2, " Offset: %08x", Offset);
// Debugging
#ifdef _WIN32
/*if(GetAsyncKeyState('V'))
{
wprintf("DataFrame: ");
for (int i = 0; i < Offset; i++)
{
wprintf("%02x ", DataFrame[i]);
if((i + 1) % 30 == 0) wprintf("\n");
}
wprintf("\n");
std::string Temp = WiiMoteEmu::ArrayToString(DataFrame, Offset, 0, 30);
wprintf("DataFrame: %s\n", Temp.c_str());
}*/
#endif
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
}
@ -169,13 +177,8 @@ void SendReportCoreAccelIr12(u16 _channelID) {
#ifdef _WIN32
/*if(GetAsyncKeyState('V'))
{
wprintf("DataFrame: ");
for (int i = 0; i < Offset; i++)
{
wprintf("%02x ", DataFrame[i]);
if((i + 1) % 30 == 0) wprintf("\n");
}
wprintf("\n");
std::string Temp = WiiMoteEmu::ArrayToString(DataFrame, Offset, 0, 30);
wprintf("DataFrame: %s\n", Temp.c_str());
}*/
#endif
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
@ -201,19 +204,16 @@ void SendReportCoreAccelExt16(u16 _channelID)
//FillReportIRBasic(pReport->ir[0], pReport->ir[1]); // no IR here
FillReportExtension(pReport->ext);
LOGV(WII_IPC_WIIMOTE, 2, " SendReportCoreAccelExt16()");
LOGV(WII_IPC_WIIMOTE, 2, " SendReportCoreAccelExt16 (0x35)");
LOGV(WII_IPC_WIIMOTE, 2, " Channel: %04x", _channelID);
LOGV(WII_IPC_WIIMOTE, 2, " Offset: %08x", Offset);
// Debugging
#ifdef _WIN32
/*if(GetAsyncKeyState('V'))
{
wprintf("DataFrame: ");
for (int i = 0; i < Offset; i++)
{
wprintf("%02x ", DataFrame[i]);
if((i + 1) % 30 == 0) wprintf("\n");
}
wprintf("\n");
std::string Temp = WiiMoteEmu::ArrayToString(DataFrame, Offset, 0, 30);
wprintf("DataFrame: %s\n", Temp.c_str());
}*/
#endif
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
@ -243,13 +243,8 @@ void SendReportCoreAccelIr10Ext(u16 _channelID)
#ifdef _WIN32
/*if(GetAsyncKeyState('V'))
{
wprintf("DataFrame: ");
for (int i = 0; i < Offset; i++)
{
wprintf("%02x ", DataFrame[i]);
if((i + 1) % 30 == 0) wprintf("\n");
}
wprintf("\n");
std::string Temp = WiiMoteEmu::ArrayToString(DataFrame, Offset, 0, 30);
wprintf("DataFrame: %s\n", Temp.c_str());
}*/
#endif
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);

View File

@ -38,6 +38,7 @@ namespace WiiMoteEmu
//******************************************************************************
u8 g_Leds = 0x1;
u8 g_IR = 0x1; // 1 = on
u8 g_Eeprom[WIIMOTE_EEPROM_SIZE];

View File

@ -30,8 +30,6 @@
#include "Config.h" // for g_Config
extern SWiimoteInitialize g_WiimoteInitialize;
//extern void __Log(int log, const char *format, ...);
//extern void __Log(int log, int v, const char *format, ...);
namespace WiiMoteEmu
@ -70,7 +68,6 @@ void HidOutputReport(u16 _channelID, wm_report* sr) {
WmDataReporting(_channelID, (wm_data_reporting*)sr->data);
break;
case WM_REQUEST_STATUS: // 0x15
//global_struct = (wm_request_status*)sr->data;
WmRequestStatus(_channelID, (wm_request_status*)sr->data);
break;
case WM_READ_DATA: // 0x17
@ -78,16 +75,20 @@ void HidOutputReport(u16 _channelID, wm_report* sr) {
break;
case WM_IR_PIXEL_CLOCK: // 0x13
case WM_IR_LOGIC: // 0x1a
LOGV(WII_IPC_WIIMOTE, 0, " IR Enable 0x%02x 0x%02x", sr->channel, sr->data[0]);
LOGV(WII_IPC_WIIMOTE, 0, " IR Enable 0x%02x: 0x%02x", sr->channel, sr->data[0]);
//wprintf("IR Enable/Disable 0x%02x: 0x%02x\n", sr->channel, sr->data[0]);
// Update the global value so that WmRequestStatus() knows it
if(sr->data[0] == 0x02) g_IR = 0;
else if(sr->data[0] == 0x06) g_IR = 1;
break;
case WM_WRITE_DATA: // 0x16
WmWriteData(_channelID, (wm_write_data*)sr->data);
break;
case WM_SPEAKER_ENABLE:
LOGV(WII_IPC_WIIMOTE, 1, " WM Speaker Enable 0x%02x 0x%02x", sr->channel, sr->data[0]);
LOGV(WII_IPC_WIIMOTE, 1, " WM Speaker Enable 0x%02x: 0x%02x", sr->channel, sr->data[0]);
break;
case WM_SPEAKER_MUTE:
LOGV(WII_IPC_WIIMOTE, 1, " WM Mute Enable 0x%02x 0x%02x", sr->channel, sr->data[0]);
LOGV(WII_IPC_WIIMOTE, 1, " WM Mute Enable 0x%02x: 0x%02x", sr->channel, sr->data[0]);
break;
default:
PanicAlert("HidOutputReport: Unknown channel 0x%02x", sr->channel);
@ -119,12 +120,12 @@ int WriteWmReport(u8* dst, u8 channel) {
// ----------------
void WmLeds(u16 _channelID, wm_leds* leds) {
LOGV(WII_IPC_WIIMOTE, 0, "===========================================================");
LOG(WII_IPC_WIIMOTE, " Set LEDs");
LOG(WII_IPC_WIIMOTE, " Leds: %x", leds->leds);
LOG(WII_IPC_WIIMOTE, " Rumble: %x", leds->rumble);
LOG(WII_IPC_WIIMOTE, " Leds: %x", leds->leds);
LOG(WII_IPC_WIIMOTE, " Rumble: %x", leds->rumble);
g_Leds = leds->leds;
LOGV(WII_IPC_WIIMOTE, 0, "===========================================================");
}
@ -137,7 +138,6 @@ void WmLeds(u16 _channelID, wm_leds* leds) {
void WmSendAck(u16 _channelID, u8 _reportID, u32 address)
{
u8 DataFrame[1024];
u32 Offset = 0;
// Header
@ -154,23 +154,18 @@ void WmSendAck(u16 _channelID, u8 _reportID, u32 address)
pData->errorID = 0;
Offset += sizeof(wm_acknowledge);
/* Debug. Write the report for extension registry writes.
LOGV(WII_IPC_WIIMOTE, 2, " WMSendAck()");
LOGV(WII_IPC_WIIMOTE, 2, " Report ID: %02x", _reportID);
//std::string Temp = WiiMoteEmu::ArrayToString(DataFrame, Offset, 0);
//LOGV(WII_IPC_WIIMOTE, 2, " Data: %s", Temp.c_str());
/* Debug. Write the report for extension registry writes.
if((_reportID == 0x16 || _reportID == 0x17) && ((address >> 16) & 0xfe) == 0xa4)
{
wprintf("\nWMSendAck Report ID: %02x KeyReady: %i, Encryption: %02x\n",
_reportID, (int)KeyReady, g_RegExt[0xf0]);
wprintf("Data: ");
for (int i = 0; i < Offset; i++)
{
wprintf("%02x ", DataFrame[i]);
if((i + 1) % 20 == 0) wprintf("\n");
}
wprintf("\n");
wprintf("\nWMSendAck Report ID: %02x Encryption: %02x\n", _reportID, g_RegExt[0xf0]);
wprintf("Data: %s\n", Temp.c_str());
}*/
LOGV(WII_IPC_WIIMOTE, 2, " WMSendAck()");
LOGV(WII_IPC_WIIMOTE, 2, " Report ID: %02x", _reportID);
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
}
@ -183,14 +178,17 @@ void WmReadData(u16 _channelID, wm_read_data* rd)
LOGV(WII_IPC_WIIMOTE, 0, "===========================================================");
u32 address = convert24bit(rd->address);
u16 size = convert16bit(rd->size);
LOG(WII_IPC_WIIMOTE, " Read data");
LOG(WII_IPC_WIIMOTE, " Address space: %x", rd->space);
LOG(WII_IPC_WIIMOTE, " Address: 0x%06x", address);
LOG(WII_IPC_WIIMOTE, " Size: 0x%04x", size);
LOG(WII_IPC_WIIMOTE, " Rumble: %x", rd->rumble);
std::string Temp;
LOG(WII_IPC_WIIMOTE, "Read data");
LOG(WII_IPC_WIIMOTE, " Address space: %x", rd->space);
LOG(WII_IPC_WIIMOTE, " Address: 0x%06x", address);
LOG(WII_IPC_WIIMOTE, " Size: 0x%04x", size);
LOG(WII_IPC_WIIMOTE, " Rumble: %x", rd->rumble);
//u32 _address = address;
/* Now we determine what address space we are reading from. Space 0 is Eeprom and
space 1 and 2 is the registers. */
if(rd->space == 0)
{
if (address + size > WIIMOTE_EEPROM_SIZE)
@ -206,22 +204,26 @@ void WmReadData(u16 _channelID, wm_read_data* rd)
u32 blockSize;
switch((address >> 16) & 0xFE)
{
/**/ case 0xA2:
case 0xA2:
block = g_RegSpeaker;
blockSize = WIIMOTE_REG_SPEAKER_SIZE;
LOGV(WII_IPC_WIIMOTE, 0, "WmReadData: 0xB0 g_RegSpeaker");
LOGV(WII_IPC_WIIMOTE, 0, " Case 0xa2: g_RegSpeaker");
//Temp = WiiMoteEmu::ArrayToString(g_RegSpeaker, size, (address & 0xffff));
//LOGV(WII_IPC_WIIMOTE, 0, " Data: %s", Temp.c_str());
break;
case 0xA4:
block = g_RegExt;
blockSize = WIIMOTE_REG_EXT_SIZE;
LOGV(WII_IPC_WIIMOTE, 0, " Case 0xA4: Read ExtReg ****************************");
//wprintf("WmReadData\n"); ReadExt();
LOGV(WII_IPC_WIIMOTE, 0, " Case 0xa4: Read ExtReg ****************************");
//Temp = WiiMoteEmu::ArrayToString(g_RegExt, size, (address & 0xffff));
//LOGV(WII_IPC_WIIMOTE, 0, " Data: %s", Temp.c_str());
break;
/**/ case 0xB0:
case 0xB0:
block = g_RegIr;
blockSize = WIIMOTE_REG_IR_SIZE;
//PanicAlert("WmReadData: 0xB0 g_RegIr");
LOGV(WII_IPC_WIIMOTE, 0, "WmReadData: 0xB0 g_RegIr");
LOGV(WII_IPC_WIIMOTE, 0, " Case: 0xb0 g_RegIr");
//Temp = WiiMoteEmu::ArrayToString(g_RegIr, size, (address & 0xffff));
//LOGV(WII_IPC_WIIMOTE, 0, " Data: %s", Temp.c_str());
break;
default:
PanicAlert("WmWriteData: bad register block!");
@ -239,12 +241,8 @@ void WmReadData(u16 _channelID, wm_read_data* rd)
// Debugging
u32 offset = address & 0xffff;
wprintf("Unencrypted data:\n");
for (int i = 0; i < (u8)size; i++)
{
wprintf("%02x ", g_RegExt[i + offset]);
if((i + 1) % 20 == 0) wprintf("\n");
}
//std::string Temp = WiiMoteEmu::ArrayToString(g_RegExt, size, offset);
//wprintf("Unencrypted data:\n%s\n", Temp.c_str());
// Check if encrypted reads is on
if(g_RegExt[0xf0] == 0xaa)
@ -264,18 +262,11 @@ void WmReadData(u16 _channelID, wm_read_data* rd)
{
wprintf("%02x ", g_RegExtTmp[i + offset]);
if((i + 1) % 20 == 0) wprintf("\n");
}
wprintf("\ng_RegExtTmp after: \n");
ReadExtTmp();
wprintf("\nFrom g_RegExt: \n");
ReadExt();*/
}*/
// Update the block that SendReadDataReply will eventually send to the Wii
block = g_RegExtTmp;
}
//wprintf("\n\n");
}
//---------
@ -288,6 +279,8 @@ void WmReadData(u16 _channelID, wm_read_data* rd)
// Let this function process the message and send it to the Wii
SendReadDataReply(_channelID, block+address, address, (u8)size);
}
else
{
@ -309,13 +302,13 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
{
LOGV(WII_IPC_WIIMOTE, 0, "========================================================");
u32 address = convert24bit(wd->address);
LOG(WII_IPC_WIIMOTE, " Write data");
LOG(WII_IPC_WIIMOTE, " Address space: %x", wd->space);
LOG(WII_IPC_WIIMOTE, " Address: 0x%06x", address);
LOG(WII_IPC_WIIMOTE, " Size: 0x%02x", wd->size);
LOG(WII_IPC_WIIMOTE, " Rumble: %x", wd->rumble);
u32 _address = address;
LOG(WII_IPC_WIIMOTE, "Write data");
LOG(WII_IPC_WIIMOTE, " Address space: %x", wd->space);
LOG(WII_IPC_WIIMOTE, " Address: 0x%06x", address);
LOG(WII_IPC_WIIMOTE, " Size: 0x%02x", wd->size);
LOG(WII_IPC_WIIMOTE, " Rumble: %x", wd->rumble);
//std::string Temp = WiiMoteEmu::ArrayToString(wd->data, wd->size);
//LOGV(WII_IPC_WIIMOTE, 0, " Data: %s", Temp.c_str());
// Write to EEPROM
if(wd->size <= 16 && wd->space == WM_SPACE_EEPROM)
@ -325,8 +318,6 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
return;
}
memcpy(g_Eeprom + address, wd->data, wd->size);
// WmSendAck(_channelID, WM_WRITE_DATA);
}
// Write to registers
else if(wd->size <= 16 && (wd->space == WM_SPACE_REGS1 || wd->space == WM_SPACE_REGS2))
@ -338,21 +329,21 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
case 0xA2:
block = g_RegSpeaker;
blockSize = WIIMOTE_REG_SPEAKER_SIZE;
LOGV(WII_IPC_WIIMOTE, 0, " Case 0xa2: g_RegSpeaker");
break;
case 0xA4:
block = g_RegExt; // Extension Controller register
blockSize = WIIMOTE_REG_EXT_SIZE;
LOGV(WII_IPC_WIIMOTE, 0, " *******************************************************");
LOGV(WII_IPC_WIIMOTE, 0, "");
LOGV(WII_IPC_WIIMOTE, 0, " Case 0xA4: Write ExtReg");
LOGV(WII_IPC_WIIMOTE, 0, "");
LOGV(WII_IPC_WIIMOTE, 0, " *******************************************************");
//LOGV(WII_IPC_WIIMOTE, 0, " *******************************************************");
LOGV(WII_IPC_WIIMOTE, 0, " Case 0xa4: ExtReg");
//LOGV(WII_IPC_WIIMOTE, 0, " *******************************************************");
wprintf("\n\nWmWriteData Size: %i Address: %08x Offset: %08x \n",
wd->size, address, (address & 0xffff));
break;
case 0xB0:
block = g_RegIr;
blockSize = WIIMOTE_REG_IR_SIZE;
LOGV(WII_IPC_WIIMOTE, 0, " Case 0xb0: g_RegIr");
break;
default:
PanicAlert("WmWriteData: bad register block!");
@ -361,7 +352,7 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
// Remove for example 0xa40000 from the address
_address = address; address &= 0xFFFF;
address &= 0xFFFF;
// Check if the address is within bounds
if(address + wd->size > blockSize) {
@ -371,26 +362,16 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
// Finally write the registers to the right structure
memcpy(block + address, wd->data, wd->size);
// -----------------------------------------
// Generate key for the Wiimote Extension
// -------------
if(blockSize == WIIMOTE_REG_EXT_SIZE)
{
/* Debugging. Write the data.
wprintf("Data: ");
for (int i = 0; i < wd->size; i++)
{
wprintf("%02x ", wd->data[i]);
if((i + 1) % 25 == 0) wprintf("\n");
}
wprintf("\n");
//wprintf("Current address: %08x\n", address);
//wprintf("g_RegExt:\n");
//ReadExt(); */
/* Debugging. Write the data.
wprintf("Data: %s\n", Temp.c_str());
wprintf("Current address: %08x\n", address); */
/* Run the key generation on all writes in the key area, it doesn't matter
that we send it parts of a key, only the last full key will have an
@ -417,8 +398,8 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
/* Here we produce the actual 0x21 Input report that we send to the Wii. The message
is divided into 16 bytes pieces and sent piece by piece. There will be five formatting
bytes at the begging of all reports. A common format is 00 00 f0 00 20, the 00 00
means that no buttons are pressedn, the f means 16 bytes in the message, the 0
means no error, the 00 20 means that the message is at the 00 20 offest the the
means that no buttons are pressed, the f means 16 bytes in the message, the 0
means no error, the 00 20 means that the message is at the 00 20 offest in the
registry that was read. */
// ----------------
void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size)
@ -460,17 +441,6 @@ void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size)
LOG(WII_IPC_WIIMOTE, " Size: 0x%x", pReply->size);
LOG(WII_IPC_WIIMOTE, " Address: 0x%04x", pReply->address);
/* Debugging
wprintf("SendReadDataReply Address: %08x\n", _Address);
for (int i = 0; i < Offset; i++)
{
wprintf("%02x ", DataFrame[i]);
if((i + 1) % 25 == 0) wprintf("\n");
}
wprintf("\n\n");*/
//---------
// Send a piece
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
@ -496,8 +466,8 @@ void WmRequestStatus(u16 _channelID, wm_request_status* rs)
//PanicAlert("WmRequestStatus");
LOGV(WII_IPC_WIIMOTE, 0, "================================================");
LOGV(WII_IPC_WIIMOTE, 0, " Request Status");
LOGV(WII_IPC_WIIMOTE, 0, " Rumble: %x", rs->rumble);
LOGV(WII_IPC_WIIMOTE, 0, " Channel: %04x", _channelID);
LOGV(WII_IPC_WIIMOTE, 0, " Rumble: %x", rs->rumble);
LOGV(WII_IPC_WIIMOTE, 0, " Channel: %04x", _channelID);
//SendStatusReport();
u8 DataFrame[1024];
@ -508,9 +478,16 @@ void WmRequestStatus(u16 _channelID, wm_request_status* rs)
memset(pStatus, 0, sizeof(wm_status_report)); // fill the status report with zeroes
// Status values
pStatus->leds = g_Leds;
pStatus->ir = 1;
pStatus->battery = 0x4F; //arbitrary number
pStatus->battery_low = 0; // battery is okay
pStatus->leds = g_Leds; // current setting
pStatus->ir = g_IR; // current setting
/* Battery levels in voltage
0x00 - 0x32: level 1
0x33 - 0x43: level 2
0x33 - 0x54: level 3
0x55 - 0xff: level 4 */
pStatus->battery = 0x5f; // fully charged
// Read config value for this one
if(g_Config.bExtensionConnected)
@ -518,11 +495,14 @@ void WmRequestStatus(u16 _channelID, wm_request_status* rs)
else
pStatus->extension = 0;
LOGV(WII_IPC_WIIMOTE, 0, " Extension: %x", pStatus->extension);
LOGV(WII_IPC_WIIMOTE, 0, " SendStatusReport()");
LOGV(WII_IPC_WIIMOTE, 0, " Flags: 0x%02x", pStatus->padding1[2]);
LOGV(WII_IPC_WIIMOTE, 0, " Battery: %d", pStatus->battery);
LOGV(WII_IPC_WIIMOTE, 0, " Extension: %x", pStatus->extension);
LOGV(WII_IPC_WIIMOTE, 0, " SendStatusReport()");
LOGV(WII_IPC_WIIMOTE, 0, " Flags: 0x%02x", pStatus->padding1[2]);
LOGV(WII_IPC_WIIMOTE, 0, " Battery: %d", pStatus->battery);
//std::string Temp = WiiMoteEmu::ArrayToString(DataFrame, Offset, 0);
//wprintf("Status Report: %s\n", Temp.c_str());
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
LOGV(WII_IPC_WIIMOTE, 0, "=================================================");
}

View File

@ -30,10 +30,7 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size);
void ControlChannel(u16 _channelID, const void* _pData, u32 _Size) ;
void Update();
//void FillReportIRBasic(wm_ir_basic& _ir0, wm_ir_basic& _ir1);
void ReadExt(); // Debugging
void ReadExtTmp();
std::string ArrayToString(const u8 *data, u32 size, u32 offset = 0, int line_len = 20);
};

View File

@ -159,12 +159,12 @@ void Shutdown(void)
// ----------------
void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
{
LOGV(WII_IPC_WIIMOTE, 0, "=============================================================");
LOGV(WII_IPC_WIIMOTE, 3, "=============================================================");
const u8* data = (const u8*)_pData;
// Debugging. Dump raw data.
{
LOG(WII_IPC_WIIMOTE, "Wiimote_Input");
LOGV(WII_IPC_WIIMOTE, 3, "Wiimote_Input");
std::string Temp;
for (u32 j=0; j<_Size; j++)
{
@ -172,7 +172,7 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
sprintf(Buffer, "%02x ", data[j]);
Temp.append(Buffer);
}
LOG(WII_IPC_WIIMOTE, " Data: %s", Temp.c_str());
LOGV(WII_IPC_WIIMOTE, 3, " Data: %s", Temp.c_str());
}
hid_packet* hidp = (hid_packet*) data;
@ -209,7 +209,7 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
PanicAlert("HidInput: Unknown type 0x%02x and param 0x%02x", hidp->type, hidp->param);
break;
}
LOGV(WII_IPC_WIIMOTE, 0, "=============================================================");
LOGV(WII_IPC_WIIMOTE, 3, "=============================================================");
}

View File

@ -40,8 +40,8 @@ namespace WiiMoteEmu
//******************************************************************************
//extern u8 g_Leds = 0x1;
extern u8 g_Leds;
extern u8 g_IR;
extern u8 g_Eeprom[WIIMOTE_EEPROM_SIZE];

View File

@ -40,30 +40,23 @@ namespace WiiMoteEmu
//******************************************************************************
/* Debugging. Read out the structs. */
void ReadExt()
// ===================================================
/* Debugging. Read out an u8 array. */
// ----------------
std::string ArrayToString(const u8 *data, u32 size, u32 offset, int line_len)
{
for (int i = 0; i < WIIMOTE_REG_EXT_SIZE; i++)
//const u8* _data = (const u8*)data;
std::string Temp;
for (u32 i = 0; i < size; i++)
{
//wprintf("%i | (i % 16)
wprintf("%02x ", g_RegExt[i]);
if((i + 1) % 20 == 0) wprintf("\n");
}
wprintf("\n\n");
}
void ReadExtTmp()
{
for (int i = 0; i < WIIMOTE_REG_EXT_SIZE; i++)
{
//wprintf("%i | (i % 16)
wprintf("%02x ", g_RegExtTmp[i]);
if((i + 1) % 20 == 0) wprintf("\n");
}
wprintf("\n\n");
char Buffer[128];
sprintf(Buffer, "%02x ", data[i + offset]);
if((i + 1) % line_len == 0) Temp.append("\n"); // break long lines
Temp.append(Buffer);
}
return Temp;
}
// ================
void FillReportInfo(wm_core& _core)
@ -525,7 +518,9 @@ void FillReportExtension(wm_extension& _ext)
// Clear g_RegExtTmp by copying zeroes to it
memset(g_RegExtTmp, 0, sizeof(g_RegExtTmp));
// Write the nunchuck inputs to it
/* Write the nunchuck inputs to it. We begin writing at 0x08, but it could also be
0x00, the important thing is that we begin at an address evenly divisible
by 0x08 */
g_RegExtTmp[0x08] = _ext.jx;
g_RegExtTmp[0x09] = _ext.jy;
g_RegExtTmp[0x0a] = _ext.ax;

View File

@ -156,53 +156,47 @@ extern "C" void Wiimote_Shutdown(void)
WiiMoteEmu::Shutdown();
}
// ===================================================
/* This function produce Wiimote Input (reports from the Wiimote) in response
to Output from the Wii. It's called from WII_IPC_HLE_WiiMote.cpp. */
// ----------------
extern "C" void Wiimote_InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
{
LOGV(WII_IPC_WIIMOTE, 0, "=============================================================");
LOGV(WII_IPC_WIIMOTE, 3, "=============================================================");
const u8* data = (const u8*)_pData;
// Debugging. Dump raw data.
// Debugging
{
LOG(WII_IPC_WIIMOTE, "Wiimote_Input");
LOG(WII_IPC_WIIMOTE, " Channel ID: %04x", _channelID);
std::string Temp;
for (u32 j=0; j<_Size; j++)
{
char Buffer[128];
sprintf(Buffer, "%02x ", data[j]);
Temp.append(Buffer);
}
LOG(WII_IPC_WIIMOTE, " Data: %s", Temp.c_str());
LOGV(WII_IPC_WIIMOTE, 3, "Wiimote_Input");
LOGV(WII_IPC_WIIMOTE, 3, " Channel ID: %04x", _channelID);
std::string Temp = WiiMoteEmu::ArrayToString(data, _Size);
LOGV(WII_IPC_WIIMOTE, 3, " Data: %s", Temp.c_str());
}
if (g_UseRealWiiMote)
WiiMoteReal::InterruptChannel(_channelID, _pData, _Size);
else
WiiMoteEmu::InterruptChannel(_channelID, _pData, _Size);
LOGV(WII_IPC_WIIMOTE, 0, "=============================================================");
LOGV(WII_IPC_WIIMOTE, 3, "=============================================================");
}
extern "C" void Wiimote_ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
{
LOGV(WII_IPC_WIIMOTE, 3, "=============================================================");
const u8* data = (const u8*)_pData;
// dump raw data
// Debugging
{
LOG(WII_IPC_WIIMOTE, "Wiimote_ControlChannel");
std::string Temp;
for (u32 j=0; j<_Size; j++)
{
char Buffer[128];
sprintf(Buffer, "%02x ", data[j]);
Temp.append(Buffer);
}
LOG(WII_IPC_WIIMOTE, " Data: %s", Temp.c_str());
LOGV(WII_IPC_WIIMOTE, 3, "Wiimote_ControlChannel");
std::string Temp = WiiMoteEmu::ArrayToString(data, _Size);
LOGV(WII_IPC_WIIMOTE, 3, " Data: %s", Temp.c_str());
}
if (g_UseRealWiiMote)
WiiMoteReal::ControlChannel(_channelID, _pData, _Size);
else
WiiMoteEmu::ControlChannel(_channelID, _pData, _Size);
LOGV(WII_IPC_WIIMOTE, 3, "=============================================================");
}
extern "C" void Wiimote_Update()

View File

@ -76,13 +76,13 @@ struct wm_request_status {
#define WM_STATUS_REPORT 0x20
struct wm_status_report {
u8 padding1[2];
u8 unknown : 1;
u8 padding1[2]; // two 00
u8 battery_low : 1;
u8 extension : 1;
u8 speaker : 1;
u8 ir : 1;
u8 leds : 4;
u8 padding2[2];
u8 padding2[2]; // two 00
u8 battery;
};