Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/xinput1_1/Makefile.in | 2 +- dlls/xinput1_2/Makefile.in | 2 +- dlls/xinput1_3/Makefile.in | 2 +- dlls/xinput1_3/main.c | 48 ++++++++++++++++++++++++++++++++++++ dlls/xinput1_4/Makefile.in | 2 +- dlls/xinput9_1_0/Makefile.in | 2 +- 6 files changed, 53 insertions(+), 5 deletions(-)
diff --git a/dlls/xinput1_1/Makefile.in b/dlls/xinput1_1/Makefile.in index 25572e18b21..f5d587b95a3 100644 --- a/dlls/xinput1_1/Makefile.in +++ b/dlls/xinput1_1/Makefile.in @@ -1,6 +1,6 @@ MODULE = xinput1_1.dll PARENTSRC = ../xinput1_3 -DELAYIMPORTS = hid setupapi +DELAYIMPORTS = hid setupapi advapi32
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/xinput1_2/Makefile.in b/dlls/xinput1_2/Makefile.in index 3358c2cd3c8..5d2ab174732 100644 --- a/dlls/xinput1_2/Makefile.in +++ b/dlls/xinput1_2/Makefile.in @@ -1,6 +1,6 @@ MODULE = xinput1_2.dll PARENTSRC = ../xinput1_3 -DELAYIMPORTS = hid setupapi +DELAYIMPORTS = hid setupapi advapi32
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/xinput1_3/Makefile.in b/dlls/xinput1_3/Makefile.in index 93281d4e853..5d1db7626cf 100644 --- a/dlls/xinput1_3/Makefile.in +++ b/dlls/xinput1_3/Makefile.in @@ -1,6 +1,6 @@ MODULE = xinput1_3.dll IMPORTLIB = xinput -DELAYIMPORTS = hid setupapi +DELAYIMPORTS = hid setupapi advapi32
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/xinput1_3/main.c b/dlls/xinput1_3/main.c index 2881a370534..81d11e5d38f 100644 --- a/dlls/xinput1_3/main.c +++ b/dlls/xinput1_3/main.c @@ -394,6 +394,52 @@ failed: return FALSE; }
+static void get_registry_keys(HKEY *defkey, HKEY *appkey) +{ + WCHAR buffer[MAX_PATH + 26], *name = buffer, *tmp; + DWORD len; + HKEY hkey; + + *appkey = 0; + if (RegOpenKeyW(HKEY_CURRENT_USER, L"Software\Wine\DirectInput\Joysticks", defkey)) + *defkey = 0; + + if (!(len = GetModuleFileNameW(0, buffer, MAX_PATH)) || len >= MAX_PATH) + return; + + if (!RegOpenKeyW(HKEY_CURRENT_USER, L"Software\Wine\AppDefaults", &hkey)) + { + if ((tmp = wcsrchr(name, '/'))) name = tmp + 1; + if ((tmp = wcsrchr(name, '\'))) name = tmp + 1; + wcscat(name, L"\DirectInput\Joysticks"); + if (RegOpenKeyW(hkey, name, appkey)) *appkey = 0; + RegCloseKey(hkey); + } +} + +static BOOL device_is_overriden(HANDLE device) +{ + WCHAR name[MAX_PATH], buffer[MAX_PATH]; + DWORD size = sizeof(buffer); + BOOL disable = FALSE; + HKEY defkey, appkey; + + if (!HidD_GetProductString(device, name, MAX_PATH)) return FALSE; + + get_registry_keys(&defkey, &appkey); + if (!defkey && !appkey) return FALSE; + if ((appkey && !RegQueryValueExW(appkey, name, 0, NULL, (LPBYTE)buffer, &size)) || + (defkey && !RegQueryValueExW(defkey, name, 0, NULL, (LPBYTE)buffer, &size))) + { + if ((disable = !wcscmp(buffer, L"override"))) + TRACE("Disabling gamepad '%s' based on registry key.\n", debugstr_w(name)); + } + + if (appkey) RegCloseKey(appkey); + if (defkey) RegCloseKey(defkey); + return disable; +} + static void update_controller_list(void) { char buffer[sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W) + MAX_PATH * sizeof(WCHAR)]; @@ -437,6 +483,8 @@ static void update_controller_list(void) else if (caps.Usage != HID_USAGE_GENERIC_GAMEPAD && caps.Usage != HID_USAGE_GENERIC_JOYSTICK && caps.Usage != HID_USAGE_GENERIC_MULTI_AXIS_CONTROLLER) WARN("ignoring HID device, unsupported usage %04x:%04x\n", caps.UsagePage, caps.Usage); + else if (device_is_overriden(device)) + WARN("ignoring HID device, overriden for dinput\n"); else if (!controller_init(&controllers[i], preparsed, &caps, device, detail->DevicePath)) WARN("ignoring HID device, failed to initialize\n"); else diff --git a/dlls/xinput1_4/Makefile.in b/dlls/xinput1_4/Makefile.in index 24b10b1e848..18fd3dd3bb2 100644 --- a/dlls/xinput1_4/Makefile.in +++ b/dlls/xinput1_4/Makefile.in @@ -1,6 +1,6 @@ MODULE = xinput1_4.dll PARENTSRC = ../xinput1_3 -DELAYIMPORTS = hid setupapi +DELAYIMPORTS = hid setupapi advapi32
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/xinput9_1_0/Makefile.in b/dlls/xinput9_1_0/Makefile.in index 0142c95c44f..82979ac8e9f 100644 --- a/dlls/xinput9_1_0/Makefile.in +++ b/dlls/xinput9_1_0/Makefile.in @@ -1,6 +1,6 @@ MODULE = xinput9_1_0.dll PARENTSRC = ../xinput1_3 -DELAYIMPORTS = hid setupapi +DELAYIMPORTS = hid setupapi advapi32
EXTRADLLFLAGS = -mno-cygwin