From 857caa3e208d8bb3a5313db9d1fb29c485b67a8c Mon Sep 17 00:00:00 2001 From: Sour Date: Thu, 26 Dec 2019 13:57:05 -0500 Subject: [PATCH] Input: Turn off hot plugging for directinput devices Loading a game or opening input config will still check for new DInput controllers --- Core/Console.cpp | 1 + UI/Forms/Config/frmInputConfig.cs | 4 ++++ Windows/WindowsKeyManager.cpp | 5 ++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Core/Console.cpp b/Core/Console.cpp index 2b70ca7..3f2e1cc 100644 --- a/Core/Console.cpp +++ b/Core/Console.cpp @@ -371,6 +371,7 @@ bool Console::LoadRom(VirtualFile romFile, VirtualFile patchFile, bool stopRom) shared_ptr cart = BaseCartridge::CreateCartridge(this, romFile, patchFile); if(cart) { if(stopRom) { + KeyManager::UpdateDevices(); Stop(false); } diff --git a/UI/Forms/Config/frmInputConfig.cs b/UI/Forms/Config/frmInputConfig.cs index 69be955..ad84576 100644 --- a/UI/Forms/Config/frmInputConfig.cs +++ b/UI/Forms/Config/frmInputConfig.cs @@ -20,6 +20,10 @@ namespace Mesen.GUI.Forms.Config return; } + Task.Run(() => { + InputApi.UpdateInputDevices(); + }); + InputConfig cfg = ConfigManager.Config.Input.Clone(); Entity = cfg; diff --git a/Windows/WindowsKeyManager.cpp b/Windows/WindowsKeyManager.cpp index 0793ee3..300f15f 100644 --- a/Windows/WindowsKeyManager.cpp +++ b/Windows/WindowsKeyManager.cpp @@ -254,12 +254,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 time and sometimes causes issues/freezes if(_xInput->NeedToUpdate()) { _xInput->UpdateDeviceList(); } - _directInput->UpdateDeviceList(); - _stopSignal.Wait(5000); } });