dinput: Disable linuxinput or linux joysticks based on registry key

Lucas Zawacki lfzawacki at gmail.com
Tue Jun 26 22:06:01 CDT 2012


From: Lucas Fialho Zawacki <lfzawacki at gmail.com>

---
 dlls/dinput/joystick.c            |   39 +++++++++++++++++++++++++++++++++++++
 dlls/dinput/joystick_linux.c      |    3 +++
 dlls/dinput/joystick_linuxinput.c |    2 ++
 dlls/dinput/joystick_private.h    |    2 ++
 4 files changed, 46 insertions(+)

diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c
index dfcaeb7..3cc7d2c 100644
--- a/dlls/dinput/joystick.c
+++ b/dlls/dinput/joystick.c
@@ -49,6 +49,45 @@ 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 disable_str[] = "Disable ";
+    static const char all[] = "all";
+
+    char buffer[MAX_PATH];
+    HKEY hkey, appkey;
+    BOOL do_disable = FALSE;
+    char *disable_name;
+
+    int str_size = strlen(name) + strlen(disable_str) + 1;
+    disable_name = HeapAlloc(GetProcessHeap(), 0, str_size);
+
+    if (!disable_name) return FALSE;
+
+    disable_name[0] = '\0';
+    strcat(disable_name, disable_str);
+    strcat(disable_name, name);
+
+    get_app_key(&hkey, &appkey);
+
+    /* Look for the "Disable controllername"="drivername" key */
+    if (!get_config_key(hkey, appkey, disable_name, buffer, sizeof(buffer)))
+    {
+        if (!strcmp(buffer, all) || !strcmp(buffer, driver))
+        {
+            TRACE("Disabling %s joystick %s -> %s\n", driver, name, buffer);
+            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..ff999b3 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, "linux")) 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..d078fdf 100644
--- a/dlls/dinput/joystick_linuxinput.c
+++ b/dlls/dinput/joystick_linuxinput.c
@@ -246,6 +246,8 @@ static void find_joydevs(void)
         else
             joydev.name = joydev.device;
 
+        if (device_disabled_registry(joydev.name, "linuxinput")) continue;
+
 	joydev.guid = DInput_Wine_Joystick_Base_GUID;
 	joydev.guid.Data3 += have_joydevs;
 
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