Made Wiimote config dialog change generate Status report. Still no working connection however.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1204 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
John Peterson 2008-11-18 07:40:56 +00:00
parent 5b5e21e4b4
commit f67a608c7d
8 changed files with 194 additions and 17 deletions

View File

@ -942,6 +942,7 @@ namespace Core
{
void Callback_WiimoteInput(u16 _channelID, const void* _pData, u32 _Size)
{
LOGV(WII_IPC_WIIMOTE, 2, "=========================================================");
const u8* pData = (const u8*)_pData;
LOGV(WII_IPC_WIIMOTE, 2, "Callback_WiimoteInput: 0x%x", _channelID);
std::string Temp;
@ -951,8 +952,9 @@ namespace Core
sprintf(Buffer, "%02x ", pData[j]);
Temp.append(Buffer);
}
LOGV(WII_IPC_WIIMOTE, 3, " Data: %s", Temp.c_str());
LOGV(WII_IPC_WIIMOTE, 2, " Data: %s", Temp.c_str());
s_Usb->m_WiiMotes[0].SendL2capData(_channelID, _pData, _Size);
LOGV(WII_IPC_WIIMOTE, 2, "=========================================================");
}
}

View File

@ -15,10 +15,12 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
//#include "Common.h" // for u16
#include "ConfigDlg.h"
#include "Config.h"
#include "EmuSubroutines.h" // for WmRequestStatus_
//extern u16 WiiMoteEmu::g_channelID; // global id
BEGIN_EVENT_TABLE(ConfigDialog,wxDialog)
EVT_CLOSE(ConfigDialog::OnClose)
@ -128,6 +130,10 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event)
break;
case ID_EXTENSIONCONNECTED:
g_Config.bExtensionConnected = m_ExtensionConnected->IsChecked();
// generate connect/disconnect status event
if(WiiMoteEmu::g_channelID > 0)
WiiMoteEmu::WmRequestStatus_(WiiMoteEmu::g_channelID);
break;
}
}

View File

@ -38,6 +38,8 @@ namespace WiiMoteEmu
// Definitions and variable declarations
//******************************************************************************
u16 g_channelID;
u8 g_Leds = 0x1;
u8 g_Eeprom[WIIMOTE_EEPROM_SIZE];

View File

