From 6014fa6524b72f0e7fd34d6ac63c2a731eab0869 Mon Sep 17 00:00:00 2001 From: ayuanx Date: Sat, 26 Dec 2009 14:16:21 +0000 Subject: [PATCH] Oh Yeah! Now ASK! git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4731 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp | 92 ++++++------------- .../Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h | 1 + .../Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp | 14 +-- .../Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h | 2 +- Source/Core/Core/Src/IPC_HLE/hci.h | 2 - Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp | 8 ++ Source/Plugins/Plugin_Wiimote/Src/main.cpp | 27 +----- Source/Plugins/Plugin_Wiimote/Src/main.h | 1 - 8 files changed, 52 insertions(+), 95 deletions(-) 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 a4300e2a9b..782b9cb481 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 @@ -46,7 +46,7 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305::CWII_IPC_HLE_Device_usb_oh1_57e_305(u32 _De { // Activate the first one Wiimote by default m_WiiMotes.push_back(CWII_IPC_HLE_WiiMote(this, 0, true)); -// m_WiiMotes.push_back(CWII_IPC_HLE_WiiMote(this, 1)); + m_WiiMotes.push_back(CWII_IPC_HLE_WiiMote(this, 1)); // The BCM2045's btaddr: m_ControllerBD.b[0] = 0x11; @@ -77,6 +77,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::DoState(PointerWrap &p) { p.Do(m_LastCmd); p.Do(m_CtrlSetup); + p.Do(m_ACLSetup); p.Do(m_HCIBuffer); p.Do(m_HCIPool); p.Do(m_ACLBuffer); @@ -200,7 +201,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::IOCtlV(u32 _CommandAddress) { // This is the ACL datapath from CPU to Wiimote // Here we only need to record the command address in case we need to delay the reply - m_CtrlSetup.m_Address = CommandBuffer.m_Address; + m_ACLSetup = CommandBuffer.m_Address; #if defined(_DEBUG) || defined(DEBUGFAST) DumpAsync(CommandBuffer.BufferVector, _CommandAddress, CommandBuffer.NumberInBuffer, CommandBuffer.NumberPayloadBuffer); @@ -213,7 +214,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::IOCtlV(u32 _CommandAddress) _dbg_assert_(WII_IPC_WIIMOTE, pACLHeader->PBFlag == 2); SendToDevice(pACLHeader->ConnectionHandle, Memory::GetPointer(BulkBuffer.m_buffer + 4), pACLHeader->Size); - m_PacketCount[pACLHeader->ConnectionHandle & 0x1]++; + m_PacketCount[pACLHeader->ConnectionHandle & 0xFF]++; // If ACLPool is not used, we can send a reply immediately // or else we have to delay this reply @@ -423,7 +424,7 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() { PurgeACLPool(); if (m_ACLPool.m_number == 0) - WII_IPCInterface::EnqReply(m_CtrlSetup.m_Address); + WII_IPCInterface::EnqReply(m_ACLSetup); return true; } @@ -791,13 +792,13 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventRemoteNameReq(const bdaddr_t& pRemoteNameReq->bdaddr = _bd; strcpy((char*)pRemoteNameReq->RemoteName, pWiiMote->GetName()); - AddEventToQueue(Event); - INFO_LOG(WII_IPC_WIIMOTE, "Event: SendEventRemoteNameReq"); INFO_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", pRemoteNameReq->bdaddr.b[0], pRemoteNameReq->bdaddr.b[1], pRemoteNameReq->bdaddr.b[2], pRemoteNameReq->bdaddr.b[3], pRemoteNameReq->bdaddr.b[4], pRemoteNameReq->bdaddr.b[5]); - INFO_LOG(WII_IPC_WIIMOTE, " remotename: %s", pRemoteNameReq->RemoteName); + DEBUG_LOG(WII_IPC_WIIMOTE, " RemoteName: %s", pRemoteNameReq->RemoteName); + + AddEventToQueue(Event); return true; } @@ -815,7 +816,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventReadRemoteFeatures(u16 _conne pReadRemoteFeatures->EventType = HCI_EVENT_READ_REMOTE_FEATURES_COMPL; pReadRemoteFeatures->PayloadLength = sizeof(SHCIEventReadRemoteFeatures) - 2; pReadRemoteFeatures->Status = 0x00; - pReadRemoteFeatures->ConnectionHandle = pWiiMote->GetConnectionHandle(); + pReadRemoteFeatures->ConnectionHandle = _connectionHandle; pReadRemoteFeatures->features[0] = pWiiMote->GetFeatures()[0]; pReadRemoteFeatures->features[1] = pWiiMote->GetFeatures()[1]; pReadRemoteFeatures->features[2] = pWiiMote->GetFeatures()[2]; @@ -825,8 +826,6 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventReadRemoteFeatures(u16 _conne pReadRemoteFeatures->features[6] = pWiiMote->GetFeatures()[6]; pReadRemoteFeatures->features[7] = pWiiMote->GetFeatures()[7]; - AddEventToQueue(Event); - // Log INFO_LOG(WII_IPC_WIIMOTE, "Event: SendEventReadRemoteFeatures"); DEBUG_LOG(WII_IPC_WIIMOTE, " Connection_Handle: 0x%04x", pReadRemoteFeatures->ConnectionHandle); @@ -835,6 +834,8 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventReadRemoteFeatures(u16 _conne pReadRemoteFeatures->features[3], pReadRemoteFeatures->features[4], pReadRemoteFeatures->features[5], pReadRemoteFeatures->features[6], pReadRemoteFeatures->features[7]); + AddEventToQueue(Event); + return true; } @@ -850,13 +851,11 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventReadRemoteVerInfo(u16 _connec pReadRemoteVerInfo->EventType = HCI_EVENT_READ_REMOTE_VER_INFO_COMPL; pReadRemoteVerInfo->PayloadLength = sizeof(SHCIEventReadRemoteVerInfo) - 2; pReadRemoteVerInfo->Status = 0x00; - pReadRemoteVerInfo->ConnectionHandle = pWiiMote->GetConnectionHandle(); + pReadRemoteVerInfo->ConnectionHandle = _connectionHandle; pReadRemoteVerInfo->lmp_version = pWiiMote->GetLMPVersion(); pReadRemoteVerInfo->manufacturer = pWiiMote->GetManufactorID(); pReadRemoteVerInfo->lmp_subversion = pWiiMote->GetLMPSubVersion(); - AddEventToQueue(Event); - // Log INFO_LOG(WII_IPC_WIIMOTE, "Event: SendEventReadRemoteVerInfo"); DEBUG_LOG(WII_IPC_WIIMOTE, " Connection_Handle: 0x%04x", pReadRemoteVerInfo->ConnectionHandle); @@ -864,6 +863,8 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventReadRemoteVerInfo(u16 _connec DEBUG_LOG(WII_IPC_WIIMOTE, " manufacturer: 0x%04x", pReadRemoteVerInfo->manufacturer); DEBUG_LOG(WII_IPC_WIIMOTE, " lmp_subversion: 0x%04x", pReadRemoteVerInfo->lmp_subversion); + AddEventToQueue(Event); + return true; } @@ -886,10 +887,9 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventCommandComplete(u16 _OpCode, memcpy(pPayload, _pData, _DataSize); } - AddEventToQueue(Event); + INFO_LOG(WII_IPC_WIIMOTE, "Event: Command Complete (Opcode: 0x%04x)", pHCIEvent->Opcode); - INFO_LOG(WII_IPC_WIIMOTE, "Event: Command Complete"); - INFO_LOG(WII_IPC_WIIMOTE, " Opcode: 0x%04x", pHCIEvent->Opcode); + AddEventToQueue(Event); } bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventCommandStatus(u16 _Opcode) @@ -912,8 +912,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventCommandStatus(u16 _Opcode) pHCIEvent->PacketIndicator = 0x01; pHCIEvent->Opcode = _Opcode; - INFO_LOG(WII_IPC_WIIMOTE, "Event: Command Status"); - INFO_LOG(WII_IPC_WIIMOTE, " Opcode: 0x%04x", pHCIEvent->Opcode); + INFO_LOG(WII_IPC_WIIMOTE, "Event: Command Status (Opcode: 0x%04x)", pHCIEvent->Opcode); AddEventToQueue(Event); @@ -943,7 +942,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventRoleChange(bdaddr_t _bd, bool pRoleChange->EventType = HCI_EVENT_ROLE_CHANGE; pRoleChange->PayloadLength = sizeof(SHCIEventRoleChange) - 2; pRoleChange->Status = 0x00; - pRoleChange->bdaddr = pWiiMote->GetBD(); + pRoleChange->bdaddr = _bd; pRoleChange->NewRole = _master ? 0x00 : 0x01; AddEventToQueue(Event); @@ -1070,16 +1069,16 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventReadClockOffsetComplete(u16 _ pReadClockOffsetComplete->EventType = HCI_EVENT_READ_CLOCK_OFFSET_COMPL; pReadClockOffsetComplete->PayloadLength = sizeof(SHCIEventReadClockOffsetComplete) - 2; pReadClockOffsetComplete->Status = 0x00; - pReadClockOffsetComplete->ConnectionHandle = pWiiMote->GetConnectionHandle(); + pReadClockOffsetComplete->ConnectionHandle = _connectionHandle; pReadClockOffsetComplete->ClockOffset = 0x3818; - AddEventToQueue(Event); - // Log INFO_LOG(WII_IPC_WIIMOTE, "Event: SendEventReadClockOffsetComplete"); DEBUG_LOG(WII_IPC_WIIMOTE, " Connection_Handle: 0x%04x", pReadClockOffsetComplete->ConnectionHandle); DEBUG_LOG(WII_IPC_WIIMOTE, " ClockOffset: 0x%04x", pReadClockOffsetComplete->ClockOffset); + AddEventToQueue(Event); + return true; } @@ -1098,13 +1097,13 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305::SendEventConPacketTypeChange(u16 _conn pChangeConPacketType->ConnectionHandle = _connectionHandle; pChangeConPacketType->PacketType = _packetType; - AddEventToQueue(Event); - // Log INFO_LOG(WII_IPC_WIIMOTE, "Event: SendEventConPacketTypeChange"); DEBUG_LOG(WII_IPC_WIIMOTE, " Connection_Handle: 0x%04x", pChangeConPacketType->ConnectionHandle); DEBUG_LOG(WII_IPC_WIIMOTE, " PacketType: 0x%04x", pChangeConPacketType->PacketType); + AddEventToQueue(Event); + return true; } @@ -1386,46 +1385,18 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandDisconnect(u8* _Input) hci_discon_cp* pDiscon = (hci_discon_cp*)_Input; INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_DISCONNECT"); - DEBUG_LOG(WII_IPC_WIIMOTE, "Input:"); DEBUG_LOG(WII_IPC_WIIMOTE, " ConnectionHandle: 0x%04x", pDiscon->con_handle); DEBUG_LOG(WII_IPC_WIIMOTE, " Reason: 0x%02x", pDiscon->reason); SendEventDisconnect(pDiscon->con_handle, pDiscon->reason); - - // AyuanX : Disconnecting WiiMote is a bad idea because we don't support reconnect yet - // so let's don't do it - /* + CWII_IPC_HLE_WiiMote* pWiimote = AccessWiiMote(pDiscon->con_handle); if (pWiimote) pWiimote->EventDisconnect(); - // Here we should enable scan so reconnect is possible - m_ScanEnable = 0x2; - */ - - static bool OneShotMessage = true; - if (OneShotMessage) - { - OneShotMessage = false; - ERROR_LOG(WII_IPC_WIIMOTE, "IPC CommandDisconnect: WiiMote emulation is out of sync.\n" - "This message will be shot one time only, because Dolphin does\n" - "not execute the disconnect at all and sometimes you can keep\n" - "playing anyway. You are strongly recommended to save the game\n" - "and/or restart the emulation."); - PanicAlert("IPC CommandDisconnect: WiiMote emulation is out of sync.\n" - "This message will be shot one time only, because Dolphin does\n" - "not execute the disconnect at all and sometimes you can keep\n" - "playing anyway. You are strongly recommended to save the game\n" - "and/or restart the emulation."); - } - INFO_LOG(CONSOLE, "IPC CommandDisconnect\n"); - - // Send message to plugin - /* - Common::PluginWiimote* mote = CPluginManager::GetInstance().GetWiimote(0); + // Send disconnect message to plugin u8 Message = WIIMOTE_RECONNECT; - mote->Wiimote_ControlChannel(99, &Message, 0); - */ + CPluginManager::GetInstance().GetWiimote(0)->Wiimote_ControlChannel(pDiscon->con_handle & 0xFF, 99, &Message, 0); } void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandAcceptCon(u8* _Input) @@ -1460,7 +1431,6 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandAcceptCon(u8* _Input) #endif INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_ACCEPT_CON"); - DEBUG_LOG(WII_IPC_WIIMOTE, "Input:"); DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", pAcceptCon->bdaddr.b[0], pAcceptCon->bdaddr.b[1], pAcceptCon->bdaddr.b[2], pAcceptCon->bdaddr.b[3], pAcceptCon->bdaddr.b[4], pAcceptCon->bdaddr.b[5]); @@ -1473,7 +1443,6 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandLinkKeyRep(u8* _Input) hci_link_key_rep_cp* pKeyRep = (hci_link_key_rep_cp*)_Input; INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_LINK_KEY_REP"); - DEBUG_LOG(WII_IPC_WIIMOTE, "Input:"); DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", pKeyRep->bdaddr.b[0], pKeyRep->bdaddr.b[1], pKeyRep->bdaddr.b[2], pKeyRep->bdaddr.b[3], pKeyRep->bdaddr.b[4], pKeyRep->bdaddr.b[5]); @@ -1493,7 +1462,6 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandLinkKeyNegRep(u8* _Input) hci_link_key_neg_rep_cp* pKeyNeg = (hci_link_key_neg_rep_cp*)_Input; INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_LINK_KEY_NEG_REP"); - DEBUG_LOG(WII_IPC_WIIMOTE, "Input:"); DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", pKeyNeg->bdaddr.b[0], pKeyNeg->bdaddr.b[1], pKeyNeg->bdaddr.b[2], pKeyNeg->bdaddr.b[3], pKeyNeg->bdaddr.b[4], pKeyNeg->bdaddr.b[5]); @@ -1615,9 +1583,9 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandSniffMode(u8* _Input) SendEventModeChange(pSniffMode->con_handle, 0x02, pSniffMode->max_interval); // 0x02 - sniff mode - // Now is a good time to activate next wiimote + // Now it is a good time to activate next wiimote u16 NextHandle = pSniffMode->con_handle + 1; - if ((NextHandle & 0x1u) < m_WiiMotes.size()) + if ((NextHandle & 0xFFu) < m_WiiMotes.size()) { CWII_IPC_HLE_WiiMote* pWiimote = AccessWiiMote(NextHandle); if (pWiimote) @@ -1813,7 +1781,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteScanEnable(u8* _Input) }; #endif - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_WRITE_SCAN_ENABLE:"); + INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_WRITE_SCAN_ENABLE: (0x%02x)", pWriteScanEnable->scan_enable); DEBUG_LOG(WII_IPC_WIIMOTE, " scan_enable: %s", Scanning[pWriteScanEnable->scan_enable]); SendEventCommandComplete(HCI_CMD_WRITE_SCAN_ENABLE, &Reply, sizeof(hci_write_scan_enable_rp)); @@ -1876,7 +1844,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteLinkSupervisionTimeout(u8* SendEventCommandComplete(HCI_CMD_WRITE_LINK_SUPERVISION_TIMEOUT, &Reply, sizeof(hci_write_link_supervision_timeout_rp)); - // Now is a good time to link channels + // Now it is a good time to link channels CWII_IPC_HLE_WiiMote* pWiimote = AccessWiiMote(pSuperVision->con_handle); if (pWiimote) pWiimote->EventConnectionAccepted(); 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 2ec9146aa8..f00b8c3658 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 @@ -188,6 +188,7 @@ private: // STATE_TO_SAVE SHCICommandMessage m_CtrlSetup; + u32 m_ACLSetup; CtrlBuffer m_HCIBuffer; HCIPool m_HCIPool; CtrlBuffer m_ACLBuffer; 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 d01b922733..d4a835b84d 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 @@ -46,7 +46,7 @@ CWII_IPC_HLE_WiiMote::CWII_IPC_HLE_WiiMote(CWII_IPC_HLE_Device_usb_oh1_57e_305* { - INFO_LOG(WII_IPC_WIIMOTE, "Wiimote #%i constructed", _Number); + INFO_LOG(WII_IPC_WIIMOTE, "Wiimote: #%i Constructed", _Number); s_Usb = _pHost; @@ -235,7 +235,7 @@ void CWII_IPC_HLE_WiiMote::EventConnectionAccepted() void CWII_IPC_HLE_WiiMote::EventDisconnect() { - m_Connected = 0; + m_Connected = -1; m_Linked = false; // Clear channel flags ResetChannels(); @@ -321,13 +321,13 @@ void CWII_IPC_HLE_WiiMote::ExecuteL2capCmd(u8* _pData, u32 _Size) break; case HID_CONTROL_CHANNEL: - mote->Wiimote_ControlChannel(m_ConnectionHandle & 0x1, pHeader->CID, pData, DataSize); + mote->Wiimote_ControlChannel(m_ConnectionHandle & 0xFF, pHeader->CID, pData, DataSize); // Call Wiimote Plugin break; case HID_INTERRUPT_CHANNEL: ShowStatus(pData); - mote->Wiimote_InterruptChannel(m_ConnectionHandle & 0x1, pHeader->CID, pData, DataSize); + mote->Wiimote_InterruptChannel(m_ConnectionHandle & 0xFF, pHeader->CID, pData, DataSize); // Call Wiimote Plugin break; @@ -612,7 +612,7 @@ void CWII_IPC_HLE_WiiMote::SendConnectionRequest(u16 scid, u16 psm) cr.psm = psm; cr.scid = scid; - INFO_LOG(WII_IPC_WIIMOTE, "-------------------------------------"); + INFO_LOG(WII_IPC_WIIMOTE, "-----------------------------------------"); INFO_LOG(WII_IPC_WIIMOTE, "[L2CAP] SendConnectionRequest"); DEBUG_LOG(WII_IPC_WIIMOTE, " Psm: 0x%04x", cr.psm); DEBUG_LOG(WII_IPC_WIIMOTE, " Scid: 0x%04x", cr.scid); @@ -945,8 +945,8 @@ namespace Core { const u8* pData = (const u8*)_pData; - INFO_LOG(WIIMOTE, "=========================="); - INFO_LOG(WIIMOTE, "Callback_WiimoteInput: (Page: %i)", _number); + INFO_LOG(WIIMOTE, "===================="); + INFO_LOG(WIIMOTE, "Callback_WiimoteInput: (Wiimote: #%i)", _number); DEBUG_LOG(WIIMOTE, " Data: %s", ArrayToString(pData, _Size, 0, 50).c_str()); DEBUG_LOG(WIIMOTE, " Channel: %u", _channelID); 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 f577369854..22ae52fb67 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 @@ -213,7 +213,7 @@ public: const char* GetName() const { return m_Name.c_str(); } u8 GetLMPVersion() const { return lmp_version; } u16 GetLMPSubVersion() const { return lmp_subversion; } - u8 GetManufactorID() const { return 0xF; } // Broadcom Corporation + u16 GetManufactorID() const { return 0x000F; } // Broadcom Corporation const u8* GetLinkKey() const { return m_LinkKey; } private: diff --git a/Source/Core/Core/Src/IPC_HLE/hci.h b/Source/Core/Core/Src/IPC_HLE/hci.h index beccadeba5..a1f47e22d7 100644 --- a/Source/Core/Core/Src/IPC_HLE/hci.h +++ b/Source/Core/Core/Src/IPC_HLE/hci.h @@ -2507,8 +2507,6 @@ struct SHCIEventNumberOfCompletedPackets u8 EventType; u8 PayloadLength; u8 NumberOfHandles; - u16 Connection_Handle; - u16 Number_Of_Completed_Packets; }; struct SHCIEventAuthenticationCompleted diff --git a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp index 9a8d51ab59..f3632bad6d 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/EmuMain.cpp @@ -575,6 +575,14 @@ void InterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size void ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size) { + // Check for custom communication + if(_channelID == 99 && *(const u8*)_pData == WIIMOTE_RECONNECT) + { + WARN_LOG(WIIMOTE, "Wiimote: #%i Disconnected", _number); + g_ReportingAuto[_number] = false; + return; + } + g_RefreshWiimote = _number; hid_packet* hidp = (hid_packet*)_pData; diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.cpp b/Source/Plugins/Plugin_Wiimote/Src/main.cpp index 29342177c3..956cd732f0 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/main.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/main.cpp @@ -70,7 +70,6 @@ bool g_FrameOpen = false; bool g_RealWiiMotePresent = false; bool g_RealWiiMoteInitialized = false; bool g_EmulatedWiiMoteInitialized = false; -bool g_WiimoteUnexpectedDisconnect = false; // Settings accel_cal g_wm; @@ -283,7 +282,6 @@ void DoState(unsigned char **ptr, int mode) p.Do(g_RealWiiMotePresent); p.Do(g_RealWiiMoteInitialized); p.Do(g_EmulatedWiiMoteInitialized); - p.Do(g_WiimoteUnexpectedDisconnect); //p.Do(g_UpdateCounter); //p.Do(g_UpdateTime); //p.Do(g_UpdateRate); @@ -331,27 +329,12 @@ void Wiimote_InterruptChannel(int _number, u16 _channelID, const void* _pData, u void Wiimote_ControlChannel(int _number, u16 _channelID, const void* _pData, u32 _Size) { - const u8* data = (const u8*)_pData; - - // Check for custom communication - if(_channelID == 99 && data[0] == WIIMOTE_RECONNECT) - { - DEBUG_LOG(WIIMOTE, "Wiimote Disconnected"); - g_EmulatorRunning = false; - g_WiimoteUnexpectedDisconnect = true; - -#if defined(HAVE_WX) && HAVE_WX - if (m_BasicConfigFrame) m_BasicConfigFrame->UpdateGUI(); -#endif - return; - } - // Debugging - { - DEBUG_LOG(WIIMOTE, "Wiimote_ControlChannel"); - std::string Temp = ArrayToString(data, _Size); - DEBUG_LOG(WIIMOTE, " Data: %s", Temp.c_str()); - } +#if defined(_DEBUG) || defined(DEBUGFAST) + DEBUG_LOG(WIIMOTE, "Wiimote_ControlChannel"); + std::string Temp = ArrayToString((const u8*)_pData, _Size); + DEBUG_LOG(WIIMOTE, " Data: %s", Temp.c_str()); +#endif if (!g_Config.bUseRealWiimote || !g_RealWiiMotePresent) WiiMoteEmu::ControlChannel(_number, _channelID, _pData, _Size); diff --git a/Source/Plugins/Plugin_Wiimote/Src/main.h b/Source/Plugins/Plugin_Wiimote/Src/main.h index 197e351ea2..97c155dc1b 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/main.h +++ b/Source/Plugins/Plugin_Wiimote/Src/main.h @@ -66,7 +66,6 @@ struct SRecordingAll extern bool g_RealWiiMotePresent; extern bool g_RealWiiMoteInitialized; extern bool g_EmulatedWiiMoteInitialized; - extern bool g_WiimoteUnexpectedDisconnect; // Settings extern accel_cal g_wm;