Skip to content

Commit

Permalink
Wiimote: Remove useless disconnections
Browse files Browse the repository at this point in the history
ChangeWiimoteSource does not need to disconnect a Wiimote if it isn't
connected.
  • Loading branch information
leoetlino committed Jul 23, 2017
1 parent ee868e2 commit 1c33dfc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Source/Core/Core/HW/WiimoteReal/WiimoteReal.cpp
Expand Up @@ -777,6 +777,7 @@ void Pause()

void ChangeWiimoteSource(unsigned int index, int source)
{
const int previous_source = g_wiimote_sources[index];
g_wiimote_sources[index] = source;
{
// kill real connection (or swap to different slot)
Expand All @@ -796,9 +797,10 @@ void ChangeWiimoteSource(unsigned int index, int source)
}

// reconnect to the emulator
Core::RunAsCPUThread([index, source] {
::Wiimote::Connect(index, false);
if (WIIMOTE_SRC_EMU & source)
Core::RunAsCPUThread([index, previous_source, source] {
if (previous_source != WIIMOTE_SRC_NONE)
::Wiimote::Connect(index, false);
if (source & WIIMOTE_SRC_EMU)
::Wiimote::Connect(index, true);
});
}
Expand Down

0 comments on commit 1c33dfc

Please sign in to comment.