Input: Turn off hot plugging for directinput devices

Loading, resetting a game or opening input config will still check for new DInput controllers
This commit is contained in:
Sour 2019-11-16 22:32:06 -05:00
parent ae0547df65
commit 27d512e02f
3 changed files with 7 additions and 8 deletions

View file

@ -1,5 +1,6 @@
#include "stdafx.h" #include "stdafx.h"
#include <random> #include <random>
#include <future>
#include <thread> #include <thread>
#include "Console.h" #include "Console.h"
#include "CPU.h" #include "CPU.h"
@ -396,7 +397,6 @@ bool Console::Initialize(VirtualFile &romFile, VirtualFile &patchFile)
GetDebugger(); GetDebugger();
} }
ResetComponents(false); ResetComponents(false);
//Reset components before creating rewindmanager, otherwise the first save state it takes will be invalid //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; _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 //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); _notificationManager->SendNotification(softReset ? ConsoleNotificationType::GameReset : ConsoleNotificationType::GameLoaded);

View file

@ -22,7 +22,9 @@ namespace Mesen.GUI.Forms.Config
tlpControllers.Enabled = !InteropEmu.MoviePlaying() && !InteropEmu.MovieRecording(); tlpControllers.Enabled = !InteropEmu.MoviePlaying() && !InteropEmu.MovieRecording();
InteropEmu.UpdateInputDevices(); Task.Run(() => {
InteropEmu.UpdateInputDevices();
});
Entity = ConfigManager.Config.InputInfo; Entity = ConfigManager.Config.InputInfo;

View file

@ -256,12 +256,11 @@ void WindowsKeyManager::StartUpdateDeviceThread()
_directInput.reset(new DirectInputManager(_console, _hWnd)); _directInput.reset(new DirectInputManager(_console, _hWnd));
while(!_stopUpdateDeviceThread) { 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()) { if(_xInput->NeedToUpdate()) {
_xInput->UpdateDeviceList(); _xInput->UpdateDeviceList();
} }
_directInput->UpdateDeviceList();
_stopSignal.Wait(5000); _stopSignal.Wait(5000);
} }
}); });
@ -375,10 +374,8 @@ void WindowsKeyManager::UpdateDevices()
return; return;
} }
_console->Pause();
_xInput->UpdateDeviceList(); _xInput->UpdateDeviceList();
_directInput->UpdateDeviceList(); _directInput->UpdateDeviceList();
_console->Resume();
} }
void WindowsKeyManager::SetKeyState(uint16_t scanCode, bool state) void WindowsKeyManager::SetKeyState(uint16_t scanCode, bool state)