Skip to content

Commit

Permalink
Merge pull request godotengine#39143 from madmiraal/fix-39116
Browse files Browse the repository at this point in the history
Do not probe joypads if DirectInput cannot be initialized.
  • Loading branch information
akien-mga authored May 29, 2020
2 parents d19257e + 97a529b commit ef5910e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions platform/windows/joypad_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit ef5910e

Please sign in to comment.