diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteNew.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteNew.cpp index 2314d1f9df..73eff317f3 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteNew.cpp +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteNew.cpp @@ -135,6 +135,7 @@ void InitPlugin( void* const hwnd ) (*i)->UpdateReferences( g_plugin.controller_interface ); // real wiimotes + WiimoteReal::LoadSettings(); WiimoteReal::Initialize(); } } @@ -248,7 +249,7 @@ unsigned int Wiimote_GetAttachedControllers() { unsigned int attached = 0; for (unsigned int i=0; i<4; ++i) - if (g_plugin.controllers[i]->default_device.ToString().length()) + if (g_wiimote_sources[i]) attached |= (1 << i); return attached; } diff --git a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp index 5dba8ea538..c1e48920f8 100644 --- a/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp +++ b/Source/Plugins/Plugin_WiimoteNew/Src/WiimoteReal/WiimoteReal.cpp @@ -163,14 +163,14 @@ void Wiimote::Read() // a data report, save it if (m_wiimote->event_buf[1] >= 0x30) { - memcpy(m_last_data_report, m_wiimote->event_buf, MAX_PAYLOAD - 1); + memcpy(m_last_data_report, m_wiimote->event_buf, MAX_PAYLOAD); m_last_data_report_valid = true; } else { // some other report, add it to queue - u8* const rpt = new u8[MAX_PAYLOAD - 1]; - memcpy(rpt, m_wiimote->event_buf, MAX_PAYLOAD - 1); + u8* const rpt = new u8[MAX_PAYLOAD]; + memcpy(rpt, m_wiimote->event_buf, MAX_PAYLOAD); m_reports.push(rpt); } } @@ -183,13 +183,13 @@ void Wiimote::Update() { u8* const rpt = m_reports.front(); m_reports.pop(); - g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, m_channel, rpt, MAX_PAYLOAD - 1); + g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, m_channel, rpt, MAX_PAYLOAD); delete[] rpt; } else if (m_last_data_report_valid) { // otherwise send the last data report, if there is one - g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, m_channel, m_last_data_report, MAX_PAYLOAD - 1); + g_WiimoteInitialize.pWiimoteInterruptChannel(m_index, m_channel, m_last_data_report, MAX_PAYLOAD); } } @@ -212,15 +212,8 @@ void Wiimote::Disconnect() Wiimote* g_wiimotes[4]; -unsigned int Initialize() +void LoadSettings() { - // return if already initialized - if (g_real_wiimotes_initialized) - return g_wiimotes_found; - - - // load realwiimote settings from inifile - { std::string ini_filename = (std::string(File::GetUserPath(D_CONFIG_IDX)) + g_plugin.ini_name + ".ini" ); IniFile inifile; @@ -234,8 +227,13 @@ unsigned int Initialize() sec.Get("Source", &g_wiimote_sources[i], WIIMOTE_SRC_EMU); } - } - // end load settings +} + +unsigned int Initialize() +{ + // return if already initialized + if (g_real_wiimotes_initialized) + return g_wiimotes_found; memset(g_wiimotes, 0, sizeof(g_wiimotes)); @@ -269,14 +267,14 @@ unsigned int Initialize() g_wiimote_critsec.Enter(); // enter // create real wiimote class instances, assign wiimotes - unsigned int index = 0; - for (unsigned int i = 0; i < g_wiimotes_found; ++i) + + for (unsigned int i = 0, w = 0; i