@ -31,16 +31,26 @@ extern SWiimoteInitialize g_WiimoteInitialize;
//extern void __Log(int log, const char *format, ...);
//extern void __Log(int log, int v, const char *format, ...);
namespace WiiMoteEmu
{
//******************************************************************************
// Subroutines
//******************************************************************************
//wm_request_status global_struct;
//extern wm_request_status global_struct;
//extern u16 g_channelID;
//void ReadExt();
// ===================================================
/* Here we process the Output Reports that the Wii sends. Our response will be an Input Report
back to the Wii. Input and Output is from the Wii's perspective, Output means data to
the Wiimote (from the Wii), Input means data from the Wiimote. */
// ----------------
void HidOutputReport(u16 _channelID, wm_report* sr) {
LOGV(WII_IPC_WIIMOTE, 0, "===========================================================");
@ -58,6 +68,7 @@ void HidOutputReport(u16 _channelID, wm_report* sr) {
WmReadData(_channelID, (wm_read_data*)sr->data);
break;
case WM_REQUEST_STATUS:
//global_struct = (wm_request_status*)sr->data;
WmRequestStatus(_channelID, (wm_request_status*)sr->data);
break;
case WM_IR_PIXEL_CLOCK:
@ -86,6 +97,7 @@ void HidOutputReport(u16 _channelID, wm_report* sr) {
LOGV(WII_IPC_WIIMOTE, 0, "===========================================================");
}
void WmLeds(u16 _channelID, wm_leds* leds) {
LOGV(WII_IPC_WIIMOTE, 0, "===========================================================");
@ -256,7 +268,8 @@ void WmReadData(u16 _channelID, wm_read_data* rd)
block = g_RegExt;
blockSize = WIIMOTE_REG_EXT_SIZE;
//PanicAlert("WmReadData: 0xA4 g_RegExt");
LOGV(WII_IPC_WIIMOTE, 0, "WmReadData: 0xA4 g_RegExt");
LOGV(WII_IPC_WIIMOTE, 0, " Case 0xA4: Read ExtReg ****************************");
//wprintf("WmReadData\n"); ReadExt();
break;
/* case 0xB0:
block = g_RegIr;
@ -274,6 +287,16 @@ void WmReadData(u16 _channelID, wm_read_data* rd)
return;
}
/*// Debugging
wprintf("WmReadData %08x %i\n", address, (u8)size);
for (int i = 0; i < sizeof(block+address); i++)
{
wprintf("%02x ", g_RegExt[i]);
if((i + 1) % 25 == 0) wprintf("\n");
}
wprintf("\n\n");
//---------*/
SendReadDataReply(_channelID, block+address, address, (u8)size);
}
else
@ -319,8 +342,9 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
case 0xA4:
block = g_RegExt; // Extension Controller register
blockSize = WIIMOTE_REG_EXT_SIZE;
LOGV(WII_IPC_WIIMOTE, 0, " Case 0xA4: Write g_RegExt *********************************");
PanicAlert(" Case 0xA4: Write g_RegExt");
LOGV(WII_IPC_WIIMOTE, 0, " Case 0xA4: Write ExtReg *********************************");
//PanicAlert(" Case 0xA4: Write g_RegExt");
//wprintf("WmWriteData\n"); ReadExt();
break;
case 0xB0:
block = g_RegIr;
@ -336,8 +360,25 @@ void WmWriteData(u16 _channelID, wm_write_data* wd)
return;
}
// finally write the registers to memory
/*// Debugging
if( ((address >> 16) & 0xFE) == 0xa4 )
{
wprintf("WmWriteData %i\n", wd->size);
for (int i = 0; i < sizeof(wd->data); i++)
{
wprintf("%02x ", wd->data[i]);
if((i + 1) % 25 == 0) wprintf("\n");
}
wprintf("\n\n");
}
//---------*/
memcpy(wd->data, block + address, wd->size);
} else {
PanicAlert("WmWriteData: unimplemented parameters!");
}
@ -360,12 +401,17 @@ int WriteWmReport(u8* dst, u8 channel) {
return Offset;
}
void WmRequestStatus(u16 _channelID, wm_request_status* rs)
// ===================================================
/* Here we produce status report to send to the Wii. We currently ignore the status
request rs and all its eventual instructions it may include (for example turn off
rumble or something else) and just send the status report. */
// ----------------
void WmRequestStatus_(u16 _channelID)
{
//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);
//SendStatusReport();
u8 DataFrame[1024];
@ -373,7 +419,7 @@ void WmRequestStatus(u16 _channelID, wm_request_status* rs)
wm_status_report* pStatus = (wm_status_report*)(DataFrame + Offset);
Offset += sizeof(wm_status_report);
memset(pStatus, 0, sizeof(wm_status_report));
memset(pStatus, 0, sizeof(wm_status_report)); // fill the status report with zeroes
pStatus->leds = g_Leds;
pStatus->ir = 1;
pStatus->battery = 0x4F; //arbitrary number
@ -393,6 +439,42 @@ void WmRequestStatus(u16 _channelID, wm_request_status* rs)
LOGV(WII_IPC_WIIMOTE, 0, "=================================================");
}
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);
//SendStatusReport();
u8 DataFrame[1024];
u32 Offset = WriteWmReport(DataFrame, WM_STATUS_REPORT);
wm_status_report* pStatus = (wm_status_report*)(DataFrame + Offset);
Offset += sizeof(wm_status_report);
memset(pStatus, 0, sizeof(wm_status_report)); // fill the status report with zeroes
pStatus->leds = g_Leds;
pStatus->ir = 1;
pStatus->battery = 0x4F; //arbitrary number
// this gets us passed the first error, but later brings up the disconnected error
if(g_Config.bExtensionConnected)
pStatus->extension = 1;
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);
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
LOGV(WII_IPC_WIIMOTE, 0, "=================================================");
}
void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size)
{
LOGV(WII_IPC_WIIMOTE, 0, "=========================================");
@ -414,7 +496,11 @@ void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size)
pReply->error = 0;
pReply->size = (copySize - 1) & 0xF;
pReply->address = Common::swap16(_Address + dataOffset);
memcpy(pReply->data + dataOffset, _Base, copySize);
if(copySize < 16)
{
memset(pReply->data + copySize, 0, 16 - copySize);
@ -427,6 +513,18 @@ 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\n");
for (int i = 0; i < sizeof(DataFrame); i++)
{
wprintf("%02x ", g_RegExt[i]);
if((i + 1) % 25 == 0) wprintf("\n");
}
wprintf("\n\n");
*/
//---------
g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset);
_Size -= copySize;

View File

