last WIP wiimote code

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@934 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
fires.gc 2008-10-22 09:48:54 +00:00
parent 054ff5a48f
commit 415366634f
5 changed files with 95 additions and 18 deletions

View File

@ -69,6 +69,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::IOCtlV(u32 _CommandAddress)
{
// wpadsampled.elf - patch so the USB_LOG will print somehting
// even it it wasn't very useful yet...
Memory::Write_U8(1, 0x80151488); // DebugLog
// Memory::Write_U8(1, 0x801514A8); // USB_LOG
// Memory::Write_U8(1, 0x801514D8); // WUD_DEBUGPrint
// Memory::Write_U8(1, 0x80148E09); // HID LOG
@ -398,7 +399,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventInquiryComplete()
SHCIEventInquiryComplete* pInquiryComplete = (SHCIEventInquiryComplete*)Event.m_buffer;
pInquiryComplete->EventType = 0x01;
pInquiryComplete->PayloadLength = sizeof(SHCIEventInquiryComplete) - 2;
pInquiryComplete->status = 0x00;
pInquiryComplete->Status = 0x00;
AddEventToQueue(Event);
@ -574,7 +575,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventReadClockOffsetComplete(u16 _
SHCIEventReadClockOffsetComplete* pReadClockOffsetComplete = (SHCIEventReadClockOffsetComplete*)Event.m_buffer;
pReadClockOffsetComplete->EventType = 0x1C;
pReadClockOffsetComplete->PayloadLength = sizeof(SHCIEventReadClockOffsetComplete) - 2;
pReadClockOffsetComplete->status = 0x00;
pReadClockOffsetComplete->Status = 0x00;
pReadClockOffsetComplete->ConnectionHandle = pWiiMote->GetConnectionHandle();
pReadClockOffsetComplete->ClockOffset = 0x3818;
@ -602,7 +603,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventReadRemoteVerInfo(u16 _connec
SHCIEventReadRemoteVerInfo* pReadRemoteVerInfo = (SHCIEventReadRemoteVerInfo*)Event.m_buffer;
pReadRemoteVerInfo->EventType = 0x0C;
pReadRemoteVerInfo->PayloadLength = sizeof(SHCIEventReadRemoteVerInfo) - 2;
pReadRemoteVerInfo->status = 0x00;
pReadRemoteVerInfo->Status = 0x00;
pReadRemoteVerInfo->ConnectionHandle = pWiiMote->GetConnectionHandle();
pReadRemoteVerInfo->lmp_version = pWiiMote->GetLMPVersion();
pReadRemoteVerInfo->manufacturer = pWiiMote->GetManufactorID();
@ -634,7 +635,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventReadRemoteFeatures(u16 _conne
SHCIEventReadRemoteFeatures* pReadRemoteFeatures = (SHCIEventReadRemoteFeatures*)Event.m_buffer;
pReadRemoteFeatures->EventType = 0x0C;
pReadRemoteFeatures->PayloadLength = sizeof(SHCIEventReadRemoteFeatures) - 2;
pReadRemoteFeatures->status = 0x00;
pReadRemoteFeatures->Status = 0x00;
pReadRemoteFeatures->ConnectionHandle = pWiiMote->GetConnectionHandle();
pReadRemoteFeatures->features[0] = pWiiMote->GetFeatures()[0];
pReadRemoteFeatures->features[1] = pWiiMote->GetFeatures()[1];
@ -700,7 +701,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventAuthenticationCompleted(u16 _
SHCIEventAuthenticationCompleted* pEventAuthenticationCompleted = (SHCIEventAuthenticationCompleted*)Event.m_buffer;
pEventAuthenticationCompleted->EventType = 0x06;
pEventAuthenticationCompleted->PayloadLength = sizeof(SHCIEventAuthenticationCompleted) - 2;
pEventAuthenticationCompleted->value = 0;
pEventAuthenticationCompleted->Status = 0;
pEventAuthenticationCompleted->Connection_Handle = _connectionHandle;
AddEventToQueue(Event);
@ -741,6 +742,36 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventModeChange(u16 _connectionHan
return true;
}
bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventDisconnect(u16 _connectionHandle, u8 _Reason)
{
CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_connectionHandle);
if (pWiiMote == NULL)
{
PanicAlert("SendEventDisconnect: Cant find WiiMote by connection handle %02x", _connectionHandle);
return false;
}
SQueuedEvent Event(sizeof(SHCIEventDisconnectCompleted), _connectionHandle);
SHCIEventDisconnectCompleted* pDisconnect = (SHCIEventDisconnectCompleted*)Event.m_buffer;
pDisconnect->EventType = 0x06;
pDisconnect->PayloadLength = sizeof(SHCIEventDisconnectCompleted) - 2;
pDisconnect->Status = 0;
pDisconnect->Connection_Handle = _connectionHandle;
pDisconnect->Reason = _Reason;
AddEventToQueue(Event);
// Log
LOG(WIIMOTE, "Event: SendEventDisconnect");
LOG(WIIMOTE, " Connection_Handle: 0x%04x", pDisconnect->Connection_Handle);
LOG(WIIMOTE, " Reason: 0x%02x", pDisconnect->Reason);
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@ -756,7 +787,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::ExecuteHCICommandMessage(const SHCICom
u8* pInput = Memory::GetPointer(_rHCICommandMessage.m_PayLoadAddr + 3);
SCommandMessage* pMsg = (SCommandMessage*)Memory::GetPointer(_rHCICommandMessage.m_PayLoadAddr);
// LOG(WIIMOTE, "ExecuteHCICommandMessage(0x%04x)", pMsg->Opcode);
LOG(WIIMOTE, "****************************** ExecuteHCICommandMessage(0x%04x)", pMsg->Opcode);
switch(pMsg->Opcode)
{
@ -881,7 +912,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::ExecuteHCICommandMessage(const SHCICom
break;
case HCI_CMD_DISCONNECT:
PanicAlert("HCI_CMD_DISCONNECT is not implemented");
CommandDisconnect(pInput);
break;
//
// --- default ---
@ -1261,9 +1292,13 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandInquiry(u8* _Input)
LOG(WIIMOTE, " num_responses: %i (N x 1.28) sec", pInquiry->num_responses);
SendEventCommandStatus(HCI_CMD_INQUIRY);
SendEventInquiryResponse();
SendEventInquiryComplete();
if (g_GlobalHandle == 0)
{
SendEventInquiryResponse();
}
/*
SendEventInquiryComplete(); */
}
void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteInquiryScanType(u8* _Input)
@ -1488,6 +1523,23 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandSniffMode(u8* _Input)
SendEventModeChange(pSniffMode->con_handle, 0x02, pSniffMode->max_interval); // sniff mode
}
void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandDisconnect(u8* _Input)
{
// command parameters
hci_discon_cp* pDiscon = (hci_discon_cp*)_Input;
LOG(WIIMOTE, "Command: HCI_CMD_DISCONNECT");
LOG(WIIMOTE, "Input:");
LOG(WIIMOTE, " ConnectionHandle: 0x%04x", pDiscon->con_handle);
LOG(WIIMOTE, " Reason: 0x%02x", pDiscon->reason);
SendEventCommandStatus(HCI_CMD_DISCONNECT);
SendEventDisconnect(pDiscon->con_handle, pDiscon->reason);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//
//

View File

@ -161,6 +161,7 @@ private:
bool SendEventNumberOfCompletedPackets(u16 _connectionHandle, u16 _count);
bool SendEventAuthenticationCompleted(u16 _connectionHandle);
bool SendEventModeChange(u16 _connectionHandle, u8 _mode, u16 _value);
bool SendEventDisconnect(u16 _connectionHandle, u8 _Reason);
// Execute HCI Message
void ExecuteHCICommandMessage(const SHCICommandMessage& _rCtrlMessage);
@ -178,6 +179,7 @@ private:
void CommandReadRemoteFeatures(u8* _Input);
void CommandAuthenticationRequested(u8* _Input);
void CommandInquiry(u8* _Input);
void CommandDisconnect(u8* _Input);
// OGF 0x02 Link policy commands and return parameters
void CommandWriteLinkPolicy(u8* _Input);

View File

@ -2426,14 +2426,14 @@ struct SHCIEventInquiryComplete
{
u8 EventType;
u8 PayloadLength;
u8 status;
u8 Status;
};
struct SHCIEventReadClockOffsetComplete
{
u8 EventType;
u8 PayloadLength;
u8 status;
u8 Status;
u16 ConnectionHandle;
u16 ClockOffset;
};
@ -2442,7 +2442,7 @@ struct SHCIEventReadRemoteVerInfo
{
u8 EventType;
u8 PayloadLength;
u8 status;
u8 Status;
u16 ConnectionHandle;
u8 lmp_version;
u16 manufacturer;
@ -2453,7 +2453,7 @@ struct SHCIEventReadRemoteFeatures
{
u8 EventType;
u8 PayloadLength;
u8 status;
u8 Status;
u16 ConnectionHandle;
u8 features[HCI_FEATURES_SIZE];
};
@ -2509,7 +2509,7 @@ struct SHCIEventAuthenticationCompleted
{
u8 EventType;
u8 PayloadLength;
u8 value;
u8 Status;
u16 Connection_Handle;
};
@ -2524,6 +2524,17 @@ struct SHCIEventModeChange
u16 Value;
};
struct SHCIEventDisconnectCompleted
{
u8 EventType;
u8 PayloadLength;
u8 Status;
u16 Connection_Handle;
u8 Reason;
};
#ifdef __cplusplus
}
#endif

View File

@ -278,10 +278,11 @@ extern "C" void Wiimote_Update() {
switch(g_ReportingMode) {
case 0:
break;
case WM_REPORT_CORE: SendReportCore(g_ReportingChannel); break;
case WM_REPORT_CORE: SendReportCoreAccel(g_ReportingChannel); break;
case WM_REPORT_CORE_ACCEL: SendReportCoreAccel(g_ReportingChannel); break;
case WM_REPORT_CORE_ACCEL_IR12: SendReportCoreAccelIr12(g_ReportingChannel);break;
}
// g_ReportingMode = 0;
}
extern "C" unsigned int Wiimote_GetAttachedControllers() {
@ -332,7 +333,9 @@ void WmLeds(u16 _channelID, wm_leds* leds) {
void WmDataReporting(u16 _channelID, wm_data_reporting* dr) {
LOG(WIIMOTE, " Set Data reporting mode");
LOG(WIIMOTE, " Rumble: %x", dr->rumble);
LOG(WIIMOTE, " Continuous: %x", dr->continuous);
LOG(WIIMOTE, " All The Time: %x (not only on data change)", dr->all_the_time);
LOG(WIIMOTE, " Rumble: %x", dr->rumble);
LOG(WIIMOTE, " Mode: 0x%02x", dr->mode);
@ -348,6 +351,15 @@ void WmDataReporting(u16 _channelID, wm_data_reporting* dr) {
}
}
void FillReportInfo(wm_report_core& _reportCore)
{
static bool bb = true;
bb = !bb;
_reportCore.c.a = bb ? 1 : 0;
}
void SendReportCore(u16 _channelID) {
u8 DataFrame[1024];
u32 Offset = WriteWmReport(_channelID, DataFrame, WM_REPORT_CORE);
@ -356,7 +368,7 @@ void SendReportCore(u16 _channelID) {
Offset += sizeof(wm_report_core);
memset(pReport, 0, sizeof(wm_report_core));
pReport->c.a = 1;
FillReportInfo(*pReport);
LOG(WIIMOTE, " SendReportCore()");

View File

@ -43,7 +43,8 @@ struct wm_leds {
struct wm_data_reporting {
u8 rumble : 1;
u8 continuous : 1;
u8 : 6;
u8 all_the_time : 1;
u8 : 5;
u8 mode;
};
@ -138,7 +139,6 @@ struct wm_ir_extended {
#define WM_REPORT_CORE 0x30
struct wm_report_core {
wm_core c;
wm_accel a;
};
#define WM_REPORT_CORE_ACCEL 0x31