diff --git a/Core/Console.cpp b/Core/Console.cpp index 106b82e5..0b1669ad 100644 --- a/Core/Console.cpp +++ b/Core/Console.cpp @@ -1,5 +1,6 @@ #include "stdafx.h" #include +#include #include #include "Console.h" #include "CPU.h" @@ -396,7 +397,6 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile) GetDebugger(); } - ResetComponents(false); //Reset components before creating rewindmanager, otherwise the first save state it takes will be invalid @@ -605,7 +605,7 @@ void Console::ResetComponents(bool softReset) _resetRunTimers = true; - KeyManager::UpdateDevices(); + std::async(std::launch::async, KeyManager::UpdateDevices); //This notification MUST be sent before the UpdateInputState() below to allow MovieRecorder to grab the first frame's worth of inputs _notificationManager->SendNotification(softReset ? ConsoleNotificationType::GameReset : ConsoleNotificationType::GameLoaded); diff --git a/GUI.NET/Forms/Config/frmInputConfig.cs b/GUI.NET/Forms/Config/frmInputConfig.cs index 33a285f5..fd94b3d3 100644 --- a/GUI.NET/Forms/Config/frmInputConfig.cs +++ b/GUI.NET/Forms/Config/frmInputConfig.cs @@ -22,7 +22,9 @@ namespace Mesen.GUI.Forms.Config tlpControllers.Enabled = !InteropEmu.MoviePlaying() && !InteropEmu.MovieRecording(); - InteropEmu.UpdateInputDevices(); + Task.Run(() => { + InteropEmu.UpdateInputDevices(); + }); Entity = ConfigManager.Config.InputInfo; diff --git a/Windows/WindowsKeyManager.cpp b/Windows/WindowsKeyManager.cpp index 277f5aae..915502fd 100644 --- a/Windows/WindowsKeyManager.cpp +++ b/Windows/WindowsKeyManager.cpp @@ -256,12 +256,11 @@ void WindowsKeyManager::StartUpdateDeviceThread() _directInput.reset(new DirectInputManager(_console, _hWnd)); while(!_stopUpdateDeviceThread) { - //Check for newly plugged in controllers every 5 secs (this takes ~60-70ms when no new controllers are found) + //Check for newly plugged in XInput controllers every 5 secs + //Do not check for DirectInput controllers because this takes more times and sometimes causes issues/freezes if(_xInput->NeedToUpdate()) { _xInput->UpdateDeviceList(); } - _directInput->UpdateDeviceList(); - _stopSignal.Wait(5000); } }); @@ -375,10 +374,8 @@ void WindowsKeyManager::UpdateDevices() return; } - _console->Pause(); _xInput->UpdateDeviceList(); _directInput->UpdateDeviceList(); - _console->Resume(); } void WindowsKeyManager::SetKeyState(uint16_t scanCode, bool state)