Real Wiimote: fix a crash some people were having, and fix IR behavior (by turning off some msvc++ optimizations...)
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4610 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
7118900d3b
commit
6145dd2967
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -51,8 +51,8 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
Optimization="0"
|
||||
InlineFunctionExpansion="2"
|
||||
AdditionalIncludeDirectories="C:\WinDDK\7600.16385.0\inc\api;C:\WinDDK\7600.16385.0\inc\crt"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;WIIUSE_EXPORTS"
|
||||
IgnoreStandardIncludePath="true"
|
||||
|
@ -147,8 +147,8 @@
|
|||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
Optimization="0"
|
||||
InlineFunctionExpansion="2"
|
||||
AdditionalIncludeDirectories="C:\WinDDK\7600.16385.0\inc\api;C:\WinDDK\7600.16385.0\inc\crt"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;WIIUSE_EXPORTS;_WIN64"
|
||||
IgnoreStandardIncludePath="true"
|
||||
|
|
|
@ -37,10 +37,12 @@
|
|||
|
||||
namespace WiiMoteReal
|
||||
{
|
||||
int GetReportSize(struct wiimote_t* wm)
|
||||
int GetIRDataSize(struct wiimote_t* wm)
|
||||
{
|
||||
// The report size is 0x33 = 18, 0x37 = 22 withouth the leading (a1) byte
|
||||
if(WIIUSE_USING_EXP(wm)) return 22; else return 18;
|
||||
if (WIIUSE_USING_EXP(wm))
|
||||
return 10;
|
||||
else
|
||||
return 12;
|
||||
}
|
||||
|
||||
void handle_ctrl_status(struct wiimote_t* wm)
|
||||
|
@ -56,19 +58,14 @@ void handle_ctrl_status(struct wiimote_t* wm)
|
|||
|
||||
bool IRDataOK(struct wiimote_t* wm)
|
||||
{
|
||||
//DEBUG_LOG(WIIMOTE, "IRDataOK: ");
|
||||
// The report size is 0x33 = 18, 0x37 = 22 withouth the leading (a1) byte
|
||||
int ReportSize = GetReportSize(wm);
|
||||
for(int i = 0; i < ReportSize; i++)
|
||||
{
|
||||
//DEBUG_LOG(WIIMOTE, "%02x ", wm->event_buf[i]);
|
||||
if (wm->event_buf[i] > 0)
|
||||
{
|
||||
//DEBUG_LOG(WIIMOTE, "");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// 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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue