Zebediah Figura : user32: Factor out raw input device enumeration.

Alexandre Julliard julliard at winehq.org
Thu Jun 2 16:26:08 CDT 2022


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

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Sun May 15 12:10:02 2022 -0500

user32: Factor out raw input device enumeration.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>

---

 dlls/user32/rawinput.c | 49 +++++++++++++++++--------------------------------
 1 file changed, 17 insertions(+), 32 deletions(-)

diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c
index 5f5c898be0e..90ca074f2a4 100644
--- a/dlls/user32/rawinput.c
+++ b/dlls/user32/rawinput.c
@@ -232,13 +232,24 @@ fail:
     return NULL;
 }
 
-void rawinput_update_device_list(void)
+static void enumerate_devices( DWORD type, const GUID *guid )
 {
-    SP_DEVICE_INTERFACE_DATA iface = { sizeof(iface) };
-    struct device *device;
+    SP_DEVICE_INTERFACE_DATA iface = {sizeof(iface)};
     HDEVINFO set;
     DWORD idx;
 
+    set = SetupDiGetClassDevsW( guid, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT );
+
+    for (idx = 0; SetupDiEnumDeviceInterfaces( set, NULL, &GUID_DEVINTERFACE_HID, idx, &iface); ++idx )
+        add_device( set, &iface, type );
+
+    SetupDiDestroyDeviceInfoList( set );
+}
+
+void rawinput_update_device_list(void)
+{
+    DWORD idx;
+
     TRACE("\n");
 
     EnterCriticalSection(&rawinput_devices_cs);
@@ -252,35 +263,9 @@ void rawinput_update_device_list(void)
     }
     rawinput_devices_count = 0;
 
-    set = SetupDiGetClassDevsW(&GUID_DEVINTERFACE_HID, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
-
-    for (idx = 0; SetupDiEnumDeviceInterfaces(set, NULL, &GUID_DEVINTERFACE_HID, idx, &iface); ++idx)
-    {
-        if (!(device = add_device( set, &iface, RIM_TYPEHID )))
-            continue;
-    }
-
-    SetupDiDestroyDeviceInfoList(set);
-
-    set = SetupDiGetClassDevsW(&GUID_DEVINTERFACE_MOUSE, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
-
-    for (idx = 0; SetupDiEnumDeviceInterfaces(set, NULL, &GUID_DEVINTERFACE_MOUSE, idx, &iface); ++idx)
-    {
-        if (!(device = add_device( set, &iface, RIM_TYPEMOUSE )))
-            continue;
-    }
-
-    SetupDiDestroyDeviceInfoList(set);
-
-    set = SetupDiGetClassDevsW(&GUID_DEVINTERFACE_KEYBOARD, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
-
-    for (idx = 0; SetupDiEnumDeviceInterfaces(set, NULL, &GUID_DEVINTERFACE_KEYBOARD, idx, &iface); ++idx)
-    {
-        if (!(device = add_device( set, &iface, RIM_TYPEHID )))
-            continue;
-    }
-
-    SetupDiDestroyDeviceInfoList(set);
+    enumerate_devices( RIM_TYPEHID, &GUID_DEVINTERFACE_HID );
+    enumerate_devices( RIM_TYPEMOUSE, &GUID_DEVINTERFACE_MOUSE );
+    enumerate_devices( RIM_TYPEKEYBOARD, &GUID_DEVINTERFACE_KEYBOARD );
 
     LeaveCriticalSection(&rawinput_devices_cs);
 }




More information about the wine-cvs mailing list