Unverified Commit 20a6fcd3 by Rémi Verschelde Committed by GitHub

Merge pull request #39163 from madmiraal/dinput-nullptr-checks

Add dinput nullptr checks.
parents 240032ad bc49d341
......@@ -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));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment