diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-05-29 13:44:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-29 13:44:53 +0200 |
commit | ef5910eea5ae47da240ea5233f82e92153f5b99e (patch) | |
tree | 37e42bd3b512f957a8ae3b3925a4467f2b4fb0e9 /platform | |
parent | d19257eb2ba6cf275a1a7be23f66054afa235df3 (diff) | |
parent | 97a529b1d817aff085777d1bc25272fad60b60b2 (diff) |
Merge pull request #39143 from madmiraal/fix-39116
Do not probe joypads if DirectInput cannot be initialized.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/windows/joypad_windows.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/platform/windows/joypad_windows.cpp b/platform/windows/joypad_windows.cpp index 50f090d2b0..20662ec591 100644 --- a/platform/windows/joypad_windows.cpp +++ b/platform/windows/joypad_windows.cpp @@ -67,13 +67,16 @@ JoypadWindows::JoypadWindows(HWND *hwnd) { for (int i = 0; i < JOYPADS_MAX; i++) attached_joypads[i] = false; - HRESULT result; - result = DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&dinput, nullptr); - if (FAILED(result)) { - printf("Couldn't initialize DirectInput: %ld\n", result); - printf("Rebooting your PC may solve this issue.\n"); + HRESULT result = DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&dinput, nullptr); + if (result == DI_OK) { + probe_joypads(); + } else { + ERR_PRINT("Couldn't initialize DirectInput. Error: " + itos(result)); + if (result == DIERR_OUTOFMEMORY) { + ERR_PRINT("The Windows DirectInput subsystem could not allocate sufficient memory."); + ERR_PRINT("Rebooting your PC may solve this issue."); + } } - probe_joypads(); } JoypadWindows::~JoypadWindows() { |