Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/scripts/deps/sdl3-ezfrd64-dll.patch
7197 views
1
From f369e804e27731e128caf3b370e0569e0695c57e Mon Sep 17 00:00:00 2001
2
From: Sam Lantinga <[email protected]>
3
Date: Wed, 7 Jan 2026 17:11:57 -0800
4
Subject: [PATCH] Fixed crash when the broken EZFRD64.DLL is present
5
6
Fixes https://github.com/ppy/osu/issues/13634
7
---
8
src/joystick/windows/SDL_dinputjoystick.c | 38 +++++++++++++++++++----
9
1 file changed, 32 insertions(+), 6 deletions(-)
10
11
diff --git a/src/joystick/windows/SDL_dinputjoystick.c b/src/joystick/windows/SDL_dinputjoystick.c
12
index d265d9fcd5fa4..62ffbb46ec9fa 100644
13
--- a/src/joystick/windows/SDL_dinputjoystick.c
14
+++ b/src/joystick/windows/SDL_dinputjoystick.c
15
@@ -45,6 +45,7 @@ extern HWND SDL_HelperWindow;
16
// local variables
17
static bool coinitialized = false;
18
static LPDIRECTINPUT8 dinput = NULL;
19
+static bool has_broken_EZFRD64DLL = false;
20
21
// Taken from Wine - Thanks!
22
static DIOBJECTDATAFORMAT dfDIJoystick2[] = {
23
@@ -437,6 +438,29 @@ bool SDL_DINPUT_JoystickInit(void)
24
dinput = NULL;
25
return SetDIerror("IDirectInput::Initialize", result);
26
}
27
+
28
+#ifdef _WIN64
29
+ if (SDL_GetHintBoolean("SDL_JOYSTICK_CHECK_EZFRD64", true)) {
30
+ // The 64-bit version of EZFRD64.DLL crashes after being loaded,
31
+ // which happens implicitly when querying the device capabilities,
32
+ // so make sure we don't do that if there's a possibility of crashing
33
+ static const char *directories[] = {
34
+ "C:/Windows/USB_Vibration",
35
+ "C:/Windows/USB Vibration"
36
+ };
37
+ for (int i = 0; i < SDL_arraysize(directories) && !has_broken_EZFRD64DLL; ++i) {
38
+ int count = 0;
39
+ char **files = SDL_GlobDirectory(directories[i], "*/EZFRD64.DLL", SDL_GLOB_CASEINSENSITIVE, &count);
40
+ if (count > 0) {
41
+ has_broken_EZFRD64DLL = true;
42
+ }
43
+ SDL_free(files);
44
+ }
45
+ if (has_broken_EZFRD64DLL) {
46
+ SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, "Broken EZFRD64.DLL detected, disabling DirectInput force feedback");
47
+ }
48
+ }
49
+#endif
50
return true;
51
}
52
53
@@ -778,12 +802,14 @@ bool SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joysti
54
return SetDIerror("IDirectInputDevice8::SetDataFormat", result);
55
}
56
57
- // Get device capabilities
58
- result =
59
- IDirectInputDevice8_GetCapabilities(joystick->hwdata->InputDevice,
60
- &joystick->hwdata->Capabilities);
61
- if (FAILED(result)) {
62
- return SetDIerror("IDirectInputDevice8::GetCapabilities", result);
63
+ if (!has_broken_EZFRD64DLL) {
64
+ // Get device capabilities to see if we are force feedback capable
65
+ result =
66
+ IDirectInputDevice8_GetCapabilities(joystick->hwdata->InputDevice,
67
+ &joystick->hwdata->Capabilities);
68
+ if (FAILED(result)) {
69
+ return SetDIerror("IDirectInputDevice8::GetCapabilities", result);
70
+ }
71
}
72
73
// Force capable?
74
75