1) Added current core button status for all REPORT_IN, so now you can hold a tire and walk in "Mad World".

2) Commented out "SendEventNumberOfCompletedPackets()", I intend to have wider tests on this, if **this revision** causes frequent wiimote de-sync, please report.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4647 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
ayuanx 2009-12-05 20:01:48 +00:00
parent 6a5a90b9db
commit d117b438ae
4 changed files with 108 additions and 120 deletions

View File

@ -468,11 +468,13 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
}
}
// This seems not necessary at all or at least not helping to avoid de-sync at all???
/*
// AyuanX: This event should be sent periodically after ACL connection is accepted
// or CPU will disconnect WiiMote automatically
// but don't send too many or it will jam the bus and cost extra CPU time
//
if (m_HCIBuffer.m_address && m_WiiMotes[0].IsConnected())
if (m_HCIBuffer.m_address && !WII_IPCInterface::GetAddress() && m_WiiMotes[0].IsConnected())
{
m_FreqDividerSync++;
if ((m_PacketCount > 0) || (m_FreqDividerSync > 60)) // Feel free to tweak it
@ -483,6 +485,7 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
return true;
}
}
*/
// AyuanX: If we let this Wiimote_Update function running freely
// it will exaust all the HLE time slots and block further CPU commands

View File

@ -553,37 +553,14 @@ void InterruptChannel(u16 _channelID, const void* _pData, u32 _Size)
wm_report* sr = (wm_report*)hidp->data;
HidOutputReport(_channelID, sr);
/* This is the 0x22 answer to all Inputs. In most games it
didn't matter if it was written before or after
HidOutputReport(), but Wii Sports and Mario Galaxy would
stop working if it was placed before
HidOutputReport(). Zelda - TP is even more sensitive and
require a delay after the Input for the Nunchuck to
work. It seemed to be enough to delay only the Nunchuck
registry reads and writes but for now I'm delaying all
inputs. Both for status changes and Eeprom and registry
reads and writes. */
/* This is the 0x22 answer to all Inputs.*/
// There are no 0x22 replys to these report from the real
// wiimote from what I could see Report 0x10 that seems to
// be only used for rumble, and we don't need to answer
// that, also if we do *we should update the 0x22 to have
// the core keys* otherwise the game will think we release
// the key every time it rumbles
// AyuanX: Since I've rewritten the whole WII_IPC & WII_IPC_HLE & USB & BT
// finally we can get rid of this AckDelay issue, HAHA!
//
/*
const u8* data = (const u8*)_pData;
if(!(data[1] == WM_READ_DATA && data[2] == 0x00)
&& !(data[1] == WM_REQUEST_STATUS)
&& !(data[1] == WM_WRITE_SPEAKER_DATA)
&& !(data[1] == WM_RUMBLE))
if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent)
CreateAckDelay((u8)_channelID, (u16)sr->wm);
*/
// that
// The rumble report still needs more investigation
}
break;

View File

