diff --git a/Externals/WiiUse/Win32/wiiuse.dll b/Externals/WiiUse/Win32/wiiuse.dll index 97f0289ca6..512b53b83f 100644 Binary files a/Externals/WiiUse/Win32/wiiuse.dll and b/Externals/WiiUse/Win32/wiiuse.dll differ diff --git a/Externals/WiiUse/Win32/wiiuse.lib b/Externals/WiiUse/Win32/wiiuse.lib index e83372d929..75c45ef4a7 100644 Binary files a/Externals/WiiUse/Win32/wiiuse.lib and b/Externals/WiiUse/Win32/wiiuse.lib differ diff --git a/Externals/WiiUse/X64/wiiuse.dll b/Externals/WiiUse/X64/wiiuse.dll index 26d6485403..46f146e382 100644 Binary files a/Externals/WiiUse/X64/wiiuse.dll and b/Externals/WiiUse/X64/wiiuse.dll differ diff --git a/Externals/WiiUse/X64/wiiuse.lib b/Externals/WiiUse/X64/wiiuse.lib index 9e6b440dbb..196bd6b19f 100644 Binary files a/Externals/WiiUse/X64/wiiuse.lib and b/Externals/WiiUse/X64/wiiuse.lib differ diff --git a/Externals/WiiUseSrc/wiiuse.vcproj b/Externals/WiiUseSrc/wiiuse.vcproj index fe4a45d6a5..1bfa3a0ede 100644 --- a/Externals/WiiUseSrc/wiiuse.vcproj +++ b/Externals/WiiUseSrc/wiiuse.vcproj @@ -51,8 +51,8 @@ /> event_buf[i]); - if (wm->event_buf[i] > 0) - { - //DEBUG_LOG(WIIMOTE, ""); - return true; - } - } - return false; + // This check is valid because 0 should only be returned if the data + // hasn't been filled in by wiiuse + int IRDataSize = GetIRDataSize(wm); + for (int i = 7; i < IRDataSize; i++) + if (wm->event_buf[i] == 0) + return false; + + return true; } void handle_event(struct wiimote_t* wm) @@ -129,17 +126,12 @@ void handle_event(struct wiimote_t* wm) Tmp += StringFromFormat("G-Force x, y, z: %1.2f %1.2f %1.2f\n", wm->gforce.x, wm->gforce.y, wm->gforce.z); Tmp += StringFromFormat("Accel x, y, z: %03i %03i %03i\n", wm->accel.x, wm->accel.y, wm->accel.z); - // The report size is 0x33 = 18, 0x37 = 22 - int ReportSize; if(WIIUSE_USING_EXP(wm)) ReportSize = 22; else ReportSize = 18; - // wm->event_buf is cleared at the end of all wiiuse_poll(), so wm->event_buf will always be zero // after that. To get the raw IR data we need to read the wiimote again. This seems to work most of the time, // it seems to fails with a regular interval about each tenth read. - if(wiiuse_io_read(wm)) - { - // Check that it's not zero - if (IRDataOK(wm)) memcpy(g_EventBuffer, wm->event_buf, ReportSize); - } + if (wiiuse_io_read(wm)) + if (IRDataOK(wm)) + memcpy(g_EventBuffer, wm->event_buf, GetIRDataSize(wm)); // Go through each of the 4 possible IR sources for (int i = 0; i < 4; ++i) @@ -163,7 +155,6 @@ void handle_event(struct wiimote_t* wm) //std::string TmpData = ArrayToString(g_EventBuffer, ReportSize, 0, 30); //Tmp += "Data: " + TmpData; - //Console::ClearScreen(); //DEBUG_LOG(WIIMOTE, "%s", Tmp.c_str()); #if defined(HAVE_WX) && HAVE_WX @@ -211,13 +202,10 @@ void handle_event(struct wiimote_t* wm) if(m_RecordingConfigFrame->m_bRecording) DEBUG_LOG(WIIMOTE, "Wiiuse Recorded accel x, y, z: %03i %03i %03i", Gx, Gy, Gz); - //DEBUG_LOG(WIIMOTE, "Wiiuse Recorded accel x, y, z: %02x %02x %02x", Gx, Gy, Gz); } // Send the data to be saved - //const u8* data = (const u8*)wm->event_buf; - m_RecordingConfigFrame->DoRecordMovement(Gx, Gy, Gz, (g_EventBuffer + 6), - (WIIUSE_USING_EXP(wm) ? 10 : 12)); + m_RecordingConfigFrame->DoRecordMovement(Gx, Gy, Gz, g_EventBuffer + 6, GetIRDataSize(wm)); // Turn recording on and off if (IS_PRESSED(wm, WIIMOTE_BUTTON_A)) m_RecordingConfigFrame->DoRecordA(true); @@ -226,7 +214,6 @@ void handle_event(struct wiimote_t* wm) // ------------------------------------ // Show roll and pitch in the status box // -------------- - if(!g_DebugData) { DEBUG_LOG(WIIMOTE, "Roll:%03i Pitch:%03i", (int)wm->orient.roll, (int)wm->orient.pitch); diff --git a/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp b/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp index ac86ad0b5f..be6f4f3525 100644 --- a/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp +++ b/Source/Plugins/Plugin_Wiimote/Src/wiimote_real.cpp @@ -144,14 +144,14 @@ void ReadData() if (pBuffer[1] >= 0x30) { // Copy Buffer to LastReport - memcpy(m_LastReport.m_PayLoad, pBuffer + 1, MAX_PAYLOAD); + memcpy(m_LastReport.m_PayLoad, pBuffer + 1, MAX_PAYLOAD - 1); m_LastReportValid = true; } else { // Copy Buffer to ImportantEvent SEvent ImportantEvent; - memcpy(ImportantEvent.m_PayLoad, pBuffer + 1, MAX_PAYLOAD); + memcpy(ImportantEvent.m_PayLoad, pBuffer + 1, MAX_PAYLOAD - 1); // Put it in the read queue right away m_EventReadQueue.push(ImportantEvent);