Do not probe joypads if DirectInput cannot be initialized.

(cherry picked from commit 97a529b1d8)
This commit is contained in:
Marcel Admiraal 2020-05-29 10:15:43 +01:00 committed by Rémi Verschelde
parent d814352d92
commit 6c9c6885a2
1 changed files with 9 additions and 6 deletions

View File

@ -67,13 +67,16 @@ JoypadWindows::JoypadWindows(InputDefault *_input, HWND *hwnd) {
for (int i = 0; i < JOYPADS_MAX; i++) for (int i = 0; i < JOYPADS_MAX; i++)
attached_joypads[i] = false; attached_joypads[i] = false;
HRESULT result; HRESULT result = DirectInput8Create(GetModuleHandle(nullptr), DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&dinput, nullptr);
result = DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, (void **)&dinput, NULL); if (result == DI_OK) {
if (FAILED(result)) { probe_joypads();
printf("Couldn't initialize DirectInput: %ld\n", result); } else {
printf("Rebooting your PC may solve this issue.\n"); 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() { JoypadWindows::~JoypadWindows() {