Use HRWrap in remaining locations
Note that D3DCommon can't use DX11HRWrap or DX12HRWrap since it's shared between them.
This commit is contained in:
parent
1b32e6dae2
commit
ca9bf3174f
|
@ -17,6 +17,7 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "Common/Assert.h"
|
#include "Common/Assert.h"
|
||||||
|
#include "Common/HRWrap.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
#include "Common/Thread.h"
|
#include "Common/Thread.h"
|
||||||
|
@ -66,11 +67,11 @@ static bool HandleWinAPI(std::string_view message, HRESULT result)
|
||||||
error = "Audio endpoint already in use!";
|
error = "Audio endpoint already in use!";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
error = TStrToUTF8(_com_error(result).ErrorMessage()).c_str();
|
error = Common::GetHResultMessage(result);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ERROR_LOG_FMT(AUDIO, "WASAPI: {}: {}", message, error);
|
ERROR_LOG_FMT(AUDIO, "WASAPI: {}: {} ({:08x})", message, error, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
return SUCCEEDED(result);
|
return SUCCEEDED(result);
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "Common/CommonFuncs.h"
|
#include "Common/CommonFuncs.h"
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/DynamicLibrary.h"
|
#include "Common/DynamicLibrary.h"
|
||||||
|
#include "Common/HRWrap.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "Common/ScopeGuard.h"
|
#include "Common/ScopeGuard.h"
|
||||||
#include "Common/Thread.h"
|
#include "Common/Thread.h"
|
||||||
|
@ -247,7 +248,7 @@ int IOWritePerSetOutputReport(HANDLE& dev_handle, const u8* buf, size_t len, DWO
|
||||||
// Some third-party adapters (DolphinBar) use this
|
// Some third-party adapters (DolphinBar) use this
|
||||||
// error code to signal the absence of a Wiimote
|
// error code to signal the absence of a Wiimote
|
||||||
// linked to the HID device.
|
// linked to the HID device.
|
||||||
WARN_LOG_FMT(WIIMOTE, "IOWrite[WWM_SET_OUTPUT_REPORT]: Error: {:08x}", err);
|
WARN_LOG_FMT(WIIMOTE, "IOWrite[WWM_SET_OUTPUT_REPORT]: Error: {}", Common::HRWrap(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +298,8 @@ int IOWritePerWriteFile(HANDLE& dev_handle, OVERLAPPED& hid_overlap_write,
|
||||||
// Pending is no error!
|
// Pending is no error!
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
WARN_LOG_FMT(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: Error on WriteFile: {:08x}", error);
|
WARN_LOG_FMT(WIIMOTE, "IOWrite[WWM_WRITE_FILE]: Error on WriteFile: {}",
|
||||||
|
Common::HRWrap(error));
|
||||||
CancelIo(dev_handle);
|
CancelIo(dev_handle);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -771,7 +773,7 @@ int IORead(HANDLE& dev_handle, OVERLAPPED& hid_overlap_read, u8* buf, int index)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WARN_LOG_FMT(WIIMOTE, "ReadFile error {} on Wiimote {}.", read_err, index + 1);
|
WARN_LOG_FMT(WIIMOTE, "ReadFile on Wiimote {}: {}", index + 1, Common::HRWrap(read_err));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -955,8 +957,8 @@ bool AttachWiimote(HANDLE hRadio, const BLUETOOTH_RADIO_INFO& radio_info,
|
||||||
|
|
||||||
if (ERROR_SUCCESS != auth_result)
|
if (ERROR_SUCCESS != auth_result)
|
||||||
{
|
{
|
||||||
ERROR_LOG_FMT(WIIMOTE, "AttachWiimote: BluetoothAuthenticateDeviceEx returned {:08x}",
|
ERROR_LOG_FMT(WIIMOTE, "AttachWiimote: BluetoothAuthenticateDeviceEx failed: {}",
|
||||||
auth_result);
|
Common::HRWrap(auth_result));
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD pcServices = 16;
|
DWORD pcServices = 16;
|
||||||
|
@ -967,8 +969,8 @@ bool AttachWiimote(HANDLE hRadio, const BLUETOOTH_RADIO_INFO& radio_info,
|
||||||
|
|
||||||
if (ERROR_SUCCESS != srv_result)
|
if (ERROR_SUCCESS != srv_result)
|
||||||
{
|
{
|
||||||
ERROR_LOG_FMT(WIIMOTE, "AttachWiimote: BluetoothEnumerateInstalledServices returned {:08x}",
|
ERROR_LOG_FMT(WIIMOTE, "AttachWiimote: BluetoothEnumerateInstalledServices failed: {}",
|
||||||
srv_result);
|
Common::HRWrap(auth_result));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
// Activate service
|
// Activate service
|
||||||
|
@ -979,7 +981,8 @@ bool AttachWiimote(HANDLE hRadio, const BLUETOOTH_RADIO_INFO& radio_info,
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
ERROR_LOG_FMT(WIIMOTE, "AttachWiimote: BluetoothSetServiceState returned {:08x}", hr);
|
ERROR_LOG_FMT(WIIMOTE, "AttachWiimote: BluetoothSetServiceState failed: {}",
|
||||||
|
Common::HRWrap(hr));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "InputCommon/ControllerInterface/DInput/DInput.h"
|
#include "InputCommon/ControllerInterface/DInput/DInput.h"
|
||||||
|
|
||||||
|
#include "Common/HRWrap.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
|
|
||||||
|
@ -37,13 +38,15 @@ std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device)
|
||||||
str.diph.dwHow = DIPH_DEVICE;
|
str.diph.dwHow = DIPH_DEVICE;
|
||||||
|
|
||||||
std::string result;
|
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));
|
result = StripSpaces(WStringToUTF8(str.wsz));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ERROR_LOG_FMT(CONTROLLERINTERFACE, "GetProperty(DIPROP_PRODUCTNAME) failed.");
|
ERROR_LOG_FMT(CONTROLLERINTERFACE, "GetProperty(DIPROP_PRODUCTNAME) failed: {}",
|
||||||
|
Common::HRWrap(hr));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -52,12 +55,16 @@ std::string GetDeviceName(const LPDIRECTINPUTDEVICE8 device)
|
||||||
// Assumes hwnd had not changed from the previous call
|
// Assumes hwnd had not changed from the previous call
|
||||||
void PopulateDevices(HWND hwnd)
|
void PopulateDevices(HWND hwnd)
|
||||||
{
|
{
|
||||||
if (!s_idi8 && FAILED(DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION,
|
if (!s_idi8)
|
||||||
IID_IDirectInput8, (LPVOID*)&s_idi8, nullptr)))
|
|
||||||
{
|
{
|
||||||
ERROR_LOG_FMT(CONTROLLERINTERFACE, "DirectInput8Create failed.");
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove old (invalid) devices. No need to ever remove the KeyboardMouse device.
|
// Remove old (invalid) devices. No need to ever remove the KeyboardMouse device.
|
||||||
// Note that if we have 2+ DInput controllers, not fully repopulating devices
|
// Note that if we have 2+ DInput controllers, not fully repopulating devices
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "Common/HRWrap.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||||
#include "InputCommon/ControllerInterface/DInput/DInput.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 (SUCCEEDED(js_device->SetDataFormat(&c_dfDIJoystick)))
|
||||||
{
|
{
|
||||||
if (FAILED(js_device->SetCooperativeLevel(GetAncestor(hwnd, GA_ROOT),
|
HRESULT hr = js_device->SetCooperativeLevel(GetAncestor(hwnd, GA_ROOT),
|
||||||
DISCL_BACKGROUND | DISCL_EXCLUSIVE)))
|
DISCL_BACKGROUND | DISCL_EXCLUSIVE);
|
||||||
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
WARN_LOG_FMT(
|
WARN_LOG_FMT(CONTROLLERINTERFACE,
|
||||||
CONTROLLERINTERFACE,
|
"DInput: Failed to acquire device exclusively. Force feedback will be "
|
||||||
"DInput: Failed to acquire device exclusively. Force feedback will be unavailable.");
|
"unavailable. {}",
|
||||||
|
Common::HRWrap(hr));
|
||||||
// Fall back to non-exclusive mode, with no rumble
|
// Fall back to non-exclusive mode, with no rumble
|
||||||
if (FAILED(
|
if (FAILED(
|
||||||
js_device->SetCooperativeLevel(nullptr, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE)))
|
js_device->SetCooperativeLevel(nullptr, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE)))
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include "Common/Flag.h"
|
#include "Common/Flag.h"
|
||||||
|
#include "Common/HRWrap.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "Common/ScopeGuard.h"
|
#include "Common/ScopeGuard.h"
|
||||||
#include "Common/Thread.h"
|
#include "Common/Thread.h"
|
||||||
|
@ -61,9 +62,10 @@ void ciface::Win32::Init(void* hwnd)
|
||||||
HWND message_window = nullptr;
|
HWND message_window = nullptr;
|
||||||
Common::ScopeGuard promise_guard([&] { message_window_promise.set_value(message_window); });
|
Common::ScopeGuard promise_guard([&] { message_window_promise.set_value(message_window); });
|
||||||
|
|
||||||
if (FAILED(CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED)))
|
HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
|
||||||
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
ERROR_LOG_FMT(CONTROLLERINTERFACE, "CoInitializeEx failed: {}", GetLastError());
|
ERROR_LOG_FMT(CONTROLLERINTERFACE, "CoInitializeEx failed: {}", Common::HRWrap(hr));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Common::ScopeGuard uninit([] { CoUninitialize(); });
|
Common::ScopeGuard uninit([] { CoUninitialize(); });
|
||||||
|
@ -77,12 +79,14 @@ void ciface::Win32::Init(void* hwnd)
|
||||||
ATOM window_class = RegisterClassEx(&window_class_info);
|
ATOM window_class = RegisterClassEx(&window_class_info);
|
||||||
if (!window_class)
|
if (!window_class)
|
||||||
{
|
{
|
||||||
NOTICE_LOG_FMT(CONTROLLERINTERFACE, "RegisterClassEx failed: {}", GetLastError());
|
NOTICE_LOG_FMT(CONTROLLERINTERFACE, "RegisterClassEx failed: {}",
|
||||||
|
Common::HRWrap(GetLastError()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Common::ScopeGuard unregister([&window_class] {
|
Common::ScopeGuard unregister([&window_class] {
|
||||||
if (!UnregisterClass(MAKEINTATOM(window_class), GetModuleHandle(nullptr)))
|
if (!UnregisterClass(MAKEINTATOM(window_class), GetModuleHandle(nullptr)))
|
||||||
ERROR_LOG_FMT(CONTROLLERINTERFACE, "UnregisterClass failed: {}", GetLastError());
|
ERROR_LOG_FMT(CONTROLLERINTERFACE, "UnregisterClass failed: {}",
|
||||||
|
Common::HRWrap(GetLastError()));
|
||||||
});
|
});
|
||||||
|
|
||||||
message_window = CreateWindowEx(0, L"Message", nullptr, 0, 0, 0, 0, 0, HWND_MESSAGE, nullptr,
|
message_window = CreateWindowEx(0, L"Message", nullptr, 0, 0, 0, 0, 0, HWND_MESSAGE, nullptr,
|
||||||
|
@ -90,12 +94,14 @@ void ciface::Win32::Init(void* hwnd)
|
||||||
promise_guard.Exit();
|
promise_guard.Exit();
|
||||||
if (!message_window)
|
if (!message_window)
|
||||||
{
|
{
|
||||||
ERROR_LOG_FMT(CONTROLLERINTERFACE, "CreateWindowEx failed: {}", GetLastError());
|
ERROR_LOG_FMT(CONTROLLERINTERFACE, "CreateWindowEx failed: {}",
|
||||||
|
Common::HRWrap(GetLastError()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Common::ScopeGuard destroy([&] {
|
Common::ScopeGuard destroy([&] {
|
||||||
if (!DestroyWindow(message_window))
|
if (!DestroyWindow(message_window))
|
||||||
ERROR_LOG_FMT(CONTROLLERINTERFACE, "DestroyWindow failed: {}", GetLastError());
|
ERROR_LOG_FMT(CONTROLLERINTERFACE, "DestroyWindow failed: {}",
|
||||||
|
Common::HRWrap(GetLastError()));
|
||||||
});
|
});
|
||||||
|
|
||||||
std::array<RAWINPUTDEVICE, 2> devices;
|
std::array<RAWINPUTDEVICE, 2> devices;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include "Common/Assert.h"
|
#include "Common/Assert.h"
|
||||||
#include "Common/DynamicLibrary.h"
|
#include "Common/DynamicLibrary.h"
|
||||||
|
#include "Common/HRWrap.h"
|
||||||
#include "Common/MsgHandler.h"
|
#include "Common/MsgHandler.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
|
|
||||||
|
@ -89,7 +90,7 @@ Microsoft::WRL::ComPtr<IDXGIFactory> CreateDXGIFactory(bool debug_device)
|
||||||
HRESULT hr = create_dxgi_factory(IID_PPV_ARGS(factory.ReleaseAndGetAddressOf()));
|
HRESULT hr = create_dxgi_factory(IID_PPV_ARGS(factory.ReleaseAndGetAddressOf()));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
PanicAlertFmt("CreateDXGIFactory() failed with HRESULT {:08X}", hr);
|
PanicAlertFmt("CreateDXGIFactory() failed: {}", Common::HRWrap(hr));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "Common/Assert.h"
|
#include "Common/Assert.h"
|
||||||
#include "Common/FileUtil.h"
|
#include "Common/FileUtil.h"
|
||||||
|
#include "Common/HRWrap.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "Common/MsgHandler.h"
|
#include "Common/MsgHandler.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
|
@ -118,8 +119,8 @@ std::optional<Shader::BinaryData> Shader::CompileShader(D3D_FEATURE_LEVEL featur
|
||||||
file << "Video Backend: " + g_video_backend->GetDisplayName();
|
file << "Video Backend: " + g_video_backend->GetDisplayName();
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
PanicAlertFmt("Failed to compile {}:\nDebug info ({}):\n{}", filename, target,
|
PanicAlertFmt("Failed to compile {}: {}\nDebug info ({}):\n{}", filename, Common::HRWrap(hr),
|
||||||
static_cast<const char*>(errors->GetBufferPointer()));
|
target, static_cast<const char*>(errors->GetBufferPointer()));
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,10 @@
|
||||||
|
|
||||||
#include "Common/Assert.h"
|
#include "Common/Assert.h"
|
||||||
#include "Common/CommonFuncs.h"
|
#include "Common/CommonFuncs.h"
|
||||||
|
#include "Common/HRWrap.h"
|
||||||
#include "Common/Logging/Log.h"
|
#include "Common/Logging/Log.h"
|
||||||
#include "Common/MsgHandler.h"
|
#include "Common/MsgHandler.h"
|
||||||
|
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
static bool IsTearingSupported(IDXGIFactory2* dxgi_factory)
|
static bool IsTearingSupported(IDXGIFactory2* dxgi_factory)
|
||||||
|
@ -125,7 +127,7 @@ bool SwapChain::CreateSwapChain(bool stereo)
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
PanicAlertFmt("Failed to create swap chain with HRESULT {:08X}", hr);
|
PanicAlertFmt("Failed to create swap chain: {}", Common::HRWrap(hr));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +135,7 @@ bool SwapChain::CreateSwapChain(bool stereo)
|
||||||
hr = m_dxgi_factory->MakeWindowAssociation(static_cast<HWND>(m_wsi.render_surface),
|
hr = m_dxgi_factory->MakeWindowAssociation(static_cast<HWND>(m_wsi.render_surface),
|
||||||
DXGI_MWA_NO_WINDOW_CHANGES | DXGI_MWA_NO_ALT_ENTER);
|
DXGI_MWA_NO_WINDOW_CHANGES | DXGI_MWA_NO_ALT_ENTER);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
WARN_LOG_FMT(VIDEO, "MakeWindowAssociation() failed with HRESULT {:08X}", hr);
|
WARN_LOG_FMT(VIDEO, "MakeWindowAssociation() failed: {}", Common::HRWrap(hr));
|
||||||
|
|
||||||
m_stereo = stereo;
|
m_stereo = stereo;
|
||||||
if (!CreateSwapChainBuffers())
|
if (!CreateSwapChainBuffers())
|
||||||
|
@ -166,7 +168,7 @@ bool SwapChain::ResizeSwapChain()
|
||||||
GetDXGIFormatForAbstractFormat(m_texture_format, false),
|
GetDXGIFormatForAbstractFormat(m_texture_format, false),
|
||||||
GetSwapChainFlags());
|
GetSwapChainFlags());
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
WARN_LOG_FMT(VIDEO, "ResizeBuffers() failed with HRESULT {:08X}", hr);
|
WARN_LOG_FMT(VIDEO, "ResizeBuffers() failed: {}", Common::HRWrap(hr));
|
||||||
|
|
||||||
DXGI_SWAP_CHAIN_DESC desc;
|
DXGI_SWAP_CHAIN_DESC desc;
|
||||||
if (SUCCEEDED(m_swap_chain->GetDesc(&desc)))
|
if (SUCCEEDED(m_swap_chain->GetDesc(&desc)))
|
||||||
|
@ -236,7 +238,7 @@ bool SwapChain::Present()
|
||||||
HRESULT hr = m_swap_chain->Present(static_cast<UINT>(g_ActiveConfig.bVSyncActive), present_flags);
|
HRESULT hr = m_swap_chain->Present(static_cast<UINT>(g_ActiveConfig.bVSyncActive), present_flags);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
WARN_LOG_FMT(VIDEO, "Swap chain present failed with HRESULT {:08X}", hr);
|
WARN_LOG_FMT(VIDEO, "Swap chain present failed: {}", Common::HRWrap(hr));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue