summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp
diff options
context:
space:
mode:
authorJMC47 <JMC4789@gmail.com>2019-03-30 18:41:46 -0400
committerGitHub <noreply@github.com>2019-03-30 18:41:46 -0400
commit735a705e4dd9f535dc529e0a7eb0d96ba5982be9 (patch)
treef85eaff4a85ef81a6fdfd7ae078aedf6291d2772 /Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp
parent2dd564304efe8f0d341cf9ab9093f57f863639a0 (diff)
parenteadbdd6bc389cd89c3e3e57a31dabaeadf161865 (diff)
Merge pull request #7776 from jordan-woyak/wm_devicechange
Add hotplug support to DInput and XInput controller backends
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp
index aacbcd55f8..cb484cc6ca 100644
--- a/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp
@@ -3,9 +3,11 @@
// Refer to the license.txt file included.
#include "InputCommon/ControllerInterface/DInput/DInput.h"
+
+#include "Common/Logging/Log.h"
#include "Common/StringUtil.h"
-#include "InputCommon/ControllerInterface/ControllerInterface.h"
+#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/ControllerInterface/DInput/DInputJoystick.h"
#include "InputCommon/ControllerInterface/DInput/DInputKeyboardMouse.h"
@@ -40,23 +42,32 @@ std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device)
{
result = StripSpaces(UTF16ToUTF8(str.wsz));
}
+ else
+ {
+ ERROR_LOG(PAD, "GetProperty(DIPROP_PRODUCTNAME) failed.");
+ }
return result;
}
void PopulateDevices(HWND hwnd)
{
+ // Remove unplugged devices.
+ g_controller_interface.RemoveDevice(
+ [](const auto* dev) { return dev->GetSource() == DINPUT_SOURCE_NAME && !dev->IsValid(); });
+
IDirectInput8* idi8;
if (FAILED(DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, IID_IDirectInput8,
(LPVOID*)&idi8, nullptr)))
{
+ ERROR_LOG(PAD, "DirectInput8Create failed.");
return;
}
- InitKeyboardMouse(idi8, hwnd);
+ InitKeyboardMouse(idi8);
InitJoystick(idi8, hwnd);
idi8->Release();
}
-}
-}
+} // namespace DInput
+} // namespace ciface