Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make real wiimote speaker not cause massive input delays.
Fixes issue 5966.
  • Loading branch information
jordan-woyak committed Feb 5, 2013
1 parent 03d9cca commit d5ec631
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
25 changes: 10 additions & 15 deletions Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp
Expand Up @@ -181,23 +181,23 @@ bool Wiimote::Read()
bool Wiimote::Write()
{
Report rpt;
bool audio_written = false;

if (m_audio_reports.Pop(rpt))
if (last_audio_report.GetTimeDifference() > 6 && m_audio_reports.Pop(rpt))
{
last_audio_report.Update();

IOWrite(rpt.first, rpt.second);
delete[] rpt.first;
audio_written = true;
return true;
}

if (m_write_reports.Pop(rpt))
else if (m_write_reports.Pop(rpt))
{
IOWrite(rpt.first, rpt.second);
delete[] rpt.first;
return true;
}
}

return audio_written;
return false;
}

// Returns the next report that should be sent
Expand Down Expand Up @@ -319,14 +319,9 @@ void Wiimote::ThreadFunc()
while (Write()) {}
Common::SleepCurrentThread(1);
#else
bool read = false;
while (Write() || (read = true, IsOpen() && Read()))
{
if (m_audio_reports.Size() && !read)
Read();
Common::SleepCurrentThread(m_audio_reports.Size() ? 5 : 2);
read = false;
}
bool const did_something = Write() || Read();
if (!did_something)
Common::SleepCurrentThread(1);
#endif
}
}
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.h
Expand Up @@ -25,6 +25,7 @@
#include "ChunkFile.h"
#include "Thread.h"
#include "FifoQueue.h"
#include "Timer.h"

#include "../Wiimote.h"
#include "../WiimoteEmu/WiimoteEmu.h"
Expand Down Expand Up @@ -103,6 +104,8 @@ friend class WiimoteEmu::Wiimote;
Common::FifoQueue<Report> m_read_reports;
Common::FifoQueue<Report> m_write_reports;
Common::FifoQueue<Report> m_audio_reports;

Common::Timer last_audio_report;
};

extern std::mutex g_refresh_lock;
Expand Down

0 comments on commit d5ec631

Please sign in to comment.