mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-01 06:44:27 +08:00
Fixed crash when the broken EZFRD64.DLL is present
Fixes https://github.com/ppy/osu/issues/13634
(cherry picked from commit f369e804e2)
This commit is contained in:
@@ -45,6 +45,7 @@ extern HWND SDL_HelperWindow;
|
|||||||
// local variables
|
// local variables
|
||||||
static bool coinitialized = false;
|
static bool coinitialized = false;
|
||||||
static LPDIRECTINPUT8 dinput = NULL;
|
static LPDIRECTINPUT8 dinput = NULL;
|
||||||
|
static bool has_broken_EZFRD64DLL = false;
|
||||||
|
|
||||||
// Taken from Wine - Thanks!
|
// Taken from Wine - Thanks!
|
||||||
static DIOBJECTDATAFORMAT dfDIJoystick2[] = {
|
static DIOBJECTDATAFORMAT dfDIJoystick2[] = {
|
||||||
@@ -437,6 +438,29 @@ bool SDL_DINPUT_JoystickInit(void)
|
|||||||
dinput = NULL;
|
dinput = NULL;
|
||||||
return SetDIerror("IDirectInput::Initialize", result);
|
return SetDIerror("IDirectInput::Initialize", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN64
|
||||||
|
if (SDL_GetHintBoolean("SDL_JOYSTICK_CHECK_EZFRD64", true)) {
|
||||||
|
// The 64-bit version of EZFRD64.DLL crashes after being loaded,
|
||||||
|
// which happens implicitly when querying the device capabilities,
|
||||||
|
// so make sure we don't do that if there's a possibility of crashing
|
||||||
|
static const char *directories[] = {
|
||||||
|
"C:/Windows/USB_Vibration",
|
||||||
|
"C:/Windows/USB Vibration"
|
||||||
|
};
|
||||||
|
for (int i = 0; i < SDL_arraysize(directories) && !has_broken_EZFRD64DLL; ++i) {
|
||||||
|
int count = 0;
|
||||||
|
char **files = SDL_GlobDirectory(directories[i], "*/EZFRD64.DLL", SDL_GLOB_CASEINSENSITIVE, &count);
|
||||||
|
if (count > 0) {
|
||||||
|
has_broken_EZFRD64DLL = true;
|
||||||
|
}
|
||||||
|
SDL_free(files);
|
||||||
|
}
|
||||||
|
if (has_broken_EZFRD64DLL) {
|
||||||
|
SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, "Broken EZFRD64.DLL detected, disabling DirectInput force feedback");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -778,12 +802,14 @@ bool SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joysti
|
|||||||
return SetDIerror("IDirectInputDevice8::SetDataFormat", result);
|
return SetDIerror("IDirectInputDevice8::SetDataFormat", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get device capabilities
|
if (!has_broken_EZFRD64DLL) {
|
||||||
result =
|
// Get device capabilities to see if we are force feedback capable
|
||||||
IDirectInputDevice8_GetCapabilities(joystick->hwdata->InputDevice,
|
result =
|
||||||
&joystick->hwdata->Capabilities);
|
IDirectInputDevice8_GetCapabilities(joystick->hwdata->InputDevice,
|
||||||
if (FAILED(result)) {
|
&joystick->hwdata->Capabilities);
|
||||||
return SetDIerror("IDirectInputDevice8::GetCapabilities", result);
|
if (FAILED(result)) {
|
||||||
|
return SetDIerror("IDirectInputDevice8::GetCapabilities", result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force capable?
|
// Force capable?
|
||||||
|
|||||||
Reference in New Issue
Block a user