diff options
author | Marcel Admiraal <madmiraal@users.noreply.github.com> | 2020-05-29 16:39:58 +0100 |
---|---|---|
committer | Marcel Admiraal <madmiraal@users.noreply.github.com> | 2020-05-30 13:59:30 +0100 |
commit | bc49d3412349ed11c03618c96c4889c5620fe5f0 (patch) | |
tree | d79dfb9a72e413c7fcb091b6a1712a5125222f70 /platform/windows | |
parent | 240032ade752c68854c2fb8223a913ca0e87f586 (diff) |
Add dinput nullptr checks.
Diffstat (limited to 'platform/windows')
-rw-r--r-- | platform/windows/joypad_windows.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp index 20662ec591..a6ec95ea10 100644 --- a/platform/windows/joypad_windows.cpp +++ b/platform/windows/joypad_windows.cpp @@ -76,12 +76,16 @@ JoypadWindows::JoypadWindows(HWND *hwnd) { ERR_PRINT("The Windows DirectInput subsystem could not allocate sufficient memory."); ERR_PRINT("Rebooting your PC may solve this issue."); } + // Ensure dinput is still a nullptr. + dinput = nullptr; } } JoypadWindows::~JoypadWindows() { close_joypad(); - dinput->Release(); + if (dinput) { + dinput->Release(); + } unload_xinput(); } @@ -139,6 +143,7 @@ bool JoypadWindows::is_xinput_device(const GUID *p_guid) { } bool JoypadWindows::setup_dinput_joypad(const DIDEVICEINSTANCE *instance) { + ERR_FAIL_NULL_V_MSG(dinput, false, "DirectInput not initialized. Rebooting your PC may solve this issue."); HRESULT hr; int num = input->get_unused_joy_id(); @@ -270,6 +275,7 @@ void JoypadWindows::close_joypad(int id) { } void JoypadWindows::probe_joypads() { + ERR_FAIL_NULL_MSG(dinput, "DirectInput not initialized. Rebooting your PC may solve this issue."); DWORD dwResult; for (DWORD i = 0; i < XUSER_MAX_COUNT; i++) { ZeroMemory(&x_joypads[i].state, sizeof(XINPUT_STATE)); |