Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/bus.h | 7 +-- dlls/winebus.sys/bus_iohid.c | 41 +++++++++-------- dlls/winebus.sys/bus_sdl.c | 29 ++++++------ dlls/winebus.sys/bus_udev.c | 89 +++++++++++++++++++----------------- dlls/winebus.sys/main.c | 55 +++++++++++----------- 5 files changed, 114 insertions(+), 107 deletions(-)
diff --git a/dlls/winebus.sys/bus.h b/dlls/winebus.sys/bus.h index 5f763acbf3e..3e53b9c53f1 100644 --- a/dlls/winebus.sys/bus.h +++ b/dlls/winebus.sys/bus.h @@ -22,6 +22,7 @@ #include <winbase.h> #include <winternl.h> #include <ddk/wdm.h> +#include <ddk/hidclass.h> #include <hidusage.h>
typedef int(*enum_func)(DEVICE_OBJECT *device, void *context); @@ -42,9 +43,9 @@ typedef struct NTSTATUS (*start_device)(DEVICE_OBJECT *device); NTSTATUS (*get_reportdescriptor)(DEVICE_OBJECT *device, BYTE *buffer, DWORD length, DWORD *out_length); NTSTATUS (*get_string)(DEVICE_OBJECT *device, DWORD index, WCHAR *buffer, DWORD length); - NTSTATUS (*set_output_report)(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written); - NTSTATUS (*get_feature_report)(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *read); - NTSTATUS (*set_feature_report)(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written); + void (*set_output_report)(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io); + void (*get_feature_report)(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io); + void (*set_feature_report)(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io); } platform_vtbl;
void *get_platform_private(DEVICE_OBJECT *device) DECLSPEC_HIDDEN; diff --git a/dlls/winebus.sys/bus_iohid.c b/dlls/winebus.sys/bus_iohid.c index 394e3228838..4eb0ea0e4b3 100644 --- a/dlls/winebus.sys/bus_iohid.c +++ b/dlls/winebus.sys/bus_iohid.c @@ -213,57 +213,60 @@ static NTSTATUS get_string(DEVICE_OBJECT *device, DWORD index, WCHAR *buffer, DW return STATUS_SUCCESS; }
-static NTSTATUS set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) +static void set_output_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { IOReturn result; struct platform_private *private = impl_from_DEVICE_OBJECT(device); - result = IOHIDDeviceSetReport(private->device, kIOHIDReportTypeOutput, id, report, length); + result = IOHIDDeviceSetReport(private->device, kIOHIDReportTypeOutput, packet->reportId, + packet->reportBuffer, packet->reportBufferLen); if (result == kIOReturnSuccess) { - *written = length; - return STATUS_SUCCESS; + io->Information = packet->reportBufferLen; + io->Status = STATUS_SUCCESS; } else { - *written = 0; - return STATUS_UNSUCCESSFUL; + io->Information = 0; + io->Status = STATUS_UNSUCCESSFUL; } }
-static NTSTATUS get_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *read) +static void get_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { IOReturn ret; - CFIndex report_length = length; + CFIndex report_length = packet->reportBufferLen; struct platform_private *private = impl_from_DEVICE_OBJECT(device);
- ret = IOHIDDeviceGetReport(private->device, kIOHIDReportTypeFeature, id, report, &report_length); + ret = IOHIDDeviceGetReport(private->device, kIOHIDReportTypeFeature, packet->reportId, + packet->reportBuffer, &report_length); if (ret == kIOReturnSuccess) { - *read = report_length; - return STATUS_SUCCESS; + io->Information = report_length; + io->Status = STATUS_SUCCESS; } else { - *read = 0; - return STATUS_UNSUCCESSFUL; + io->Information = 0; + io->Status = STATUS_UNSUCCESSFUL; } }
-static NTSTATUS set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) +static void set_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { IOReturn result; struct platform_private *private = impl_from_DEVICE_OBJECT(device);
- result = IOHIDDeviceSetReport(private->device, kIOHIDReportTypeFeature, id, report, length); + result = IOHIDDeviceSetReport(private->device, kIOHIDReportTypeFeature, packet->reportId, + packet->reportBuffer, packet->reportBufferLen); if (result == kIOReturnSuccess) { - *written = length; - return STATUS_SUCCESS; + io->Information = packet->reportBufferLen; + io->Status = STATUS_SUCCESS; } else { - *written = 0; - return STATUS_UNSUCCESSFUL; + io->Information = 0; + io->Status = STATUS_UNSUCCESSFUL; } }
diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index 4770de02ffe..84e3ef20664 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -536,14 +536,14 @@ static NTSTATUS get_string(DEVICE_OBJECT *device, DWORD index, WCHAR *buffer, DW return STATUS_SUCCESS; }
-static NTSTATUS set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) +static void set_output_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { struct platform_private *ext = impl_from_DEVICE_OBJECT(device);
- if (ext->sdl_haptic && id == 0) + if (ext->sdl_haptic && packet->reportId == 0) { - WORD left = report[2] * 128; - WORD right = report[3] * 128; + WORD left = packet->reportBuffer[2] * 128; + WORD right = packet->reportBuffer[3] * 128;
if (ext->haptic_effect_id >= 0) { @@ -572,26 +572,27 @@ static NTSTATUS set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, pSDL_HapticRumblePlay(ext->sdl_haptic, i, -1); } } - *written = length; - return STATUS_SUCCESS; + + io->Information = packet->reportBufferLen; + io->Status = STATUS_SUCCESS; } else { - *written = 0; - return STATUS_NOT_IMPLEMENTED; + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; } }
-static NTSTATUS get_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *read) +static void get_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - *read = 0; - return STATUS_NOT_IMPLEMENTED; + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
-static NTSTATUS set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) +static void set_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - *written = 0; - return STATUS_NOT_IMPLEMENTED; + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
static const platform_vtbl sdl_vtbl = diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index 977e5f2972a..77a242a6087 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -716,100 +716,103 @@ static DWORD CALLBACK device_report_thread(void *args) return 0; }
-static NTSTATUS hidraw_set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) +static void hidraw_set_output_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { struct platform_private* ext = impl_from_DEVICE_OBJECT(device); + ULONG length = packet->reportBufferLen; BYTE buffer[8192]; int count = 0;
- if ((buffer[0] = id)) - count = write(ext->device_fd, report, length); + if ((buffer[0] = packet->reportId)) + count = write(ext->device_fd, packet->reportBuffer, length); else if (length > sizeof(buffer) - 1) - ERR_(hid_report)("id %d length %u >= 8192, cannot write\n", id, length); + ERR_(hid_report)("id %d length %u >= 8192, cannot write\n", packet->reportId, length); else { - memcpy(buffer + 1, report, length); + memcpy(buffer + 1, packet->reportBuffer, length); count = write(ext->device_fd, buffer, length + 1); }
if (count > 0) { - *written = count; - return STATUS_SUCCESS; + io->Information = count; + io->Status = STATUS_SUCCESS; } else { - ERR_(hid_report)("id %d write failed error: %d %s\n", id, errno, strerror(errno)); - *written = 0; - return STATUS_UNSUCCESSFUL; + ERR_(hid_report)("id %d write failed error: %d %s\n", packet->reportId, errno, strerror(errno)); + io->Information = 0; + io->Status = STATUS_UNSUCCESSFUL; } }
-static NTSTATUS hidraw_get_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *read) +static void hidraw_get_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { #if defined(HAVE_LINUX_HIDRAW_H) && defined(HIDIOCGFEATURE) struct platform_private* ext = impl_from_DEVICE_OBJECT(device); + ULONG length = packet->reportBufferLen; BYTE buffer[8192]; int count = 0;
- if ((buffer[0] = id) && length <= 0x1fff) - count = ioctl(ext->device_fd, HIDIOCGFEATURE(length), report); + if ((buffer[0] = packet->reportId) && length <= 0x1fff) + count = ioctl(ext->device_fd, HIDIOCGFEATURE(length), packet->reportBuffer); else if (length > sizeof(buffer) - 1) - ERR_(hid_report)("id %d length %u >= 8192, cannot read\n", id, length); + ERR_(hid_report)("id %d length %u >= 8192, cannot read\n", packet->reportId, length); else { count = ioctl(ext->device_fd, HIDIOCGFEATURE(length + 1), buffer); - memcpy(report, buffer + 1, length); + memcpy(packet->reportBuffer, buffer + 1, length); }
if (count > 0) { - *read = count; - return STATUS_SUCCESS; + io->Information = count; + io->Status = STATUS_SUCCESS; } else { - ERR_(hid_report)("id %d read failed, error: %d %s\n", id, errno, strerror(errno)); - *read = 0; - return STATUS_UNSUCCESSFUL; + ERR_(hid_report)("id %d read failed, error: %d %s\n", packet->reportId, errno, strerror(errno)); + io->Information = 0; + io->Status = STATUS_UNSUCCESSFUL; } #else - *read = 0; - return STATUS_NOT_IMPLEMENTED; + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; #endif }
-static NTSTATUS hidraw_set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) +static void hidraw_set_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { #if defined(HAVE_LINUX_HIDRAW_H) && defined(HIDIOCSFEATURE) struct platform_private* ext = impl_from_DEVICE_OBJECT(device); + ULONG length = packet->reportBufferLen; BYTE buffer[8192]; int count = 0;
- if ((buffer[0] = id) && length <= 0x1fff) - count = ioctl(ext->device_fd, HIDIOCSFEATURE(length), report); + if ((buffer[0] = packet->reportId) && length <= 0x1fff) + count = ioctl(ext->device_fd, HIDIOCSFEATURE(length), packet->reportBuffer); else if (length > sizeof(buffer) - 1) - ERR_(hid_report)("id %d length %u >= 8192, cannot write\n", id, length); + ERR_(hid_report)("id %d length %u >= 8192, cannot write\n", packet->reportId, length); else { - memcpy(buffer + 1, report, length); + memcpy(buffer + 1, packet->reportBuffer, length); count = ioctl(ext->device_fd, HIDIOCSFEATURE(length + 1), buffer); }
if (count > 0) { - *written = count; - return STATUS_SUCCESS; + io->Information = count; + io->Status = STATUS_SUCCESS; } else { - ERR_(hid_report)("id %d write failed, error: %d %s\n", id, errno, strerror(errno)); - *written = 0; - return STATUS_UNSUCCESSFUL; + ERR_(hid_report)("id %d write failed, error: %d %s\n", packet->reportId, errno, strerror(errno)); + io->Information = 0; + io->Status = STATUS_UNSUCCESSFUL; } #else - *written = 0; - return STATUS_NOT_IMPLEMENTED; + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; #endif }
@@ -949,22 +952,22 @@ static DWORD CALLBACK lnxev_device_report_thread(void *args) return 0; }
-static NTSTATUS lnxev_set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) +static void lnxev_set_output_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - *written = 0; - return STATUS_NOT_IMPLEMENTED; + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
-static NTSTATUS lnxev_get_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *read) +static void lnxev_get_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - *read = 0; - return STATUS_NOT_IMPLEMENTED; + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
-static NTSTATUS lnxev_set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *written) +static void lnxev_set_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - *written = 0; - return STATUS_NOT_IMPLEMENTED; + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
static const platform_vtbl lnxev_vtbl = { diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index c5408f29beb..cd8573cf1d0 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -504,22 +504,25 @@ static NTSTATUS mouse_get_string(DEVICE_OBJECT *device, DWORD index, WCHAR *buff return STATUS_SUCCESS; }
-static NTSTATUS mouse_set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *ret_length) +static void mouse_set_output_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - FIXME("id %u, stub!\n", id); - return STATUS_NOT_IMPLEMENTED; + FIXME("id %u, stub!\n", packet->reportId); + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
-static NTSTATUS mouse_get_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *ret_length) +static void mouse_get_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - FIXME("id %u, stub!\n", id); - return STATUS_NOT_IMPLEMENTED; + FIXME("id %u, stub!\n", packet->reportId); + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
-static NTSTATUS mouse_set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *ret_length) +static void mouse_set_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - FIXME("id %u, stub!\n", id); - return STATUS_NOT_IMPLEMENTED; + FIXME("id %u, stub!\n", packet->reportId); + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
static const platform_vtbl mouse_vtbl = @@ -578,22 +581,25 @@ static NTSTATUS keyboard_get_string(DEVICE_OBJECT *device, DWORD index, WCHAR *b return STATUS_SUCCESS; }
-static NTSTATUS keyboard_set_output_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *ret_length) +static void keyboard_set_output_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - FIXME("id %u, stub!\n", id); - return STATUS_NOT_IMPLEMENTED; + FIXME("id %u, stub!\n", packet->reportId); + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
-static NTSTATUS keyboard_get_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *ret_length) +static void keyboard_get_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - FIXME("id %u, stub!\n", id); - return STATUS_NOT_IMPLEMENTED; + FIXME("id %u, stub!\n", packet->reportId); + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
-static NTSTATUS keyboard_set_feature_report(DEVICE_OBJECT *device, UCHAR id, BYTE *report, DWORD length, ULONG_PTR *ret_length) +static void keyboard_set_feature_report(DEVICE_OBJECT *device, HID_XFER_PACKET *packet, IO_STATUS_BLOCK *io) { - FIXME("id %u, stub!\n", id); - return STATUS_NOT_IMPLEMENTED; + FIXME("id %u, stub!\n", packet->reportId); + io->Information = 0; + io->Status = STATUS_NOT_IMPLEMENTED; }
static const platform_vtbl keyboard_vtbl = @@ -940,28 +946,21 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) { HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer); TRACE_(hid_report)("IOCTL_HID_WRITE_REPORT / IOCTL_HID_SET_OUTPUT_REPORT\n"); - irp->IoStatus.Status = ext->vtbl->set_output_report( - device, packet->reportId, packet->reportBuffer, - packet->reportBufferLen, &irp->IoStatus.Information); + ext->vtbl->set_output_report(device, packet, &irp->IoStatus); break; } case IOCTL_HID_GET_FEATURE: { HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer); TRACE_(hid_report)("IOCTL_HID_GET_FEATURE\n"); - irp->IoStatus.Status = ext->vtbl->get_feature_report( - device, packet->reportId, packet->reportBuffer, - packet->reportBufferLen, &irp->IoStatus.Information); - packet->reportBufferLen = irp->IoStatus.Information; + ext->vtbl->get_feature_report(device, packet, &irp->IoStatus); break; } case IOCTL_HID_SET_FEATURE: { HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer); TRACE_(hid_report)("IOCTL_HID_SET_FEATURE\n"); - irp->IoStatus.Status = ext->vtbl->set_feature_report( - device, packet->reportId, packet->reportBuffer, - packet->reportBufferLen, &irp->IoStatus.Information); + ext->vtbl->set_feature_report(device, packet, &irp->IoStatus); break; } default: