Aric Stewart : winebus.sys: Implement removing IOHID devices.

Alexandre Julliard julliard at winehq.org
Tue Nov 8 13:39:35 CST 2016


Module: wine
Branch: master
Commit: 3b132cb9ec91b903ba3da19b019fc8b8e94b4554
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=3b132cb9ec91b903ba3da19b019fc8b8e94b4554

Author: Aric Stewart <aric at codeweavers.com>
Date:   Mon Nov  7 13:42:27 2016 -0600

winebus.sys: Implement removing IOHID devices.

Signed-off-by: Aric Stewart <aric at codeweavers.com>
Signed-off-by: Ken Thomases <ken at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/winebus.sys/bus_iohid.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c
index 866241e..76db0a2 100644
--- a/dlls/winebus.sys/bus_iohid.c
+++ b/dlls/winebus.sys/bus_iohid.c
@@ -130,7 +130,12 @@ static DWORD CFNumberToDWORD(CFNumberRef num)
 
 static int compare_platform_device(DEVICE_OBJECT *device, void *platform_dev)
 {
-    return 0;
+    struct platform_private *private = impl_from_DEVICE_OBJECT(device);
+    IOHIDDeviceRef dev2 = (IOHIDDeviceRef)platform_dev;
+    if (private->device != dev2)
+        return 1;
+    else
+        return 0;
 }
 
 static NTSTATUS get_reportdescriptor(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length)
@@ -207,6 +212,18 @@ static void handle_DeviceMatchingCallback(void *context, IOReturn result, void *
     }
 }
 
+static void handle_RemovalCallback(void *context, IOReturn result, void *sender, IOHIDDeviceRef IOHIDDevice)
+{
+    DEVICE_OBJECT *device;
+    TRACE("OS/X IOHID Device Removed %p\n", IOHIDDevice);
+    device = bus_find_hid_device(&iohid_vtbl, IOHIDDevice);
+    if (device)
+    {
+        IoInvalidateDeviceRelations(device, RemovalRelations);
+        bus_remove_hid_device(device);
+    }
+}
+
 /* This puts the relevant run loop for event handling into a WINE thread */
 static DWORD CALLBACK runloop_thread(void *args)
 {
@@ -214,6 +231,7 @@ static DWORD CALLBACK runloop_thread(void *args)
 
     IOHIDManagerSetDeviceMatching(hid_manager, NULL);
     IOHIDManagerRegisterDeviceMatchingCallback(hid_manager, handle_DeviceMatchingCallback, NULL);
+    IOHIDManagerRegisterDeviceRemovalCallback(hid_manager, handle_RemovalCallback, NULL);
     IOHIDManagerScheduleWithRunLoop(hid_manager, run_loop, kCFRunLoopDefaultMode);
     if (IOHIDManagerOpen( hid_manager, 0 ) != kIOReturnSuccess)
     {
@@ -227,6 +245,7 @@ static DWORD CALLBACK runloop_thread(void *args)
     TRACE("Run Loop exiting\n");
 
     IOHIDManagerRegisterDeviceMatchingCallback(hid_manager, NULL, NULL);
+    IOHIDManagerRegisterDeviceRemovalCallback(hid_manager, NULL, NULL);
     IOHIDManagerUnscheduleFromRunLoop(hid_manager, run_loop, kCFRunLoopDefaultMode);
     CFRelease(hid_manager);
     return 1;




More information about the wine-cvs mailing list