Path: blob/master/scripts/deps/sdl3-ezfrd64-dll.patch
7197 views
From f369e804e27731e128caf3b370e0569e0695c57e Mon Sep 17 00:00:00 20011From: Sam Lantinga <[email protected]>2Date: Wed, 7 Jan 2026 17:11:57 -08003Subject: [PATCH] Fixed crash when the broken EZFRD64.DLL is present45Fixes https://github.com/ppy/osu/issues/136346---7src/joystick/windows/SDL_dinputjoystick.c | 38 +++++++++++++++++++----81 file changed, 32 insertions(+), 6 deletions(-)910diff --git a/src/joystick/windows/SDL_dinputjoystick.c b/src/joystick/windows/SDL_dinputjoystick.c11index d265d9fcd5fa4..62ffbb46ec9fa 10064412--- a/src/joystick/windows/SDL_dinputjoystick.c13+++ b/src/joystick/windows/SDL_dinputjoystick.c14@@ -45,6 +45,7 @@ extern HWND SDL_HelperWindow;15// local variables16static bool coinitialized = false;17static LPDIRECTINPUT8 dinput = NULL;18+static bool has_broken_EZFRD64DLL = false;1920// Taken from Wine - Thanks!21static DIOBJECTDATAFORMAT dfDIJoystick2[] = {22@@ -437,6 +438,29 @@ bool SDL_DINPUT_JoystickInit(void)23dinput = NULL;24return SetDIerror("IDirectInput::Initialize", result);25}26+27+#ifdef _WIN6428+ if (SDL_GetHintBoolean("SDL_JOYSTICK_CHECK_EZFRD64", true)) {29+ // The 64-bit version of EZFRD64.DLL crashes after being loaded,30+ // which happens implicitly when querying the device capabilities,31+ // so make sure we don't do that if there's a possibility of crashing32+ static const char *directories[] = {33+ "C:/Windows/USB_Vibration",34+ "C:/Windows/USB Vibration"35+ };36+ for (int i = 0; i < SDL_arraysize(directories) && !has_broken_EZFRD64DLL; ++i) {37+ int count = 0;38+ char **files = SDL_GlobDirectory(directories[i], "*/EZFRD64.DLL", SDL_GLOB_CASEINSENSITIVE, &count);39+ if (count > 0) {40+ has_broken_EZFRD64DLL = true;41+ }42+ SDL_free(files);43+ }44+ if (has_broken_EZFRD64DLL) {45+ SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, "Broken EZFRD64.DLL detected, disabling DirectInput force feedback");46+ }47+ }48+#endif49return true;50}5152@@ -778,12 +802,14 @@ bool SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joysti53return SetDIerror("IDirectInputDevice8::SetDataFormat", result);54}5556- // Get device capabilities57- result =58- IDirectInputDevice8_GetCapabilities(joystick->hwdata->InputDevice,59- &joystick->hwdata->Capabilities);60- if (FAILED(result)) {61- return SetDIerror("IDirectInputDevice8::GetCapabilities", result);62+ if (!has_broken_EZFRD64DLL) {63+ // Get device capabilities to see if we are force feedback capable64+ result =65+ IDirectInputDevice8_GetCapabilities(joystick->hwdata->InputDevice,66+ &joystick->hwdata->Capabilities);67+ if (FAILED(result)) {68+ return SetDIerror("IDirectInputDevice8::GetCapabilities", result);69+ }70}7172// Force capable?737475