diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp index cf1d0d5c66..0450ca5f67 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.cpp @@ -815,6 +815,7 @@ bool CWII_IPC_HLE_Device_es::IOCtlV(u32 _CommandAddress) std::string tContentFile(m_ContentFile.c_str()); WII_IPC_HLE_Interface::Reset(true); WII_IPC_HLE_Interface::Init(); + s_Usb = GetUsbPointer(); for (unsigned int i = 0; i < s_Usb->m_WiiMotes.size(); i++) { if (wiiMoteConnected[i]) 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 29e3c64a7c..33474af8c7 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 @@ -38,7 +38,7 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305::CWII_IPC_HLE_Device_usb_oh1_57e_305(u32 _De // Activate only first Wiimote by default _conf_pads BT_DINF; - + SetUsbPointer(this); if (!SConfig::GetInstance().m_SYSCONF->GetArrayData("BT.DINF", (u8*)&BT_DINF, sizeof(_conf_pads))) { PanicAlertT("Trying to read from invalid SYSCONF\nWiimote bt ids are not available"); @@ -100,6 +100,7 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305::CWII_IPC_HLE_Device_usb_oh1_57e_305(u32 _De CWII_IPC_HLE_Device_usb_oh1_57e_305::~CWII_IPC_HLE_Device_usb_oh1_57e_305() { m_WiiMotes.clear(); + SetUsbPointer(NULL); } void CWII_IPC_HLE_Device_usb_oh1_57e_305::DoState(PointerWrap &p) 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 e59e1b3208..6e06f60dd6 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 @@ -27,13 +27,19 @@ #include "l2cap.h" // Local #include "WiiMote_HID_Attr.h" -static CWII_IPC_HLE_Device_usb_oh1_57e_305* s_Usb; +static CWII_IPC_HLE_Device_usb_oh1_57e_305* s_Usb = NULL; CWII_IPC_HLE_Device_usb_oh1_57e_305* GetUsbPointer() { return s_Usb; } +void SetUsbPointer(CWII_IPC_HLE_Device_usb_oh1_57e_305* ptr) +{ + s_Usb = ptr; +} + + CWII_IPC_HLE_WiiMote::CWII_IPC_HLE_WiiMote(CWII_IPC_HLE_Device_usb_oh1_57e_305* _pHost, int _Number, bdaddr_t _BD, bool ready) : m_HIDControlChannel_Connected(false) , m_HIDControlChannel_ConnectedWait(false) @@ -49,8 +55,6 @@ CWII_IPC_HLE_WiiMote::CWII_IPC_HLE_WiiMote(CWII_IPC_HLE_Device_usb_oh1_57e_305* { DEBUG_LOG(WII_IPC_WIIMOTE, "Wiimote: #%i Constructed", _Number); - s_Usb = _pHost; - m_ConnectionState = (ready) ? CONN_READY : CONN_INACTIVE; m_ConnectionHandle = 0x100 + _Number; memset(m_LinkKey, 0xA0 + _Number, HCI_KEY_SIZE); 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 f3180c7dc9..5373f68c0a 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 @@ -25,6 +25,7 @@ class CWII_IPC_HLE_Device_usb_oh1_57e_305; CWII_IPC_HLE_Device_usb_oh1_57e_305* GetUsbPointer(); +void SetUsbPointer(CWII_IPC_HLE_Device_usb_oh1_57e_305* ptr); class CBigEndianBuffer {