diff --git a/Binary/win32/WII/shared2/sys/SYSCONF b/Binary/win32/WII/shared2/sys/SYSCONF index 3b65d5399e..2ce0367bc2 100644 Binary files a/Binary/win32/WII/shared2/sys/SYSCONF and b/Binary/win32/WII/shared2/sys/SYSCONF differ 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 fbfdab264b..e7f2a08a6b 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 @@ -313,11 +313,18 @@ u32 CWII_IPC_HLE_Device_usb_oh1_57e_305::Update() return Addr; } - if(scan_enable && m_pHCIBuffer) { - //by now, the emulatee should be listening for incoming L2CAP packets. - //let's send a few. - SendEventRequestConnection(); - scan_enable = 0; + if(m_DelayedEvent != EVENT_NONE && m_pHCIBuffer) { + switch(m_DelayedEvent) { + case EVENT_REQUEST_CONNECTION: + SendEventRequestConnection(); + break; + case EVENT_CONNECTION_COMPLETE: + SendEventConnectionComplete(); + break; + default: + PanicAlert("Unknown Event in USBDev"); + } + m_DelayedEvent = EVENT_NONE; u32 Addr = m_pHCIBuffer->m_Address; delete m_pHCIBuffer; @@ -727,6 +734,10 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::ExecuteHCICommandMessage(const SHCICom case HCI_CMD_READ_REMOTE_FEATURES: CommandReadRemoteFeatures(pInput); break; + + case HCI_CMD_WRITE_LINK_POLICY_SETTINGS: + CommandWriteLinkPolicy(pInput); + break; // // --- default --- @@ -984,6 +995,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteScanEnable(u8* _Input) LOG(WIIMOTE, "write:"); LOG(WIIMOTE, " scan_enable: %s", Scanning[pWriteScanEnable->scan_enable]); + SetDelayedEvent(EVENT_REQUEST_CONNECTION); } void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteInquiryMode(u8* _Input) @@ -1190,19 +1202,30 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandCreateCon(u8* _Input) void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandAcceptCon(u8* _Input) { -#ifdef LOGGING // command parameters hci_accept_con_cp* pAcceptCon = (hci_accept_con_cp*)_Input; -#endif + + _dbg_assert_msg_(WIIMOTE, m_State == STATE_NONE, "m_State != NONE"); + m_State = STATE_CONNECTION_COMPLETE_EVENT; + m_StateTempBD = pAcceptCon->bdaddr; + SendEventCommandStatus(HCI_CMD_ACCEPT_CON); LOG(WIIMOTE, "Command: HCI_CMD_ACCEPT_CON"); LOG(WIIMOTE, "Input:"); - LOG(WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", + LOG(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]); LOG(WIIMOTE, " role: %i", pAcceptCon->role); } +void CWII_IPC_HLE_Device_usb_oh1_57e_305::SetDelayedEvent(EDelayedEvent e) +{ + if(m_DelayedEvent != EVENT_NONE) { + PanicAlert("WIIMOTE: Double delayed events!"); + } + m_DelayedEvent = e; +} + void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandReadClockOffset(u8* _Input) { // command parameters @@ -1245,9 +1268,23 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandReadRemoteFeatures(u8* _Input) LOG(WIIMOTE, "Command: HCI_CMD_READ_REMOTE_FEATURES"); LOG(WIIMOTE, "Input:"); - LOG(WIIMOTE, " ConnectionHandle: 0x%02x", pReadRemoteFeatures->con_handle); + LOG(WIIMOTE, " ConnectionHandle: 0x%04x", pReadRemoteFeatures->con_handle); } +void CWII_IPC_HLE_Device_usb_oh1_57e_305::CommandWriteLinkPolicy(u8* _Input) +{ + // command parameters + hci_write_link_policy_settings_cp* pLinkPolicy = (hci_write_link_policy_settings_cp*)_Input; + + SendEventCommandStatus(HCI_CMD_WRITE_LINK_POLICY_SETTINGS); + + LOG(WIIMOTE, "Command: HCI_CMD_WRITE_LINK_POLICY_SETTINGS"); + LOG(WIIMOTE, "Input:"); + LOG(WIIMOTE, " ConnectionHandle: 0x%04x", pLinkPolicy->con_handle); + LOG(WIIMOTE, " Policy: 0x%04x", pLinkPolicy->settings); +} + + CWII_IPC_HLE_WiiMote* CWII_IPC_HLE_Device_usb_oh1_57e_305::AccessWiiMote(const bdaddr_t& _rAddr) { for (size_t i=0; i m_HCICommandMessageQueue; + std::queue m_HCICommandMessageQueue; - bool m_ACLAnswer; - SIOCtlVBuffer* m_pACLBuffer; + bool m_ACLAnswer; + SIOCtlVBuffer* m_pACLBuffer; - SIOCtlVBuffer* m_pHCIBuffer; + SIOCtlVBuffer* m_pHCIBuffer; - bool SendEventCommandStatus(u16 _Opcode); + bool SendEventCommandStatus(u16 _Opcode); void SendEventCommandComplete(u16 _OpCode, void* _pData, u32 _DataSize); - bool SendEventInquiryResponse(); + bool SendEventInquiryResponse(); bool SendEventInquiryComplete(); - + bool SendEventRemoteNameReq(); bool SendEventRequestConnection(); bool SendEventConnectionComplete(); - bool SendEventReadClockOffsetComplete(); - bool SendEventReadRemoteVerInfo(); - bool SendEventReadRemoteFeatures(); + bool SendEventReadClockOffsetComplete(); + bool SendEventReadRemoteVerInfo(); + bool SendEventReadRemoteFeatures(); void ExecuteHCICommandMessage(const SHCICommandMessage& _rCtrlMessage); - // commands - void CommandReset(u8* _Input); - void CommandReadBufferSize(u8* _Input); - void CommandReadLocalVer(u8* _Input); - void CommandReadBDAdrr(u8* _Input); - void CommandReadLocalFeatures(u8* _Input); - void CommandReadStoredLinkKey(u8* _Input); - void CommandWriteUnitClass(u8* _Input); - void CommandWriteLocalName(u8* _Input); - void CommandWritePinType(u8* _Input); - void CommandHostBufferSize(u8* _Input); - void CommandWritePageTimeOut(u8* _Input); - void CommandWriteScanEnable(u8* _Input); - void CommandWriteInquiryMode(u8* _Input); - void CommandWritePageScanType(u8* _Input); - void CommandSetEventFilter(u8* _Input); - void CommandInquiry(u8* _Input); - void CommandWriteInquiryScanType(u8* _Input); - void CommandVendorSpecific_FC4C(u8* _Input, u32 _Size); - void CommandVendorSpecific_FC4F(u8* _Input, u32 _Size); - void CommandInquiryCancel(u8* _Input); + // commands + void CommandReset(u8* _Input); + void CommandReadBufferSize(u8* _Input); + void CommandReadLocalVer(u8* _Input); + void CommandReadBDAdrr(u8* _Input); + void CommandReadLocalFeatures(u8* _Input); + void CommandReadStoredLinkKey(u8* _Input); + void CommandWriteUnitClass(u8* _Input); + void CommandWriteLocalName(u8* _Input); + void CommandWritePinType(u8* _Input); + void CommandHostBufferSize(u8* _Input); + void CommandWritePageTimeOut(u8* _Input); + void CommandWriteScanEnable(u8* _Input); + void CommandWriteInquiryMode(u8* _Input); + void CommandWritePageScanType(u8* _Input); + void CommandSetEventFilter(u8* _Input); + void CommandInquiry(u8* _Input); + void CommandWriteInquiryScanType(u8* _Input); + void CommandVendorSpecific_FC4C(u8* _Input, u32 _Size); + void CommandVendorSpecific_FC4F(u8* _Input, u32 _Size); + void CommandInquiryCancel(u8* _Input); void CommandRemoteNameReq(u8* _Input); void CommandCreateCon(u8* _Input); void CommandAcceptCon(u8* _Input); - void CommandReadClockOffset(u8* _Input); - void CommandReadRemoteVerInfo(u8* _Input); - void CommandReadRemoteFeatures(u8* _Input); - + void CommandReadClockOffset(u8* _Input); + void CommandReadRemoteVerInfo(u8* _Input); + void CommandReadRemoteFeatures(u8* _Input); + void CommandWriteLinkPolicy(u8* _Input); - void SendToDevice(u16 _ConnectionHandle, u8* _pData, u32 _Size); + void SendToDevice(u16 _ConnectionHandle, u8* _pData, u32 _Size); - enum EState - { - STATE_NONE, - STATE_INQUIRY_RESPONSE, - STATE_INQUIRY_COMPLETE, + enum EState + { + STATE_NONE, + STATE_INQUIRY_RESPONSE, + STATE_INQUIRY_COMPLETE, STATE_START_REMOTE_NAME_REQ, STATE_REMOTE_NAME_REQ, - STATE_CONNECTION_COMPLETE_EVENT, - STATE_READ_CLOCK_OFFSET, - STATE_READ_REMOTE_VER_INFO, - STATE_READ_REMOTE_FEATURES - }; + STATE_CONNECTION_COMPLETE_EVENT, + STATE_READ_CLOCK_OFFSET, + STATE_READ_REMOTE_VER_INFO, + STATE_READ_REMOTE_FEATURES + }; - EState m_State; + EState m_State; bdaddr_t m_StateTempBD; u16 m_StateTempConnectionHandle; - bdaddr_t m_ControllerBD; - u8 m_ClassOfDevice[HCI_CLASS_SIZE]; - char m_LocalName[HCI_UNIT_NAME_SIZE]; - u8 m_PINType; - u8 filter_type; - u8 filter_condition_type; - u8 scan_enable; + enum EDelayedEvent + { + EVENT_NONE, + EVENT_REQUEST_CONNECTION, + EVENT_CONNECTION_COMPLETE + }; - u16 Host_max_acl_size; /* Max. size of ACL packet (bytes) */ - u8 Host_max_sco_size; /* Max. size of SCO packet (bytes) */ - u16 Host_num_acl_pkts; /* Max. number of ACL packets */ - u16 Host_num_sco_pkts; /* Max. number of SCO packets */ + EDelayedEvent m_DelayedEvent; + + void SetDelayedEvent(EDelayedEvent e); + + bdaddr_t m_ControllerBD; + u8 m_ClassOfDevice[HCI_CLASS_SIZE]; + char m_LocalName[HCI_UNIT_NAME_SIZE]; + u8 m_PINType; + u8 filter_type; + u8 filter_condition_type; + u8 scan_enable; + + u16 Host_max_acl_size; /* Max. size of ACL packet (bytes) */ + u8 Host_max_sco_size; /* Max. size of SCO packet (bytes) */ + u16 Host_num_acl_pkts; /* Max. number of ACL packets */ + u16 Host_num_sco_pkts; /* Max. number of SCO packets */ std::vector m_WiiMotes;