Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'real-wiimote-fixes'
  • Loading branch information
RachelBryk committed Jul 11, 2013
2 parents e1f6414 + fd4a441 commit 970cb43
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Core/Src/Core.cpp
Expand Up @@ -391,7 +391,7 @@ void EmuThread()
// Load and Init Wiimotes - only if we are booting in wii mode
if (g_CoreStartupParameter.bWii)
{
Wiimote::Initialize(g_pWindowHandle);
Wiimote::Initialize(g_pWindowHandle, !g_stateFileName.empty());

// Activate wiimotes which don't have source set to "None"
for (unsigned int i = 0; i != MAX_BBMOTES; ++i)
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/Src/HW/Wiimote.cpp
Expand Up @@ -38,7 +38,7 @@ void Shutdown()
}

// if plugin isn't initialized, init and load config
void Initialize(void* const hwnd)
void Initialize(void* const hwnd, bool wait)
{
// add 4 wiimotes
for (unsigned int i = WIIMOTE_CHAN_0; i<MAX_BBMOTES; ++i)
Expand All @@ -50,7 +50,7 @@ void Initialize(void* const hwnd)

g_plugin.LoadConfig(false);

WiimoteReal::Initialize();
WiimoteReal::Initialize(wait);

// reload Wiimotes with our settings
if (Movie::IsPlayingInput() || Movie::IsRecordingInput())
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/Src/HW/Wiimote.h
Expand Up @@ -35,7 +35,7 @@ namespace Wiimote
{

void Shutdown();
void Initialize(void* const hwnd);
void Initialize(void* const hwnd, bool wait = false);
void Resume();
void Pause();

Expand All @@ -53,7 +53,7 @@ void Update(int _number);
namespace WiimoteReal
{

void Initialize();
void Initialize(bool wait = false);
void Shutdown();
void Resume();
void Pause();
Expand Down
26 changes: 17 additions & 9 deletions Source/Core/Core/Src/HW/WiimoteReal/WiimoteReal.cpp
Expand Up @@ -299,6 +299,11 @@ void Wiimote::Update()
return;
}

WiimoteEmu::Wiimote *const wm = (WiimoteEmu::Wiimote*)::Wiimote::GetPlugin()->controllers[index];

if (wm->Step())
return;

// Pop through the queued reports
const Report& rpt = ProcessReadQueue();

Expand Down Expand Up @@ -533,7 +538,7 @@ void LoadSettings()
}

// config dialog calls this when some settings change
void Initialize()
void Initialize(bool wait)
{
if (SConfig::GetInstance().m_WiimoteContinuousScanning)
g_wiimote_scanner.StartScanning();
Expand All @@ -546,16 +551,19 @@ void Initialize()
g_wiimote_scanner.WantBB(0 != CalculateWantedBB());

// wait for connection because it should exist before state load
int timeout = 100;
std::vector<Wiimote*> found_wiimotes;
Wiimote* found_board = NULL;
g_wiimote_scanner.FindWiimotes(found_wiimotes, found_board);
if (SConfig::GetInstance().m_WiimoteContinuousScanning)
if (wait)
{
while(CalculateWantedWiimotes() && CalculateConnectedWiimotes() < found_wiimotes.size() && timeout)
int timeout = 100;
std::vector<Wiimote*> found_wiimotes;
Wiimote* found_board = NULL;
g_wiimote_scanner.FindWiimotes(found_wiimotes, found_board);
if (SConfig::GetInstance().m_WiimoteContinuousScanning)
{
Common::SleepCurrentThread(100);
timeout--;
while(CalculateWantedWiimotes() && CalculateConnectedWiimotes() < found_wiimotes.size() && timeout)
{
Common::SleepCurrentThread(100);
timeout--;
}
}
}

Expand Down

0 comments on commit 970cb43

Please sign in to comment.