From ca9bf3174f4acd4c9d78ac7c21b6aeaa1430b7ef Mon Sep 17 00:00:00 2001 From: Pokechu22 Date: Sun, 12 Dec 2021 13:50:18 -0800 Subject: Use HRWrap in remaining locations Note that D3DCommon can't use DX11HRWrap or DX12HRWrap since it's shared between them. --- .../InputCommon/ControllerInterface/DInput/DInput.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp') diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp index ec02abaddf..1ab12af20a 100644 --- a/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp +++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp @@ -3,6 +3,7 @@ #include "InputCommon/ControllerInterface/DInput/DInput.h" +#include "Common/HRWrap.h" #include "Common/Logging/Log.h" #include "Common/StringUtil.h" @@ -37,13 +38,15 @@ std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device) str.diph.dwHow = DIPH_DEVICE; std::string result; - if (SUCCEEDED(device->GetProperty(DIPROP_PRODUCTNAME, &str.diph))) + HRESULT hr = device->GetProperty(DIPROP_PRODUCTNAME, &str.diph); + if (SUCCEEDED(hr)) { result = StripSpaces(WStringToUTF8(str.wsz)); } else { - ERROR_LOG_FMT(CONTROLLERINTERFACE, "GetProperty(DIPROP_PRODUCTNAME) failed."); + ERROR_LOG_FMT(CONTROLLERINTERFACE, "GetProperty(DIPROP_PRODUCTNAME) failed: {}", + Common::HRWrap(hr)); } return result; @@ -52,11 +55,15 @@ std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device) // Assumes hwnd had not changed from the previous call void PopulateDevices(HWND hwnd) { - if (!s_idi8 && FAILED(DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, - IID_IDirectInput8, (LPVOID*)&s_idi8, nullptr))) + if (!s_idi8) { - ERROR_LOG_FMT(CONTROLLERINTERFACE, "DirectInput8Create failed."); - return; + HRESULT hr = DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, + IID_IDirectInput8, (LPVOID*)&s_idi8, nullptr); + if (FAILED(hr)) + { + ERROR_LOG_FMT(CONTROLLERINTERFACE, "DirectInput8Create failed: {}", Common::HRWrap(hr)); + return; + } } // Remove old (invalid) devices. No need to ever remove the KeyboardMouse device. -- cgit v1.2.3