[PATCH 1/3] dinput: Disable linuxinput or linux joysticks based on registry key (try 2)
Lucas Zawacki
lfzawacki at gmail.com
Wed Aug 22 16:55:33 CDT 2012
From: Lucas Fialho Zawacki <lfzawacki at gmail.com>
In the form of "controllername(drivername)"="disabled" key
Examples:
Disable the linux js driver for "Usb Controller" device
"Usb Controller(js)"="disabled"
Disable the linux js and event drivers for "Other Controller" device
"OtherController(event)"="disabled"
"OtherController(js)"="disabled"
This can help the users with bugs #26810 and #30690
---
dlls/dinput/joystick.c | 45 +++++++++++++++++++++++++++++++++++++
dlls/dinput/joystick_linux.c | 3 +++
dlls/dinput/joystick_linuxinput.c | 8 ++++---
dlls/dinput/joystick_private.h | 2 ++
4 files changed, 55 insertions(+), 3 deletions(-)
diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c
index dfcaeb7..a365b82 100644
--- a/dlls/dinput/joystick.c
+++ b/dlls/dinput/joystick.c
@@ -49,6 +49,51 @@ static inline IDirectInputDevice8W *IDirectInputDevice8W_from_impl(JoystickGener
return &This->base.IDirectInputDevice8W_iface;
}
+BOOL device_disabled_registry(const char* name, const char* driver)
+{
+ static const char *disabled_str = "disabled";
+ char buffer[MAX_PATH];
+ HKEY hkey, appkey;
+ BOOL do_disable = FALSE;
+ char *disable_name;
+
+ int str_size = strlen(name) + strlen(driver) + 3;
+ disable_name = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, str_size);
+
+ if (!disable_name) return FALSE;
+
+ strcat(disable_name, name);
+ strcat(disable_name, "(");
+ strcat(disable_name, driver);
+ strcat(disable_name, ")");
+
+ get_app_key(&hkey, &appkey);
+
+ /* Look for the "controllername(drivername)"="disabled" key
+
+ Examples:
+ Disable the linux js driver for "Usb Controller" device
+ "Usb Controller(js)"="disabled"
+
+ Disable the linux js and event drivers for "Other Controller" device
+ "OtherController(event)"="disabled"
+ "OtherController(js)"="disabled"
+ */
+ if (!get_config_key(hkey, appkey, disable_name, buffer, sizeof(buffer)))
+ if (!strncmp(disabled_str, buffer, sizeof(disabled_str)))
+ {
+ TRACE("Disabling joystick '%s(%s)' based on registry key.\n", name, driver);
+ do_disable = TRUE;
+ }
+
+ HeapFree(GetProcessHeap(), 0, disable_name);
+
+ if (appkey) RegCloseKey(appkey);
+ if (hkey) RegCloseKey(hkey);
+
+ return do_disable;
+}
+
/******************************************************************************
* SetProperty : change input device properties
*/
diff --git a/dlls/dinput/joystick_linux.c b/dlls/dinput/joystick_linux.c
index 5afd07c..a1ad818 100644
--- a/dlls/dinput/joystick_linux.c
+++ b/dlls/dinput/joystick_linux.c
@@ -153,6 +153,9 @@ static INT find_joystick_devices(void)
if (ioctl(fd, JSIOCGNAME(sizeof(joydev.name)), joydev.name) < 0)
WARN("ioctl(%s,JSIOCGNAME) failed: %s\n", joydev.device, strerror(errno));
#endif
+
+ if (device_disabled_registry(joydev.name, "js")) continue;
+
#ifdef JSIOCGAXES
if (ioctl(fd, JSIOCGAXES, &joydev.axis_count) < 0)
{
diff --git a/dlls/dinput/joystick_linuxinput.c b/dlls/dinput/joystick_linuxinput.c
index 3cab015..54f9fdd 100644
--- a/dlls/dinput/joystick_linuxinput.c
+++ b/dlls/dinput/joystick_linuxinput.c
@@ -246,10 +246,12 @@ static void find_joydevs(void)
else
joydev.name = joydev.device;
- joydev.guid = DInput_Wine_Joystick_Base_GUID;
- joydev.guid.Data3 += have_joydevs;
+ if (device_disabled_registry(joydev.name, "event")) continue;
- TRACE("Found a joystick on %s: %s (%s)\n",
+ joydev.guid = DInput_Wine_Joystick_Base_GUID;
+ joydev.guid.Data3 += have_joydevs;
+
+ TRACE("Found a joystick on %s: %s (%s)\n",
joydev.device, joydev.name,
debugstr_guid(&joydev.guid)
);
diff --git a/dlls/dinput/joystick_private.h b/dlls/dinput/joystick_private.h
index 71d91f1..97becc7 100644
--- a/dlls/dinput/joystick_private.h
+++ b/dlls/dinput/joystick_private.h
@@ -57,6 +57,8 @@ HRESULT setup_dinput_options(JoystickGenericImpl *This, const int *default_axis_
DWORD joystick_map_pov(const POINTL *p) DECLSPEC_HIDDEN;
+BOOL device_disabled_registry(const char* name, const char* driver) DECLSPEC_HIDDEN;
+
HRESULT WINAPI JoystickWGenericImpl_GetObjectInfo(LPDIRECTINPUTDEVICE8W iface,
LPDIDEVICEOBJECTINSTANCEW pdidoi, DWORD dwObj, DWORD dwHow) DECLSPEC_HIDDEN;
--
1.7.9.5
More information about the wine-patches
mailing list