@ -98,6 +98,14 @@ void Initialize()
// Write 0x0000 in encrypted form (0xfefe) to 0xfe in the extension register
WriteCrypted16(g_RegExt, 0xfe, 0x0000); // Fully inserted Nunchuk
/*
g_RegExt[0xfa] = 0x00;
g_RegExt[0xfb] = 0x00;
g_RegExt[0xfc] = 0xa4;
g_RegExt[0xfd] = 0x20;
g_RegExt[0xfe] = 0x00;
g_RegExt[0xff] = 0x00;
*/
// g_RegExt[0xfd] = 0x1e;
// g_RegExt[0xfc] = 0x9a;
@ -114,8 +122,15 @@ void Shutdown(void)
{
}
// ===================================================
/* This function produce Wiimote Input, i.e. reports from the Wiimote in response
to Output from the Wii. */
// ----------------
void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
{
g_channelID = _channelID; // store the channel id for manual use
LOGV(WII_IPC_WIIMOTE, 0, "=============================================================");
const u8* data = (const u8*)_pData;
@ -161,6 +176,7 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
LOGV(WII_IPC_WIIMOTE, 0, "=============================================================");
}
void ControlChannel(u16 _channelID, const void* _pData, u32 _Size)
{
const u8* data = (const u8*)_pData;

View File

@ -38,6 +38,8 @@ namespace WiiMoteEmu
// Definitions and variable declarations
//******************************************************************************
extern u16 g_channelID;
//extern u8 g_Leds = 0x1;
extern u8 g_Leds;
@ -73,6 +75,7 @@ void WmLeds(u16 _channelID, wm_leds* leds);
void WmReadData(u16 _channelID, wm_read_data* rd);
void WmWriteData(u16 _channelID, wm_write_data* wd);
void WmRequestStatus(u16 _channelID, wm_request_status* rs);
void WmRequestStatus_(u16 _channelID);
void WmDataReporting(u16 _channelID, wm_data_reporting* dr);
void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size);

View File

@ -33,16 +33,33 @@ extern SWiimoteInitialize g_WiimoteInitialize;
//extern void __Log(int log, const char *format, ...);
//extern void __Log(int log, int v, const char *format, ...);
namespace WiiMoteEmu
{
//******************************************************************************
// Subroutines
//******************************************************************************
bool toggleSideWays = false;
/*
void ReadExt()
{
for (int i = 0; i < WIIMOTE_REG_EXT_SIZE; i++)
{
//wprintf("%i | (i % 16)
wprintf("%02x ", g_RegExt[i]);
if((i + 1) % 20 == 0) wprintf("\n");
}
wprintf("\n\n");
}
*/
//bool AllowReport = true;
//int AllowCount = 0;
//bool toggleSideWays = false;
void FillReportInfo(wm_core& _core)
{
memset(&_core, 0x00, sizeof(wm_core));
@ -79,6 +96,34 @@ void FillReportInfo(wm_core& _core)
_core.right = GetAsyncKeyState(VK_RIGHT) ? 1 : 0;
_core.down = GetAsyncKeyState(VK_DOWN) ? 1 : 0;
}
/*
if(GetAsyncKeyState('M') && AllowReport)
{
//wm_report sr;
//wm_request_status *sr;
//WmRequestStatus(0x41, sr);
WmRequestStatus_(0x0041);
wprintf("Sent status report\n");
AllowReport = false;
AllowCount = 0;
void ReadExt();
}
*/
/*
if(AllowCount > 20)
{
AllowReport = true;
AllowCount = 0;
}
AllowCount++;
*/
#else
// TODO: fill in
#endif
@ -350,7 +395,7 @@ void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1)
// ----------------------------
// Debugging for calibration
// ----------
/**/
/*
if(GetAsyncKeyState(VK_NUMPAD1))
Right +=1;
else if(GetAsyncKeyState(VK_NUMPAD2))
@ -376,9 +421,8 @@ void FillReportIR(wm_ir_extended& _ir0, wm_ir_extended& _ir1)
//if(consoleDisplay == 1)
wprintf("x0:%03i x1:%03i y0:%03i y1:%03i irx0:%03i y0:%03i x1:%03i y1:%03i | T:%i L:%i R:%i B:%i S:%i\n",
x0, x1, y0, y1, _ir0.x, _ir0.y, _ir1.x, _ir1.y, Top, Left, Right, Bottom, SensorBarRadius
);
);
*/
}
void FillReportIRBasic(wm_ir_basic& _ir0, wm_ir_basic& _ir1)

View File

@ -138,11 +138,15 @@ extern "C" void Wiimote_Initialize(SWiimoteInitialize _WiimoteInitialize)
g_Config.Load(); // load config settings
// Debugging window
/*startConsoleWin(160, 30, "Wiimote"); // give room for 20 rows
/*startConsoleWin(100, 750, "Wiimote"); // give room for 20 rows
wprintf("Wiimote console opened\n");
MoveWindow(GetConsoleHwnd(), 0,400, 100*8,30*14, true); // move window, TODO: make this*/
// move window, TODO: make this
//MoveWindow(GetConsoleHwnd(), 0,400, 100*8,10*14, true); // small window
MoveWindow(GetConsoleHwnd(), 400,0, 100*8,70*14, true); // big window*/
}
extern "C" void Wiimote_DoState(void* ptr, int mode)
{
WiiMoteReal::DoState(ptr, mode);
@ -163,6 +167,8 @@ extern "C" void Wiimote_InterruptChannel(u16 _channelID, const void* _pData, u32
// dump raw data
{
LOG(WII_IPC_WIIMOTE, "Wiimote_Input");
LOG(WII_IPC_WIIMOTE, " Channel ID: %04x", _channelID);
std::string Temp;
for (u32 j=0; j<_Size; j++)
{