summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerInterface/DInput
diff options
context:
space:
mode:
authorPokechu22 <Pokechu022@gmail.com>2021-12-12 13:50:18 -0800
committerPokechu22 <Pokechu022@gmail.com>2022-01-09 12:44:55 -0800
commitca9bf3174f4acd4c9d78ac7c21b6aeaa1430b7ef (patch)
treee97af4fd1e5319cb74567f7c434d5084d9e1c4a5 /Source/Core/InputCommon/ControllerInterface/DInput
parent1b32e6dae23835c020a7ea44d14a88e6b55b0353 (diff)
Use HRWrap in remaining locations
Note that D3DCommon can't use DX11HRWrap or DX12HRWrap since it's shared between them.
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/DInput')
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInput.cpp19
-rw-r--r--Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp13
2 files changed, 21 insertions, 11 deletions
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.
diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
index 596fd1f109..ac72d383be 100644
--- a/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
+++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInputJoystick.cpp
@@ -10,6 +10,7 @@
#include <sstream>
#include <type_traits>
+#include "Common/HRWrap.h"
#include "Common/Logging/Log.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
#include "InputCommon/ControllerInterface/DInput/DInput.h"
@@ -62,12 +63,14 @@ void InitJoystick(IDirectInput8* const idi8, HWND hwnd)
{
if (SUCCEEDED(js_device->SetDataFormat(&c_dfDIJoystick)))
{
- if (FAILED(js_device->SetCooperativeLevel(GetAncestor(hwnd, GA_ROOT),
- DISCL_BACKGROUND | DISCL_EXCLUSIVE)))
+ HRESULT hr = js_device->SetCooperativeLevel(GetAncestor(hwnd, GA_ROOT),
+ DISCL_BACKGROUND | DISCL_EXCLUSIVE);
+ if (FAILED(hr))
{
- WARN_LOG_FMT(
- CONTROLLERINTERFACE,
- "DInput: Failed to acquire device exclusively. Force feedback will be unavailable.");
+ WARN_LOG_FMT(CONTROLLERINTERFACE,
+ "DInput: Failed to acquire device exclusively. Force feedback will be "
+ "unavailable. {}",
+ Common::HRWrap(hr));
// Fall back to non-exclusive mode, with no rumble
if (FAILED(
js_device->SetCooperativeLevel(nullptr, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE)))