mirror of https://github.com/PCSX2/pcsx2.git
DInputSource: Use wil on m_dinput_module
This commit is contained in:
parent
c4bf297f42
commit
6a40959f3a
|
@ -32,13 +32,7 @@ using PFNGETDFDIJOYSTICK = LPCDIDATAFORMAT(WINAPI*)();
|
||||||
|
|
||||||
DInputSource::DInputSource() = default;
|
DInputSource::DInputSource() = default;
|
||||||
|
|
||||||
DInputSource::~DInputSource()
|
DInputSource::~DInputSource() = default;
|
||||||
{
|
|
||||||
m_controllers.clear();
|
|
||||||
m_dinput.reset();
|
|
||||||
if (m_dinput_module)
|
|
||||||
FreeLibrary(m_dinput_module);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::array<bool, DInputSource::NUM_HAT_DIRECTIONS> DInputSource::GetHatButtons(DWORD hat)
|
std::array<bool, DInputSource::NUM_HAT_DIRECTIONS> DInputSource::GetHatButtons(DWORD hat)
|
||||||
{
|
{
|
||||||
|
@ -69,15 +63,15 @@ static constexpr std::array<const char*, DInputSource::NUM_HAT_DIRECTIONS> s_hat
|
||||||
|
|
||||||
bool DInputSource::Initialize(SettingsInterface& si, std::unique_lock<std::mutex>& settings_lock)
|
bool DInputSource::Initialize(SettingsInterface& si, std::unique_lock<std::mutex>& settings_lock)
|
||||||
{
|
{
|
||||||
m_dinput_module = LoadLibraryW(L"dinput8");
|
m_dinput_module.reset(LoadLibraryW(L"dinput8"));
|
||||||
if (!m_dinput_module)
|
if (!m_dinput_module)
|
||||||
{
|
{
|
||||||
Console.Error("Failed to load DInput module.");
|
Console.Error("Failed to load DInput module.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PFNDIRECTINPUT8CREATE create = reinterpret_cast<PFNDIRECTINPUT8CREATE>(GetProcAddress(m_dinput_module, "DirectInput8Create"));
|
PFNDIRECTINPUT8CREATE create = reinterpret_cast<PFNDIRECTINPUT8CREATE>(GetProcAddress(m_dinput_module.get(), "DirectInput8Create"));
|
||||||
PFNGETDFDIJOYSTICK get_joystick_data_format = reinterpret_cast<PFNGETDFDIJOYSTICK>(GetProcAddress(m_dinput_module, "GetdfDIJoystick"));
|
PFNGETDFDIJOYSTICK get_joystick_data_format = reinterpret_cast<PFNGETDFDIJOYSTICK>(GetProcAddress(m_dinput_module.get(), "GetdfDIJoystick"));
|
||||||
if (!create || !get_joystick_data_format)
|
if (!create || !get_joystick_data_format)
|
||||||
{
|
{
|
||||||
Console.Error("Failed to get DInput function pointers.");
|
Console.Error("Failed to get DInput function pointers.");
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <wil/resource.h>
|
||||||
|
|
||||||
class DInputSource final : public InputSource
|
class DInputSource final : public InputSource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -83,10 +85,11 @@ private:
|
||||||
|
|
||||||
void CheckForStateChanges(size_t index, const DIJOYSTATE& new_state);
|
void CheckForStateChanges(size_t index, const DIJOYSTATE& new_state);
|
||||||
|
|
||||||
ControllerDataArray m_controllers;
|
// Those must go first in the class so they are destroyed last
|
||||||
|
wil::unique_hmodule m_dinput_module;
|
||||||
HMODULE m_dinput_module{};
|
|
||||||
wil::com_ptr_nothrow<IDirectInput8W> m_dinput;
|
wil::com_ptr_nothrow<IDirectInput8W> m_dinput;
|
||||||
LPCDIDATAFORMAT m_joystick_data_format{};
|
LPCDIDATAFORMAT m_joystick_data_format{};
|
||||||
HWND m_toplevel_window = NULL;
|
HWND m_toplevel_window = nullptr;
|
||||||
|
|
||||||
|
ControllerDataArray m_controllers;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue