Aric Stewart : winebus.sys: Reports for iohid.

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


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

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

winebus.sys: Reports for iohid.

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 | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c
index 954b021..e728b34 100644
--- a/dlls/winebus.sys/bus_iohid.c
+++ b/dlls/winebus.sys/bus_iohid.c
@@ -107,6 +107,7 @@ DEFINE_GUID(GUID_DEVCLASS_IOHID, 0x989D309D,0x0470,0x4E1A,0x89,0x38,0x50,0x1F,0x
 struct platform_private
 {
     IOHIDDeviceRef device;
+    uint8_t *buffer;
 };
 
 static inline struct platform_private *impl_from_DEVICE_OBJECT(DEVICE_OBJECT *device)
@@ -129,6 +130,14 @@ static DWORD CFNumberToDWORD(CFNumberRef num)
     return dwNum;
 }
 
+static void handle_IOHIDDeviceIOHIDReportCallback(void *context,
+        IOReturn result, void *sender, IOHIDReportType type,
+        uint32_t reportID, uint8_t *report, CFIndex report_length)
+{
+    DEVICE_OBJECT *device = (DEVICE_OBJECT*)context;
+    process_hid_report(device, report, report_length);
+}
+
 static int compare_platform_device(DEVICE_OBJECT *device, void *platform_dev)
 {
     struct platform_private *private = impl_from_DEVICE_OBJECT(device);
@@ -192,7 +201,19 @@ static NTSTATUS get_string(DEVICE_OBJECT *device, DWORD index, WCHAR *buffer, DW
 
 static NTSTATUS begin_report_processing(DEVICE_OBJECT *device)
 {
-    return STATUS_NOT_IMPLEMENTED;
+    DWORD length;
+    struct platform_private *private = impl_from_DEVICE_OBJECT(device);
+    CFNumberRef num;
+
+    if (private->buffer)
+        return STATUS_SUCCESS;
+
+    num = IOHIDDeviceGetProperty(private->device, CFSTR(kIOHIDMaxInputReportSizeKey));
+    length = CFNumberToDWORD(num);
+    private->buffer = HeapAlloc(GetProcessHeap(), 0, length);
+
+    IOHIDDeviceRegisterInputReportCallback(private->device, private->buffer, length, handle_IOHIDDeviceIOHIDReportCallback, device);
+    return STATUS_SUCCESS;
 }
 
 static NTSTATUS set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written)
@@ -250,6 +271,7 @@ static void handle_DeviceMatchingCallback(void *context, IOReturn result, void *
     {
         struct platform_private *private = impl_from_DEVICE_OBJECT(device);
         private->device = IOHIDDevice;
+        private->buffer = NULL;
         IoInvalidateDeviceRelations(device, BusRelations);
     }
 }
@@ -258,6 +280,9 @@ static void handle_RemovalCallback(void *context, IOReturn result, void *sender,
 {
     DEVICE_OBJECT *device;
     TRACE("OS/X IOHID Device Removed %p\n", IOHIDDevice);
+    IOHIDDeviceRegisterInputReportCallback(IOHIDDevice, NULL, 0, NULL, NULL);
+    /* Note: Yes, we leak the buffer. But according to research there is no
+             safe way to deallocate that buffer. */
     device = bus_find_hid_device(&iohid_vtbl, IOHIDDevice);
     if (device)
     {




More information about the wine-cvs mailing list