diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 9df8d51bfa..aa1f35967c 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -76,7 +76,7 @@ void Callback_DSPLog(const TCHAR* _szMessage); void Callback_DSPInterrupt(); void Callback_PADLog(const TCHAR* _szMessage); void Callback_WiimoteLog(const TCHAR* _szMessage); -void Callback_WiimoteInput(const void* _pData, u32 _Size); +void Callback_WiimoteInput(u16 _channelID, const void* _pData, u32 _Size); // For keyboard shortcuts. void Callback_KeyPress(int key, BOOL shift, BOOL control); diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp index 6c68e0b6a8..6f6e3ccf43 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp @@ -174,6 +174,8 @@ bool AckCommand(u32 _Address) CCPU::Break(); Count++; */ + LOG(WII_IPC_HLE, "AckCommand: 0%08x", _Address); + m_Ack.push(_Address); return true; 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 0a5f114d3a..04606cbb48 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 @@ -19,6 +19,9 @@ #include "../Plugins/Plugin_Wiimote.h" #include +int g_HCICount = 0; +int globalHandle = 0; + CWII_IPC_HLE_Device_usb_oh1_57e_305::CWII_IPC_HLE_Device_usb_oh1_57e_305(u32 _DeviceID, const std::string& _rDeviceName) : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) , m_pACLBuffer(NULL) @@ -54,8 +57,11 @@ 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, 0x801514A8); // USB_LOG - Memory::Write_U8(1, 0x801514D8); // WUD_DEBUGPrint +// Memory::Write_U8(1, 0x801514A8); // USB_LOG +// Memory::Write_U8(1, 0x801514D8); // WUD_DEBUGPrint + + Memory::Write_U8(1, 0x80148E09); // HID LOG + SIOCtlVBuffer CommandBuffer(_CommandAddress); @@ -228,7 +234,6 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() } #endif - //LOG(WIIMOTE, "Update() %i 0x%08x", m_HCICommandMessageQueue.size(), m_pHCIBuffer); if (!m_EventQueue.empty() && m_pHCIBuffer) { // copy the event to memory @@ -241,6 +246,11 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() // return reply buffer size Memory::Write_U32(rEvent.m_size, m_pHCIBuffer->m_Address + 0x4); + if (rEvent.m_connectionHandle > 0) + { + g_HCICount++; + } + m_EventQueue.pop(); } @@ -265,7 +275,7 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() return Addr; } - + // check if we can fill the aclbuffer if(!m_AclFrameQue.empty() && m_pACLBuffer) { @@ -290,11 +300,15 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() delete m_pACLBuffer; m_pACLBuffer = NULL; - // SendEventNumberOfCompletedPackets(frame.ConnectionHandle); - return Addr; } + if (m_HCICommandMessageQueue.empty() && (globalHandle != 0) && (g_HCICount > 0)) + { + SendEventNumberOfCompletedPackets(globalHandle, g_HCICount*2); + g_HCICount = 0; + } + PluginWiimote::Wiimote_Update(); return 0; @@ -310,7 +324,7 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventCommandStatus(u16 _Opcode) { - SQueuedEvent Event(sizeof(SHCIEventStatus)); + SQueuedEvent Event(sizeof(SHCIEventStatus), 0); SHCIEventStatus* pHCIEvent = (SHCIEventStatus*)Event.m_buffer; pHCIEvent->EventType = 0x0F; @@ -322,14 +336,14 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventCommandStatus(u16 _Opcode) AddEventToQueue(Event); LOG(WIIMOTE, "Event: Command Status"); - LOG(WIIMOTE, " Opcode: %i", pHCIEvent->Opcode); + LOG(WIIMOTE, " Opcode: 0x%04x", pHCIEvent->Opcode); return true; } void CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventCommandComplete(u16 _OpCode, void* _pData, u32 _DataSize) { - SQueuedEvent Event(sizeof(SHCIEventCommand) + _DataSize); + SQueuedEvent Event(sizeof(SHCIEventCommand) + _DataSize, 0); SHCIEventCommand* pHCIEvent = (SHCIEventCommand*)Event.m_buffer; pHCIEvent->EventType = 0x0E; @@ -347,7 +361,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventCommandComplete(u16 _OpCode, AddEventToQueue(Event); LOG(WIIMOTE, "Event: Command Complete"); - LOG(WIIMOTE, " Opcode: %i", pHCIEvent->Opcode); + LOG(WIIMOTE, " Opcode: 0x%04x", pHCIEvent->Opcode); } bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventInquiryResponse() @@ -355,7 +369,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventInquiryResponse() if (m_WiiMotes.empty()) return false; - SQueuedEvent Event(sizeof(SHCIEventInquiryResult) + m_WiiMotes.size()*sizeof(hci_inquiry_response)); + SQueuedEvent Event(sizeof(SHCIEventInquiryResult) + m_WiiMotes.size()*sizeof(hci_inquiry_response), 0); SHCIEventInquiryResult* pInquiryResult = (SHCIEventInquiryResult*)Event.m_buffer; @@ -391,7 +405,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventInquiryResponse() bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventInquiryComplete() { - SQueuedEvent Event(sizeof(SHCIEventInquiryComplete)); + SQueuedEvent Event(sizeof(SHCIEventInquiryComplete), 0); SHCIEventInquiryComplete* pInquiryComplete = (SHCIEventInquiryComplete*)Event.m_buffer; pInquiryComplete->EventType = 0x01; @@ -416,7 +430,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventRemoteNameReq(bdaddr_t _bd) return false; } - SQueuedEvent Event(sizeof(SHCIEventRemoteNameReq)); + SQueuedEvent Event(sizeof(SHCIEventRemoteNameReq), 0); SHCIEventRemoteNameReq* pRemoteNameReq = (SHCIEventRemoteNameReq*)Event.m_buffer; @@ -441,7 +455,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventRequestConnection() { const CWII_IPC_HLE_WiiMote rWiiMote = m_WiiMotes[0]; - SQueuedEvent Event(sizeof(SHCIEventRequestConnection)); + SQueuedEvent Event(sizeof(SHCIEventRequestConnection), 0); SHCIEventRequestConnection* pEventRequestConnection = (SHCIEventRequestConnection*)Event.m_buffer; @@ -488,7 +502,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventConnectionComplete(bdaddr_t _ return false; } - SQueuedEvent Event(sizeof(SHCIEventConnectionComplete)); + SQueuedEvent Event(sizeof(SHCIEventConnectionComplete), 0); SHCIEventConnectionComplete* pConnectionComplete = (SHCIEventConnectionComplete*)Event.m_buffer; @@ -502,6 +516,8 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventConnectionComplete(bdaddr_t _ AddEventToQueue(Event); + globalHandle = pConnectionComplete->Connection_Handle; + #ifdef LOGGING static char s_szLinkType[][128] = { @@ -533,7 +549,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventRoleChange(bdaddr_t _bd) return false; } - SQueuedEvent Event(sizeof(SHCIEventRoleChange)); + SQueuedEvent Event(sizeof(SHCIEventRoleChange), 0); SHCIEventRoleChange* pRoleChange = (SHCIEventRoleChange*)Event.m_buffer; @@ -565,7 +581,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventReadClockOffsetComplete(u16 _ return false; } - SQueuedEvent Event(sizeof(SHCIEventReadClockOffsetComplete)); + SQueuedEvent Event(sizeof(SHCIEventReadClockOffsetComplete), _connectionHandle); SHCIEventReadClockOffsetComplete* pReadClockOffsetComplete = (SHCIEventReadClockOffsetComplete*)Event.m_buffer; pReadClockOffsetComplete->EventType = 0x1C; @@ -593,7 +609,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventReadRemoteVerInfo(u16 _connec return false; } - SQueuedEvent Event(sizeof(SHCIEventReadRemoteVerInfo)); + SQueuedEvent Event(sizeof(SHCIEventReadRemoteVerInfo), _connectionHandle); SHCIEventReadRemoteVerInfo* pReadRemoteVerInfo = (SHCIEventReadRemoteVerInfo*)Event.m_buffer; pReadRemoteVerInfo->EventType = 0x0C; @@ -625,7 +641,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventReadRemoteFeatures(u16 _conne return false; } - SQueuedEvent Event(sizeof(SHCIEventReadRemoteFeatures)); + SQueuedEvent Event(sizeof(SHCIEventReadRemoteFeatures), _connectionHandle); SHCIEventReadRemoteFeatures* pReadRemoteFeatures = (SHCIEventReadRemoteFeatures*)Event.m_buffer; pReadRemoteFeatures->EventType = 0x0C; @@ -654,7 +670,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventReadRemoteFeatures(u16 _conne return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventNumberOfCompletedPackets(u16 _connectionHandle) +bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventNumberOfCompletedPackets(u16 _connectionHandle, u16 _count) { CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_connectionHandle); if (pWiiMote == NULL) @@ -663,14 +679,14 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventNumberOfCompletedPackets(u16 return false; } - SQueuedEvent Event(sizeof(SHCIEventNumberOfCompletedPackets)); + SQueuedEvent Event(sizeof(SHCIEventNumberOfCompletedPackets), 0); // zero, so this packet isnt counted SHCIEventNumberOfCompletedPackets* pNumberOfCompletedPackets = (SHCIEventNumberOfCompletedPackets*)Event.m_buffer; pNumberOfCompletedPackets->EventType = 0x13; pNumberOfCompletedPackets->PayloadLength = sizeof(SHCIEventReadRemoteFeatures) - 2; - pNumberOfCompletedPackets->value = 1; + pNumberOfCompletedPackets->NumberOfHandles = 1; pNumberOfCompletedPackets->Connection_Handle = _connectionHandle; - pNumberOfCompletedPackets->Number_Of_Completed_Packets = 1; + pNumberOfCompletedPackets->Number_Of_Completed_Packets = _count; AddEventToQueue(Event); @@ -691,12 +707,12 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventAuthenticationCompleted(u16 _ return false; } - SQueuedEvent Event(sizeof(SHCIEventAuthenticationCompleted)); + SQueuedEvent Event(sizeof(SHCIEventAuthenticationCompleted), _connectionHandle); SHCIEventAuthenticationCompleted* pEventAuthenticationCompleted = (SHCIEventAuthenticationCompleted*)Event.m_buffer; - pEventAuthenticationCompleted->EventType = 0x13; - pEventAuthenticationCompleted->PayloadLength = sizeof(SHCIEventReadRemoteFeatures) - 2; - pEventAuthenticationCompleted->value = 1; + pEventAuthenticationCompleted->EventType = 0x06; + pEventAuthenticationCompleted->PayloadLength = sizeof(SHCIEventAuthenticationCompleted) - 2; + pEventAuthenticationCompleted->value = 0; pEventAuthenticationCompleted->Connection_Handle = _connectionHandle; AddEventToQueue(Event); @@ -708,6 +724,36 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventAuthenticationCompleted(u16 _ return true; } +bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventModeChange(u16 _connectionHandle, u8 _mode, u16 _value) +{ + CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_connectionHandle); + if (pWiiMote == NULL) + { + PanicAlert("SendEventModeChange: Cant find WiiMote by connection handle %02x", _connectionHandle); + return false; + } + + SQueuedEvent Event(sizeof(SHCIEventModeChange), _connectionHandle); + + SHCIEventModeChange* pModeChange = (SHCIEventModeChange*)Event.m_buffer; + pModeChange->EventType = 0x14; + pModeChange->PayloadLength = sizeof(SHCIEventModeChange) - 2; + pModeChange->Status = 0; + pModeChange->Connection_Handle = _connectionHandle; + pModeChange->CurrentMode = _mode; + pModeChange->Value = _value; + + AddEventToQueue(Event); + + // Log + LOG(WIIMOTE, "Event: SendEventModeChange"); + LOG(WIIMOTE, " Connection_Handle: 0x%04x", pModeChange->Connection_Handle); + LOG(WIIMOTE, " missing other paramter :)"); + + return true; +} + + //////////////////////////////////////////////////////////////////////////////////////////////////// // @@ -842,6 +888,10 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::ExecuteHCICommandMessage(const SHCICom CommandAuthenticationRequested(pInput); break; + case HCI_CMD_SNIFF_MODE: + CommandSniffMode(pInput); + break; + // // --- default --- // @@ -1107,16 +1157,15 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteScanEnable(u8* _Input) SendEventCommandComplete(HCI_CMD_WRITE_SCAN_ENABLE, &Reply, sizeof(hci_write_scan_enable_rp)); // TODO: fix this ugly request connection hack :) - // for homebrew works this - if (pWriteScanEnable->scan_enable & 2) // check if page scan is enable - { + // for homebrew works this if (pWriteScanEnable->scan_enable & 2) // check if page scan is enable +/* { static bool first = true; if (first) { first = false; SendEventRequestConnection(); } - } + }*/ } void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteInquiryMode(u8* _Input) @@ -1208,6 +1257,8 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandInquiry(u8* _Input) SendEventCommandStatus(HCI_CMD_INQUIRY); SendEventInquiryResponse(); + + SendEventInquiryComplete(); } void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteInquiryScanType(u8* _Input) @@ -1394,8 +1445,8 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteLinkPolicy(u8* _Input) PanicAlert("The connect should be send after the command status... check it"); // for homebrew works this - CWII_IPC_HLE_WiiMote* pWiimote = AccessWiiMote(pLinkPolicy->con_handle); - pWiimote->Connect(); + // CWII_IPC_HLE_WiiMote* pWiimote = AccessWiiMote(pLinkPolicy->con_handle); + // pWiimote->Connect(); } void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandAuthenticationRequested(u8* _Input) @@ -1411,6 +1462,23 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandAuthenticationRequested(u8* _In SendEventAuthenticationCompleted(pAuthReq->con_handle); } +void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandSniffMode(u8* _Input) +{ + // command parameters + hci_sniff_mode_cp* pSniffMode = (hci_sniff_mode_cp*)_Input; + + LOG(WIIMOTE, "Command: HCI_CMD_SNIFF_MODE"); + LOG(WIIMOTE, "Input:"); + LOG(WIIMOTE, " ConnectionHandle: 0x%04x", pSniffMode->con_handle); + LOG(WIIMOTE, " max_interval: 0x%04x", pSniffMode->max_interval); + LOG(WIIMOTE, " min_interval: 0x%04x", pSniffMode->min_interval); + LOG(WIIMOTE, " attempt: 0x%04x", pSniffMode->attempt); + LOG(WIIMOTE, " timeout: 0x%04x", pSniffMode->timeout); + + SendEventCommandStatus(HCI_CMD_SNIFF_MODE); + SendEventModeChange(pSniffMode->con_handle, 0x02, pSniffMode->max_interval); // sniff mode +} + //////////////////////////////////////////////////////////////////////////////////////////////////// // // 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 96dd75711e..4434fff2aa 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 @@ -45,8 +45,11 @@ struct SQueuedEvent { u8 m_buffer[1024]; size_t m_size; - SQueuedEvent(size_t size) : - m_size(size) + u16 m_connectionHandle; + + SQueuedEvent(size_t size, u16 connectionHandle) + : m_size(size) + , m_connectionHandle(connectionHandle) {} }; @@ -138,8 +141,9 @@ private: bool SendEventReadRemoteVerInfo(u16 _connectionHandle); bool SendEventReadRemoteFeatures(u16 _connectionHandle); bool SendEventRoleChange(bdaddr_t _bd); - bool SendEventNumberOfCompletedPackets(u16 _connectionHandle); + bool SendEventNumberOfCompletedPackets(u16 _connectionHandle, u16 _count); bool SendEventAuthenticationCompleted(u16 _connectionHandle); + bool SendEventModeChange(u16 _connectionHandle, u8 _mode, u16 _value); void ExecuteHCICommandMessage(const SHCICommandMessage& _rCtrlMessage); @@ -172,6 +176,7 @@ private: void CommandReadRemoteFeatures(u8* _Input); void CommandWriteLinkPolicy(u8* _Input); void CommandAuthenticationRequested(u8* _Input); + void CommandSniffMode(u8* _Input); void SendToDevice(u16 _ConnectionHandle, u8* _pData, u32 _Size); 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 6768baa5d6..bd49130e5c 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 @@ -30,12 +30,6 @@ #define HIDP_OUTPUT_CHANNEL 0x11 #define HIDP_INPUT_CHANNEL 0x13 -// #define HID_OUTPUT_SCID 0x1234 -// #define HID_INPUT_SCID 0x5678 - - -#define HID_OUTPUT_SCID 0x0040 -#define HID_INPUT_SCID 0x0040 struct SL2CAP_Header { @@ -138,8 +132,9 @@ struct SL2CAP_CommandDisconnectionResponse // 0x07 static CWII_IPC_HLE_Device_usb_oh1_57e_305* s_Usb; namespace Core { - void Callback_WiimoteInput(const void* _pData, u32 _Size) { - s_Usb->m_WiiMotes[0].SendL2capData(HID_OUTPUT_SCID, _pData, _Size); + void Callback_WiimoteInput(u16 _channelID, const void* _pData, u32 _Size) + { + s_Usb->m_WiiMotes[0].SendL2capData(_channelID, _pData, _Size); } } @@ -178,7 +173,7 @@ CWII_IPC_HLE_WiiMote::CWII_IPC_HLE_WiiMote(CWII_IPC_HLE_Device_usb_oh1_57e_305* void CWII_IPC_HLE_WiiMote::SendACLFrame(u8* _pData, u32 _Size) { - // dump raw data +/* // dump raw data { LOG(WIIMOTE, "SendToDevice: 0x%x", GetConnectionHandle()); std::string Temp; @@ -190,7 +185,7 @@ void CWII_IPC_HLE_WiiMote::SendACLFrame(u8* _pData, u32 _Size) } LOG(WIIMOTE, " Data: %s", Temp.c_str()); } - +*/ // parse the command SL2CAP_Header* pHeader = (SL2CAP_Header*)_pData; u8* pData = _pData + sizeof(SL2CAP_Header); @@ -224,8 +219,29 @@ void CWII_IPC_HLE_WiiMote::SendACLFrame(u8* _pData, u32 _Size) } break; + case 0x11: // HID Output + { + PanicAlert("CWII_IPC_HLE_WiiMote: HID Output %x, %x",rChannel.SCID, rChannel.DCID); + PluginWiimote::Wiimote_Output(rChannel.DCID, pData, DataSize); + + //return handshake + // u8 handshake = 0; + // SendL2capData(rChannel.DCID, &handshake, 1); + } + break; + + case 0x13: // HID Input + { + PluginWiimote::Wiimote_Input(rChannel.DCID, pData, DataSize); + + //return handshake + u8 handshake = 0; + SendL2capData(rChannel.DCID, &handshake, 1); + } + break; + default: - PanicAlert("channel %i has unknow PSM %x", pHeader->CID); + PanicAlert("channel 0x04%x has unknow PSM %x", pHeader->CID, rChannel.PSM); break; } } @@ -263,7 +279,7 @@ void CWII_IPC_HLE_WiiMote::SendCommandToACL(u8 _Ident, u8 _Code, u8 _CommandLeng m_pHost->SendACLFrame(GetConnectionHandle(), DataFrame, pHeader->Length + sizeof(SL2CAP_Header)); - // dump raw data +/* // dump raw data { LOG(WIIMOTE, "m_pHost->SendACLFrame: 0x%x", GetConnectionHandle()); std::string Temp; @@ -274,13 +290,13 @@ void CWII_IPC_HLE_WiiMote::SendCommandToACL(u8 _Ident, u8 _Code, u8 _CommandLeng Temp.append(Buffer); } LOG(WIIMOTE, " Data: %s", Temp.c_str()); - } + }*/ } void CWII_IPC_HLE_WiiMote::Connect() { - SendConnectionRequest(HID_OUTPUT_SCID, HIDP_OUTPUT_CHANNEL); - SendConnectionRequest(HID_INPUT_SCID, HIDP_INPUT_CHANNEL); + SendConnectionRequest(0x0040, HIDP_OUTPUT_CHANNEL); + SendConnectionRequest(0x0041, HIDP_INPUT_CHANNEL); } void CWII_IPC_HLE_WiiMote::SendConnectionRequest(u16 scid, u16 psm) @@ -340,6 +356,9 @@ void CWII_IPC_HLE_WiiMote::SendConfigurationRequest(u16 scid, u16* MTU, u16* Flu LOG(WIIMOTE, " Dcid: 0x%04x", cr->dcid); LOG(WIIMOTE, " Flags: 0x%04x", cr->flags); + // hack: + static u8 ident = 99; + ident++; SendCommandToACL(L2CAP_CONF_REQ, L2CAP_CONF_REQ, Offset, Buffer); } @@ -368,7 +387,6 @@ void CWII_IPC_HLE_WiiMote::SignalChannel(u8* _pData, u32 _Size) case L2CAP_DISCONN_REQ: CommandDisconnectionReq(pCommand->ident, _pData, pCommand->len); - PanicAlert("SignalChannel - L2CAP_DISCONN_REQ (something went wrong)",pCommand->code); break; case L2CAP_CONF_RSP: @@ -389,16 +407,6 @@ void CWII_IPC_HLE_WiiMote::SignalChannel(u8* _pData, u32 _Size) } } - -void CWII_IPC_HLE_WiiMote::HidOutput(u8* _pData, u32 _Size) -{ - PluginWiimote::Wiimote_Output(_pData, _Size); - - //return handshake - u8 handshake = 0; - SendL2capData(HID_OUTPUT_SCID, &handshake, 1); -} - void CWII_IPC_HLE_WiiMote::SendL2capData(u16 scid, const void* _pData, u32 _Size) { //allocate @@ -580,8 +588,6 @@ void CWII_IPC_HLE_WiiMote::CommandConnectionResponse(u8 _Ident, u8* _pData, u32 _dbg_assert_(WIIMOTE, DoesChannelExist(rsp->scid)); SChannel& rChannel = m_Channel[rsp->scid]; rChannel.DCID = rsp->dcid; - -// SendConfigurationRequest(rsp->scid); } void CWII_IPC_HLE_WiiMote::CommandDisconnectionReq(u8 _Ident, u8* _pData, u32 _Size) @@ -800,7 +806,7 @@ void CWII_IPC_HLE_WiiMote::SDPSendServiceAttributeResponse(u16 cid, u16 Transact m_pHost->SendACLFrame(GetConnectionHandle(), DataFrame, pHeader->Length + sizeof(SL2CAP_Header)); - // dump raw data +/* // dump raw data { LOG(WIIMOTE, "test response: 0x%x", GetConnectionHandle()); for (u32 j=0; jLength + sizeof(SL2CAP_Header);) @@ -819,14 +825,14 @@ void CWII_IPC_HLE_WiiMote::SDPSendServiceAttributeResponse(u16 cid, u16 Transact LOG(WIIMOTE, " Data: %s", Temp.c_str()); } - } + }*/ } void CWII_IPC_HLE_WiiMote::HandleSDP(u16 cid, u8* _pData, u32 _Size) { - // dump raw data +/* // dump raw data { LOG(WIIMOTE, "HandleSDP: 0x%x", GetConnectionHandle()); std::string Temp; @@ -838,7 +844,7 @@ void CWII_IPC_HLE_WiiMote::HandleSDP(u16 cid, u8* _pData, u32 _Size) } LOG(WIIMOTE, " Data: %s", Temp.c_str()); } - +*/ CBigEndianBuffer buffer(_pData); diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h index 96df9ff32f..7c434c9abe 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h @@ -145,8 +145,6 @@ private: void SignalChannel(u8* _pData, u32 _Size); - void HidOutput(u8* _pData, u32 _Size); - void SendConnectionRequest(u16 scid, u16 psm); void SendConfigurationRequest(u16 scid, u16* MTU, u16* FlushTimeOut); diff --git a/Source/Core/Core/Src/IPC_HLE/hci.h b/Source/Core/Core/Src/IPC_HLE/hci.h index ab5223a24b..1b1c703fd2 100644 --- a/Source/Core/Core/Src/IPC_HLE/hci.h +++ b/Source/Core/Core/Src/IPC_HLE/hci.h @@ -2500,7 +2500,7 @@ struct SHCIEventNumberOfCompletedPackets { u8 EventType; u8 PayloadLength; - u8 value; + u8 NumberOfHandles; u16 Connection_Handle; u16 Number_Of_Completed_Packets; }; @@ -2514,6 +2514,16 @@ struct SHCIEventAuthenticationCompleted }; +struct SHCIEventModeChange +{ + u8 EventType; + u8 PayloadLength; + u8 Status; + u16 Connection_Handle; + u8 CurrentMode; + u16 Value; + +}; #ifdef __cplusplus } #endif diff --git a/Source/Core/Core/Src/LogManager.cpp b/Source/Core/Core/Src/LogManager.cpp index 6d146ead9c..0fd149f542 100644 --- a/Source/Core/Core/Src/LogManager.cpp +++ b/Source/Core/Core/Src/LogManager.cpp @@ -180,6 +180,9 @@ u32 lastPC; std::string lastSymbol; void LogManager::Log(LogTypes::LOG_TYPE _type, const char *_fmt, ...) { + if (m_LogSettings == NULL) + return; + // declarations int v; // verbosity level int type; // the log type, CONSOLE etc. diff --git a/Source/Core/Core/Src/Plugins/Plugin_Wiimote.cpp b/Source/Core/Core/Src/Plugins/Plugin_Wiimote.cpp index 76a3a0b6ff..af4060f644 100644 --- a/Source/Core/Core/Src/Plugins/Plugin_Wiimote.cpp +++ b/Source/Core/Core/Src/Plugins/Plugin_Wiimote.cpp @@ -28,6 +28,7 @@ namespace PluginWiimote TWiimote_Initialize Wiimote_Initialize = 0; TWiimote_Shutdown Wiimote_Shutdown = 0; TWiimote_Output Wiimote_Output = 0; + TWiimote_Input Wiimote_Input = 0; TWiimote_Update Wiimote_Update = 0; TWiimote_GetAttachedControllers Wiimote_GetAttachedControllers = 0; TWiimote_DoState Wiimote_DoState = 0; @@ -50,6 +51,7 @@ namespace PluginWiimote Wiimote_Initialize = 0; Wiimote_Shutdown = 0; Wiimote_Output = 0; + Wiimote_Input = 0; Wiimote_Update = 0; Wiimote_GetAttachedControllers = 0; Wiimote_DoState = 0; @@ -65,6 +67,7 @@ namespace PluginWiimote Wiimote_Initialize = reinterpret_cast (plugin.Get("Wiimote_Initialize")); Wiimote_Shutdown = reinterpret_cast (plugin.Get("Wiimote_Shutdown")); Wiimote_Output = reinterpret_cast (plugin.Get("Wiimote_Output")); + Wiimote_Input = reinterpret_cast (plugin.Get("Wiimote_Input")); Wiimote_Update = reinterpret_cast (plugin.Get("Wiimote_Update")); Wiimote_GetAttachedControllers = reinterpret_cast (plugin.Get("Wiimote_GetAttachedControllers")); Wiimote_DoState = reinterpret_cast (plugin.Get("Wiimote_DoState")); @@ -74,6 +77,7 @@ 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_Input", Wiimote_Input); 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); @@ -81,6 +85,7 @@ namespace PluginWiimote (Wiimote_Initialize != 0) && (Wiimote_Shutdown != 0) && (Wiimote_Output != 0) && + (Wiimote_Input != 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 4db4bf617f..3e52f88514 100644 --- a/Source/Core/Core/Src/Plugins/Plugin_Wiimote.h +++ b/Source/Core/Core/Src/Plugins/Plugin_Wiimote.h @@ -33,19 +33,21 @@ 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 void (__cdecl* TWiimote_Output)(u16 _channelID, const void* _pData, u32 _Size); +typedef void (__cdecl* TWiimote_Input)(u16 _channelID, const void* _pData, u32 _Size); typedef unsigned int (__cdecl* TWiimote_GetAttachedControllers)(); typedef void (__cdecl* TWiimote_DoState)(void *ptr, int mode); // Function Pointers -extern TGetDllInfo GetDllInfo; -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; +extern TGetDllInfo GetDllInfo; +extern TDllConfig DllConfig; +extern TWiimote_Initialize Wiimote_Initialize; +extern TWiimote_Shutdown Wiimote_Shutdown; +extern TWiimote_Output Wiimote_Output; +extern TWiimote_Input Wiimote_Input; +extern TWiimote_Update Wiimote_Update; +extern TWiimote_GetAttachedControllers Wiimote_GetAttachedControllers; +extern TWiimote_DoState Wiimote_DoState; } // end of namespace PluginWiimote diff --git a/Source/PluginSpecs/pluginspecs_wiimote.h b/Source/PluginSpecs/pluginspecs_wiimote.h index bb9bc38bb8..7b93660d23 100644 --- a/Source/PluginSpecs/pluginspecs_wiimote.h +++ b/Source/PluginSpecs/pluginspecs_wiimote.h @@ -14,7 +14,7 @@ typedef void (*TLog)(const char* _pMessage); // Called when the Wiimote sends input reports to the Core. // Payload: an L2CAP packet. -typedef void (*TWiimoteInput)(const void* _pData, u32 _Size); +typedef void (*TWiimoteInput)(u16 _channelID, const void* _pData, u32 _Size); // This data is passed from the core on initialization. typedef struct @@ -71,7 +71,16 @@ EXPORT void CALL Wiimote_Shutdown(); // input: Da pakket. // output: none // -EXPORT void CALL Wiimote_Output(const void* _pData, u32 _Size); +EXPORT void CALL Wiimote_Output(u16 _channelID, const void* _pData, u32 _Size); + +// __________________________________________________________________________________________________ +// Function: Wiimote_Input +// Purpose: An L2CAP packet is passed from the Core to the Wiimote, +// on the HID INPUT channel. +// input: Da pakket. +// output: none +// +EXPORT void CALL Wiimote_Input(u16 _channelID, const void* _pData, u32 _Size); // __________________________________________________________________________________________________ // Function: Wiimote_Update diff --git a/Source/Plugins/Plugin_Wiimote_Test/Src/Wiimote.cpp b/Source/Plugins/Plugin_Wiimote_Test/Src/Wiimote.cpp index a3b26e59ec..73e6522192 100644 --- a/Source/Plugins/Plugin_Wiimote_Test/Src/Wiimote.cpp +++ b/Source/Plugins/Plugin_Wiimote_Test/Src/Wiimote.cpp @@ -27,6 +27,7 @@ u8 g_RegExt[WIIMOTE_REG_EXT_SIZE]; u8 g_RegIr[WIIMOTE_REG_IR_SIZE]; u8 g_ReportingMode; +u16 g_ReportingChannel; static const u8 EepromData_0[] = { 0xA1, 0xAA, 0x8B, 0x99, 0xAE, 0x9E, 0x78, 0x30, @@ -57,20 +58,21 @@ void __Log(int log, const char *format, ...) } //void PanicAlert(const char* fmt, ...); -void HidOutputReport(wm_report* sr); +void HidOutputReport(u16 _channelID, wm_report* sr); -void WmLeds(wm_leds* leds); -void WmReadData(wm_read_data* rd); -void WmWriteData(wm_write_data* wd); -void WmRequestStatus(wm_request_status* rs); -void WmDataReporting(wm_data_reporting* dr); +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 WmDataReporting(u16 _channelID, wm_data_reporting* dr); -void SendReadDataReply(void* _Base, u16 _Address, u8 _Size); -void SendWriteDataReply(); -void SendReportCoreAccel(); -void SendReportCoreAccelIr12(); +void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size); +void SendWriteDataReply(u16 _channelID); +void SendReportCoreAccel(u16 _channelID); +void SendReportCoreAccelIr12(u16 _channelID); +void SendReportCore(u16 _channelID); -int WriteWmReport(u8* dst, u8 channel); +int WriteWmReport(u16 _channelID, u8* dst, u8 channel); static u32 convert24bit(const u8* src) { return (src[0] << 16) | (src[1] << 8) | src[2]; @@ -165,7 +167,8 @@ extern "C" void Wiimote_Initialize(SWiimoteInitialize _WiimoteInitialize) g_ReportingMode = 0; } -extern "C" void Wiimote_DoState(void* ptr, int mode) { +extern "C" void Wiimote_DoState(void* ptr, int mode) +{ //TODO: implement } @@ -173,7 +176,50 @@ extern "C" void Wiimote_Shutdown(void) { } -extern "C" void Wiimote_Output(const void* _pData, u32 _Size) { +extern "C" void Wiimote_Input(u16 _channelID, const void* _pData, u32 _Size) +{ + + const u8* data = (const u8*)_pData; + + // dump raw data + { + LOG(WIIMOTE, "Wiimote_Input"); + std::string Temp; + for (u32 j=0; j<_Size; j++) + { + char Buffer[128]; + sprintf(Buffer, "%02x ", data[j]); + Temp.append(Buffer); + } + LOG(WIIMOTE, " Data: %s", Temp.c_str()); + } + hid_packet* hidp = (hid_packet*) data; + + switch(hidp->type) + { + case HID_TYPE_DATA: + { + switch(hidp->param) + { + case HID_PARAM_OUTPUT: + HidOutputReport(_channelID, (wm_report*)hidp->data); + break; + + default: + PanicAlert("HidInput: HID_TYPE_DATA - param 0x%02x", hidp->type, hidp->param); + break; + } + } + break; + + default: + PanicAlert("HidInput: Unknown type 0x%02x and param 0x%02x", hidp->type, hidp->param); + break; + } +} + +extern "C" void Wiimote_Output(u16 _channelID, const void* _pData, u32 _Size) +{ const u8* data = (const u8*)_pData; // dump raw data { @@ -189,11 +235,7 @@ extern "C" void Wiimote_Output(const void* _pData, u32 _Size) { } hid_packet* hidp = (hid_packet*) data; - - if ((hidp->param != HID_PARAM_INPUT) && (hidp->param != HID_PARAM_OUTPUT)) - { - PanicAlert("hidp->param has a wrong parameter!!!"); - } + PanicAlert("HidOutput: Unknown type %x and param %x", hidp->type, hidp->param); switch(hidp->type) { @@ -206,7 +248,6 @@ extern "C" void Wiimote_Output(const void* _pData, u32 _Size) { { PanicAlert("HID_TYPE_HANDSHAKE - HID_PARAM_OUTPUT"); } - g_ReportingMode = 0x33; break; case HID_TYPE_SET_REPORT: @@ -216,7 +257,7 @@ extern "C" void Wiimote_Output(const void* _pData, u32 _Size) { } else { - HidOutputReport((wm_report*)hidp->data); + HidOutputReport(_channelID, (wm_report*)hidp->data); } break; @@ -237,12 +278,9 @@ extern "C" void Wiimote_Update() { switch(g_ReportingMode) { case 0: break; - case 0x31: - SendReportCoreAccel(); - break; - case 0x33: - SendReportCoreAccelIr12(); - break; + case WM_REPORT_CORE: SendReportCore(g_ReportingChannel); break; + case WM_REPORT_CORE_ACCEL: SendReportCoreAccel(g_ReportingChannel); break; + case WM_REPORT_CORE_ACCEL_IR12: SendReportCoreAccelIr12(g_ReportingChannel);break; } } @@ -253,29 +291,29 @@ extern "C" unsigned int Wiimote_GetAttachedControllers() { //****************************************************************************** // Subroutines //****************************************************************************** -void HidOutputReport(wm_report* sr) { +void HidOutputReport(u16 _channelID, wm_report* sr) { LOG(WIIMOTE, " HidOutputReport(0x%02x)", sr->channel); switch(sr->channel) { case WM_LEDS: - WmLeds((wm_leds*)sr->data); + WmLeds(_channelID, (wm_leds*)sr->data); break; case WM_READ_DATA: - WmReadData((wm_read_data*)sr->data); + WmReadData(_channelID, (wm_read_data*)sr->data); break; case WM_REQUEST_STATUS: - WmRequestStatus((wm_request_status*)sr->data); + WmRequestStatus(_channelID, (wm_request_status*)sr->data); break; case WM_IR_PIXEL_CLOCK: case WM_IR_LOGIC: LOG(WIIMOTE, " IR Enable 0x%02x 0x%02x", sr->channel, sr->data[0]); break; case WM_WRITE_DATA: - WmWriteData((wm_write_data*)sr->data); + WmWriteData(_channelID, (wm_write_data*)sr->data); break; case WM_DATA_REPORTING: - WmDataReporting((wm_data_reporting*)sr->data); + WmDataReporting(_channelID, (wm_data_reporting*)sr->data); break; default: @@ -284,7 +322,7 @@ void HidOutputReport(wm_report* sr) { } } -void WmLeds(wm_leds* leds) { +void WmLeds(u16 _channelID, wm_leds* leds) { LOG(WIIMOTE, " Set LEDs"); LOG(WIIMOTE, " Leds: %x", leds->leds); LOG(WIIMOTE, " Rumble: %x", leds->rumble); @@ -292,25 +330,43 @@ void WmLeds(wm_leds* leds) { g_Leds = leds->leds; } -void WmDataReporting(wm_data_reporting* dr) { +void WmDataReporting(u16 _channelID, wm_data_reporting* dr) { LOG(WIIMOTE, " Set Data reporting mode"); LOG(WIIMOTE, " Continuous: %x", dr->continuous); LOG(WIIMOTE, " Rumble: %x", dr->rumble); LOG(WIIMOTE, " Mode: 0x%02x", dr->mode); g_ReportingMode = dr->mode; + g_ReportingChannel = _channelID; switch(g_ReportingMode) { //see Wiimote_Update() + case 0x30: case 0x31: case 0x33: break; default: - PanicAlert("Wiimote: Unknown reporting mode"); + PanicAlert("Wiimote: Unknown reporting mode 0x%x", dr->mode); } } -void SendReportCoreAccelIr12() { +void SendReportCore(u16 _channelID) { u8 DataFrame[1024]; - u32 Offset = WriteWmReport(DataFrame, WM_REPORT_CORE_ACCEL_IR12); + u32 Offset = WriteWmReport(_channelID, DataFrame, WM_REPORT_CORE); + + wm_report_core* pReport = (wm_report_core*)(DataFrame + Offset); + Offset += sizeof(wm_report_core); + memset(pReport, 0, sizeof(wm_report_core)); + + pReport->c.a = 1; + + LOG(WIIMOTE, " SendReportCore()"); + + g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset); +} + + +void SendReportCoreAccelIr12(u16 _channelID) { + u8 DataFrame[1024]; + u32 Offset = WriteWmReport(_channelID, DataFrame, WM_REPORT_CORE_ACCEL_IR12); wm_report_core_accel_ir12* pReport = (wm_report_core_accel_ir12*)(DataFrame + Offset); Offset += sizeof(wm_report_core_accel_ir12); @@ -364,12 +420,12 @@ void SendReportCoreAccelIr12() { LOG(WIIMOTE, " SendReportCoreAccelIr12()"); - g_WiimoteInitialize.pWiimoteInput(DataFrame, Offset); + g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset); } -void SendReportCoreAccel() { +void SendReportCoreAccel(u16 _channelID) { u8 DataFrame[1024]; - u32 Offset = WriteWmReport(DataFrame, WM_REPORT_CORE_ACCEL); + u32 Offset = WriteWmReport(_channelID, DataFrame, WM_REPORT_CORE_ACCEL); wm_report_core_accel* pReport = (wm_report_core_accel*)(DataFrame + Offset); Offset += sizeof(wm_report_core_accel); @@ -382,10 +438,10 @@ void SendReportCoreAccel() { LOG(WIIMOTE, " SendReportCoreAccel()"); - g_WiimoteInitialize.pWiimoteInput(DataFrame, Offset); + g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset); } -void WmReadData(wm_read_data* rd) { +void WmReadData(u16 _channelID, wm_read_data* rd) { u32 address = convert24bit(rd->address); u16 size = convert16bit(rd->size); LOG(WIIMOTE, " Read data"); @@ -395,13 +451,13 @@ void WmReadData(wm_read_data* rd) { LOG(WIIMOTE, " Rumble: %x", rd->rumble); if(size <= 16 && rd->space == 0) { - SendReadDataReply(g_Eeprom, address, (u8)size); + SendReadDataReply(_channelID, g_Eeprom, address, (u8)size); } else { PanicAlert("WmReadData: unimplemented parameters!"); } } -void WmWriteData(wm_write_data* wd) { +void WmWriteData(u16 _channelID, wm_write_data* wd) { u32 address = convert24bit(wd->address); LOG(WIIMOTE, " Write data"); LOG(WIIMOTE, " Address space: %x", wd->space); @@ -416,7 +472,7 @@ void WmWriteData(wm_write_data* wd) { return; } memcpy(g_Eeprom + address, wd->data, wd->size); - SendWriteDataReply(); + SendWriteDataReply(_channelID); } else if(wd->size <= 16 && (wd->space == WM_SPACE_REGS1 || wd->space == WM_SPACE_REGS2)) { @@ -445,22 +501,22 @@ void WmWriteData(wm_write_data* wd) { return; } memcpy(block + address, wd->data, wd->size); - SendWriteDataReply(); + SendWriteDataReply(_channelID); } else { PanicAlert("WmWriteData: unimplemented parameters!"); } } -void SendWriteDataReply() { +void SendWriteDataReply(u16 _channelID) { u8 DataFrame[1024]; - u32 Offset = WriteWmReport(DataFrame, WM_WRITE_DATA_REPLY); + u32 Offset = WriteWmReport(_channelID, DataFrame, WM_WRITE_DATA_REPLY); LOG(WIIMOTE, " SendWriteDataReply()"); - g_WiimoteInitialize.pWiimoteInput(DataFrame, Offset); + g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset); } -int WriteWmReport(u8* dst, u8 channel) { +int WriteWmReport(u16 _channelID, u8* dst, u8 channel) { u32 Offset = 0; hid_packet* pHidHeader = (hid_packet*)(dst + Offset); Offset += sizeof(hid_packet); @@ -473,13 +529,13 @@ int WriteWmReport(u8* dst, u8 channel) { return Offset; } -void WmRequestStatus(wm_request_status* rs) { +void WmRequestStatus(u16 _channelID, wm_request_status* rs) { LOG(WIIMOTE, " Request Status"); LOG(WIIMOTE, " Rumble: %x", rs->rumble); //SendStatusReport(); u8 DataFrame[1024]; - u32 Offset = WriteWmReport(DataFrame, WM_STATUS_REPORT); + u32 Offset = WriteWmReport(_channelID, DataFrame, WM_STATUS_REPORT); wm_status_report* pStatus = (wm_status_report*)(DataFrame + Offset); Offset += sizeof(wm_status_report); @@ -492,13 +548,13 @@ void WmRequestStatus(wm_request_status* rs) { LOG(WIIMOTE, " Flags: 0x%02x", pStatus->padding1[2]); LOG(WIIMOTE, " Battery: %d", pStatus->battery); - g_WiimoteInitialize.pWiimoteInput(DataFrame, Offset); + g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset); } -void SendReadDataReply(void* _Base, u16 _Address, u8 _Size) +void SendReadDataReply(u16 _channelID, void* _Base, u16 _Address, u8 _Size) { u8 DataFrame[1024]; - u32 Offset = WriteWmReport(DataFrame, WM_READ_DATA_REPLY); + u32 Offset = WriteWmReport(_channelID, DataFrame, WM_READ_DATA_REPLY); _dbg_assert_(WIIMOTE, _Size <= 16); @@ -519,5 +575,5 @@ void SendReadDataReply(void* _Base, u16 _Address, u8 _Size) LOG(WIIMOTE, " Size: 0x%x", pReply->size); LOG(WIIMOTE, " Address: 0x%04x", pReply->address); - g_WiimoteInitialize.pWiimoteInput(DataFrame, Offset); + g_WiimoteInitialize.pWiimoteInput(_channelID, DataFrame, Offset); } diff --git a/Source/Plugins/Plugin_Wiimote_Test/Src/wiimote_hid.h b/Source/Plugins/Plugin_Wiimote_Test/Src/wiimote_hid.h index 46d3a68d18..9f958bc122 100644 --- a/Source/Plugins/Plugin_Wiimote_Test/Src/wiimote_hid.h +++ b/Source/Plugins/Plugin_Wiimote_Test/Src/wiimote_hid.h @@ -136,6 +136,10 @@ 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 struct wm_report_core_accel {