@ -55,6 +55,10 @@ namespace WiiMoteEmu
1. Wiimote_InterruptChannel > InterruptChannel > HidOutputReport
2. Wiimote_ControlChannel > ControlChannel > HidOutputReport
The IR lights and speaker enable/disable and mute/unmute values are
0x2 = Disable
0x6 = Enable
*/
void HidOutputReport(u16 _channelID, wm_report* sr)
{
@ -62,8 +66,8 @@ void HidOutputReport(u16 _channelID, wm_report* sr)
switch(sr->wm)
{
case 0x10:
// Unknown
case WM_RUMBLE: // 0x10
// TODO: Implement rumble
break;
case WM_LEDS: // 0x11
@ -104,6 +108,7 @@ void HidOutputReport(u16 _channelID, wm_report* sr)
break;
case WM_WRITE_SPEAKER_DATA: // 0x18
// TODO: Does this need an ack?
break;
case WM_SPEAKER_MUTE: // 0x19
@ -170,7 +175,7 @@ void WmSendAck(u16 _channelID, u8 _reportID)
u32 Offset = WriteWmReportHdr(DataFrame, WM_ACK_DATA);
wm_acknowledge* pData = (wm_acknowledge*)(DataFrame + Offset);
pData->buttons = 0;
FillReportInfo(pData->buttons);
pData->reportID = _reportID;
pData->errorID = 0;
Offset += sizeof(wm_acknowledge);
@ -311,7 +316,7 @@ void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, int _Size)
wm_read_data_reply* pReply = (wm_read_data_reply*)(DataFrame + Offset);
Offset += sizeof(wm_read_data_reply);
pReply->buttons = 0;
FillReportInfo(pReply->buttons);
pReply->error = 0;
// 0x1 means two bytes, 0xf means 16 bytes
pReply->size = copySize - 1;
@ -465,6 +470,7 @@ void WmRequestStatus(u16 _channelID, wm_request_status* rs, int Extension)
memset(pStatus, 0, sizeof(wm_status_report)); // fill the status report with zeroes
// Status values
FillReportInfo(pStatus->buttons);
pStatus->leds = g_Leds; // leds are 4 bit
pStatus->ir = g_IR; // 1 bit
pStatus->speaker = g_Speaker; // 1 bit

View File

@ -44,93 +44,6 @@ struct hid_packet {
//source: http://wiibrew.org/wiki/Wiimote
struct wm_report {
u8 wm;
u8 data[0];
};
#define WM_LEDS 0x11
struct wm_leds {
u8 rumble : 1;
u8 : 3;
u8 leds : 4;
};
#define WM_REPORT_MODE 0x12
struct wm_report_mode {
u8 rumble : 1;
u8 continuous : 1;
u8 all_the_time : 1;
u8 : 5;
u8 mode;
};
#define WM_IR_PIXEL_CLOCK 0x13
#define WM_IR_LOGIC 0x1A
#define WM_REQUEST_STATUS 0x15
struct wm_request_status {
u8 rumble : 1;
u8 : 7;
};
#define WM_STATUS_REPORT 0x20
struct wm_status_report {
u8 padding1[2]; // two 00
u8 battery_low : 1;
u8 extension : 1;
u8 speaker : 1;
u8 ir : 1;
u8 leds : 4;
u8 padding2[2]; // two 00
u8 battery;
};
#define WM_WRITE_DATA 0x16
struct wm_write_data
{
u8 rumble : 1;
u8 space : 2; //see WM_SPACE_*
u8 : 5;
u8 address[3];
u8 size;
u8 data[16];
};
#define WM_ACK_DATA 0x22
struct wm_acknowledge
{
u16 buttons;
u8 reportID;
u8 errorID;
};
#define WM_READ_DATA 0x17
struct wm_read_data {
u8 rumble : 1;
u8 space : 2; //see WM_SPACE_*
u8 : 5;
u8 address[3];
u8 size[2];
};
#define WM_SPACE_EEPROM 0
#define WM_SPACE_REGS1 1
#define WM_SPACE_REGS2 2
#define WM_SPACE_INVALID 3
#define WM_READ_DATA_REPLY 0x21
struct wm_read_data_reply {
u16 buttons;
u8 error : 4; //see WM_RDERR_*
u8 size : 4;
u16 address;
u8 data[16];
};
#define WM_RDERR_WOREG 7
#define WM_RDERR_NOMEM 8
struct wm_core {
u8 left : 1;
u8 right : 1;
@ -254,7 +167,96 @@ struct wm_GH3_extension
u8 Orange : 1;
};
struct wm_report {
u8 wm;
u8 data[0];
};
#define WM_RUMBLE 0x10
#define WM_LEDS 0x11
struct wm_leds {
u8 rumble : 1;
u8 : 3;
u8 leds : 4;
};
#define WM_REPORT_MODE 0x12
struct wm_report_mode {
u8 rumble : 1;
u8 continuous : 1;
u8 all_the_time : 1;
u8 : 5;
u8 mode;
};
#define WM_IR_PIXEL_CLOCK 0x13
#define WM_IR_LOGIC 0x1A
#define WM_REQUEST_STATUS 0x15
struct wm_request_status {
u8 rumble : 1;
u8 : 7;
};
#define WM_STATUS_REPORT 0x20
struct wm_status_report {
wm_core buttons;
u8 battery_low : 1;
u8 extension : 1;
u8 speaker : 1;
u8 ir : 1;
u8 leds : 4;
u8 padding2[2]; // two 00, TODO: this needs more investigation
u8 battery;
};
#define WM_WRITE_DATA 0x16
struct wm_write_data
{
u8 rumble : 1;
u8 space : 2; //see WM_SPACE_*
u8 : 5;
u8 address[3];
u8 size;
u8 data[16];
};
#define WM_ACK_DATA 0x22
struct wm_acknowledge
{
wm_core buttons;
u8 reportID;
u8 errorID;
};
#define WM_READ_DATA 0x17
struct wm_read_data {
u8 rumble : 1;
u8 space : 2; //see WM_SPACE_*
u8 : 5;
u8 address[3];
u8 size[2];
};
#define WM_SPACE_EEPROM 0
#define WM_SPACE_REGS1 1
#define WM_SPACE_REGS2 2
#define WM_SPACE_INVALID 3
#define WM_READ_DATA_REPLY 0x21
struct wm_read_data_reply {
wm_core buttons;
u8 error : 4; //see WM_RDERR_*
u8 size : 4;
u16 address;
u8 data[16];
};
#define WM_RDERR_WOREG 7
#define WM_RDERR_NOMEM 8
// Data reports