WiimoteReal: Don't block on refresh

This changes Refresh() to use the existing scanning thread to scan for
devices, instead of running the scan on the UI thread and blocking it.

Also makes the UI thread not block when Continuous Scanning is disabled
and removes duplicated code.

Should fix issue 8992.

Under the hood:
* The scanning thread is now always active, even when continuous
  scanning is disabled.
* The initialize code which waits for Wiimotes to be connected also
  uses the scanning thread instead of scanning on yet another thread.
* The scanning thread now always checks for disconnected devices, to
  avoid Dolphin thinking a Wiimote is still connected when it isn't. So
  we now check if we need new Wiimotes or a Balance Board at scan time.
This commit is contained in:
Léo Lam 2016-07-07 15:40:14 +02:00
parent ece5de24bc
commit c827fdd2b5
7 changed files with 79 additions and 126 deletions

View file

@ -533,7 +533,9 @@ void EmuThread()
if (core_parameter.bWii)
{
if (init_controllers)
Wiimote::Initialize(s_window_handle, !s_state_filename.empty());
Wiimote::Initialize(s_window_handle, !s_state_filename.empty() ?
Wiimote::InitializeMode::DO_WAIT_FOR_WIIMOTES :
Wiimote::InitializeMode::DO_NOT_WAIT_FOR_WIIMOTES);
else
Wiimote::LoadConfig();