Rémi Bernon : dinput: Move device_instance_is_disabled to device.c.

Alexandre Julliard julliard at winehq.org
Mon Oct 11 15:41:34 CDT 2021


Module: wine
Branch: master
Commit: 46d35211203201cbe1826db98c15f488ed91a883
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=46d35211203201cbe1826db98c15f488ed91a883

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Mon Oct 11 10:10:55 2021 +0200

dinput: Move device_instance_is_disabled to device.c.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dinput/device.c         | 48 ++++++++++++++++++++++++++++++++++++++++++++
 dlls/dinput/device_private.h |  1 +
 dlls/dinput/joystick.c       | 48 --------------------------------------------
 3 files changed, 49 insertions(+), 48 deletions(-)

diff --git a/dlls/dinput/device.c b/dlls/dinput/device.c
index d869f439101..61f6effad19 100644
--- a/dlls/dinput/device.c
+++ b/dlls/dinput/device.c
@@ -314,6 +314,54 @@ DWORD get_config_key( HKEY defkey, HKEY appkey, const WCHAR *name, WCHAR *buffer
     return ERROR_FILE_NOT_FOUND;
 }
 
+BOOL device_instance_is_disabled( DIDEVICEINSTANCEW *instance, BOOL *override )
+{
+    static const WCHAR disabled_str[] = {'d', 'i', 's', 'a', 'b', 'l', 'e', 'd', 0};
+    static const WCHAR override_str[] = {'o', 'v', 'e', 'r', 'r', 'i', 'd', 'e', 0};
+    static const WCHAR joystick_key[] = {'J', 'o', 'y', 's', 't', 'i', 'c', 'k', 's', 0};
+    WCHAR buffer[MAX_PATH];
+    HKEY hkey, appkey, temp;
+    BOOL disable = FALSE;
+
+    get_app_key( &hkey, &appkey );
+    if (override) *override = FALSE;
+
+    /* Joystick settings are in the 'joysticks' subkey */
+    if (appkey)
+    {
+        if (RegOpenKeyW( appkey, joystick_key, &temp )) temp = 0;
+        RegCloseKey( appkey );
+        appkey = temp;
+    }
+
+    if (hkey)
+    {
+        if (RegOpenKeyW( hkey, joystick_key, &temp )) temp = 0;
+        RegCloseKey( hkey );
+        hkey = temp;
+    }
+
+    /* Look for the "controllername"="disabled" key */
+    if (!get_config_key( hkey, appkey, instance->tszInstanceName, buffer, sizeof(buffer) ))
+    {
+        if (!strcmpW( disabled_str, buffer ))
+        {
+            TRACE( "Disabling joystick '%s' based on registry key.\n", debugstr_w(instance->tszInstanceName) );
+            disable = TRUE;
+        }
+        else if (override && !strcmpW( override_str, buffer ))
+        {
+            TRACE( "Force enabling joystick '%s' based on registry key.\n", debugstr_w(instance->tszInstanceName) );
+            *override = TRUE;
+        }
+    }
+
+    if (appkey) RegCloseKey( appkey );
+    if (hkey) RegCloseKey( hkey );
+
+    return disable;
+}
+
 /* Conversion between internal data buffer and external data buffer */
 void fill_DataFormat(void *out, DWORD size, const void *in, const DataFormat *df)
 {
diff --git a/dlls/dinput/device_private.h b/dlls/dinput/device_private.h
index 90eab627c26..8aced6d84dd 100644
--- a/dlls/dinput/device_private.h
+++ b/dlls/dinput/device_private.h
@@ -98,6 +98,7 @@ extern const IDirectInputDevice8AVtbl dinput_device_a_vtbl DECLSPEC_HIDDEN;
 
 extern BOOL get_app_key(HKEY*, HKEY*) DECLSPEC_HIDDEN;
 extern DWORD get_config_key( HKEY, HKEY, const WCHAR *, WCHAR *, DWORD ) DECLSPEC_HIDDEN;
+extern BOOL device_instance_is_disabled( DIDEVICEINSTANCEW *instance, BOOL *override ) DECLSPEC_HIDDEN;
 
 /* Routines to do DataFormat / WineFormat conversions */
 extern void fill_DataFormat(void *out, DWORD size, const void *in, const DataFormat *df)  DECLSPEC_HIDDEN;
diff --git a/dlls/dinput/joystick.c b/dlls/dinput/joystick.c
index 6e573e8741a..979d5a5c7f2 100644
--- a/dlls/dinput/joystick.c
+++ b/dlls/dinput/joystick.c
@@ -279,54 +279,6 @@ BOOL device_disabled_registry(const char* name)
     return device_instance_is_disabled( &instance, NULL );
 }
 
-BOOL device_instance_is_disabled( DIDEVICEINSTANCEW *instance, BOOL *override )
-{
-    static const WCHAR disabled_str[] = {'d', 'i', 's', 'a', 'b', 'l', 'e', 'd', 0};
-    static const WCHAR override_str[] = {'o', 'v', 'e', 'r', 'r', 'i', 'd', 'e', 0};
-    static const WCHAR joystick_key[] = {'J', 'o', 'y', 's', 't', 'i', 'c', 'k', 's', 0};
-    WCHAR buffer[MAX_PATH];
-    HKEY hkey, appkey, temp;
-    BOOL disable = FALSE;
-
-    get_app_key(&hkey, &appkey);
-    if (override) *override = FALSE;
-
-    /* Joystick settings are in the 'joysticks' subkey */
-    if (appkey)
-    {
-        if (RegOpenKeyW( appkey, joystick_key, &temp )) temp = 0;
-        RegCloseKey(appkey);
-        appkey = temp;
-    }
-
-    if (hkey)
-    {
-        if (RegOpenKeyW( hkey, joystick_key, &temp )) temp = 0;
-        RegCloseKey(hkey);
-        hkey = temp;
-    }
-
-    /* Look for the "controllername"="disabled" key */
-    if (!get_config_key( hkey, appkey, instance->tszInstanceName, buffer, sizeof(buffer) ))
-    {
-        if (!strcmpW( disabled_str, buffer ))
-        {
-            TRACE( "Disabling joystick '%s' based on registry key.\n", debugstr_w(instance->tszInstanceName) );
-            disable = TRUE;
-        }
-        else if (override && !strcmpW( override_str, buffer ))
-        {
-            TRACE( "Force enabling joystick '%s' based on registry key.\n", debugstr_w(instance->tszInstanceName) );
-            *override = TRUE;
-        }
-    }
-
-    if (appkey) RegCloseKey(appkey);
-    if (hkey)   RegCloseKey(hkey);
-
-    return disable;
-}
-
 BOOL is_xinput_device(const DIDEVCAPS *devcaps, WORD vid, WORD pid)
 {
     int i;




More information about the wine-cvs mailing list