Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
Maybe we could merge hid with plugplay too, but it may end up being a bit too much verbose, I'm not completely sure yet.
dlls/winebus.sys/bus_sdl.c | 4 +--- dlls/winebus.sys/bus_udev.c | 22 ++++++++++------------ dlls/winebus.sys/main.c | 7 +++---- 3 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/dlls/winebus.sys/bus_sdl.c b/dlls/winebus.sys/bus_sdl.c index fe3a960649c..d172d5382fd 100644 --- a/dlls/winebus.sys/bus_sdl.c +++ b/dlls/winebus.sys/bus_sdl.c @@ -59,8 +59,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(plugplay);
#ifdef SONAME_LIBSDL2
-WINE_DECLARE_DEBUG_CHANNEL(hid_report); - static pthread_mutex_t sdl_cs = PTHREAD_MUTEX_INITIALIZER; static struct sdl_bus_options options;
@@ -847,7 +845,7 @@ static void process_device_event(SDL_Event *event) struct sdl_device *impl; SDL_JoystickID id;
- TRACE_(hid_report)("Received action %x\n", event->type); + TRACE("Received action %x\n", event->type);
pthread_mutex_lock(&sdl_cs);
diff --git a/dlls/winebus.sys/bus_udev.c b/dlls/winebus.sys/bus_udev.c index 4c00fe6ad39..780af549916 100644 --- a/dlls/winebus.sys/bus_udev.c +++ b/dlls/winebus.sys/bus_udev.c @@ -101,8 +101,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(plugplay);
#ifdef HAVE_UDEV
-WINE_DECLARE_DEBUG_CHANNEL(hid_report); - static pthread_mutex_t udev_cs = PTHREAD_MUTEX_INITIALIZER;
static struct udev *udev_context = NULL; @@ -344,9 +342,9 @@ static void hidraw_device_read_report(struct unix_device *iface)
int size = read(impl->base.device_fd, report_buffer, sizeof(report_buffer)); if (size == -1) - TRACE_(hid_report)("Read failed. Likely an unplugged device %d %s\n", errno, strerror(errno)); + TRACE("Read failed. Likely an unplugged device %d %s\n", errno, strerror(errno)); else if (size == 0) - TRACE_(hid_report)("Failed to read report\n"); + TRACE("Failed to read report\n"); else { /* As described in the Linux kernel driver, when connected over bluetooth, DS4 controllers @@ -380,7 +378,7 @@ static void hidraw_device_set_output_report(struct unix_device *iface, HID_XFER_ if ((buffer[0] = packet->reportId)) count = write(impl->base.device_fd, packet->reportBuffer, length); else if (length > sizeof(buffer) - 1) - ERR_(hid_report)("id %d length %u >= 8192, cannot write\n", packet->reportId, length); + ERR("id %d length %u >= 8192, cannot write\n", packet->reportId, length); else { memcpy(buffer + 1, packet->reportBuffer, length); @@ -394,7 +392,7 @@ static void hidraw_device_set_output_report(struct unix_device *iface, HID_XFER_ } else { - ERR_(hid_report)("id %d write failed error: %d %s\n", packet->reportId, errno, strerror(errno)); + ERR("id %d write failed error: %d %s\n", packet->reportId, errno, strerror(errno)); io->Information = 0; io->Status = STATUS_UNSUCCESSFUL; } @@ -412,7 +410,7 @@ static void hidraw_device_get_feature_report(struct unix_device *iface, HID_XFER if ((buffer[0] = packet->reportId) && length <= 0x1fff) count = ioctl(impl->base.device_fd, HIDIOCGFEATURE(length), packet->reportBuffer); else if (length > sizeof(buffer) - 1) - ERR_(hid_report)("id %d length %u >= 8192, cannot read\n", packet->reportId, length); + ERR("id %d length %u >= 8192, cannot read\n", packet->reportId, length); else { count = ioctl(impl->base.device_fd, HIDIOCGFEATURE(length + 1), buffer); @@ -426,7 +424,7 @@ static void hidraw_device_get_feature_report(struct unix_device *iface, HID_XFER } else { - ERR_(hid_report)("id %d read failed, error: %d %s\n", packet->reportId, errno, strerror(errno)); + ERR("id %d read failed, error: %d %s\n", packet->reportId, errno, strerror(errno)); io->Information = 0; io->Status = STATUS_UNSUCCESSFUL; } @@ -448,7 +446,7 @@ static void hidraw_device_set_feature_report(struct unix_device *iface, HID_XFER if ((buffer[0] = packet->reportId) && length <= 0x1fff) count = ioctl(impl->base.device_fd, HIDIOCSFEATURE(length), packet->reportBuffer); else if (length > sizeof(buffer) - 1) - ERR_(hid_report)("id %d length %u >= 8192, cannot write\n", packet->reportId, length); + ERR("id %d length %u >= 8192, cannot write\n", packet->reportId, length); else { memcpy(buffer + 1, packet->reportBuffer, length); @@ -462,7 +460,7 @@ static void hidraw_device_set_feature_report(struct unix_device *iface, HID_XFER } else { - ERR_(hid_report)("id %d write failed, error: %d %s\n", packet->reportId, errno, strerror(errno)); + ERR("id %d write failed, error: %d %s\n", packet->reportId, errno, strerror(errno)); io->Information = 0; io->Status = STATUS_UNSUCCESSFUL; } @@ -802,9 +800,9 @@ static void lnxev_device_read_report(struct unix_device *iface)
size = read(impl->base.device_fd, &ie, sizeof(ie)); if (size == -1) - TRACE_(hid_report)("Read failed. Likely an unplugged device\n"); + TRACE("Read failed. Likely an unplugged device\n"); else if (size == 0) - TRACE_(hid_report)("Failed to read report\n"); + TRACE("Failed to read report\n"); else if (set_report_from_event(iface, &ie)) bus_event_queue_input_report(&event_queue, iface, state->report_buf, state->report_len); } diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 433963b44d4..1353df7d000 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -41,7 +41,6 @@ #include "unixlib.h"
WINE_DEFAULT_DEBUG_CHANNEL(plugplay); -WINE_DECLARE_DEBUG_CHANNEL(hid_report);
static DRIVER_OBJECT *driver_obj;
@@ -1045,21 +1044,21 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) case IOCTL_HID_WRITE_REPORT: { HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer); - TRACE_(hid_report)("IOCTL_HID_WRITE_REPORT / IOCTL_HID_SET_OUTPUT_REPORT\n"); + TRACE("IOCTL_HID_WRITE_REPORT / IOCTL_HID_SET_OUTPUT_REPORT\n"); unix_device_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"); + TRACE("IOCTL_HID_GET_FEATURE\n"); unix_device_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"); + TRACE("IOCTL_HID_SET_FEATURE\n"); unix_device_set_feature_report(device, packet, &irp->IoStatus); break; }
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winebus.sys/main.c | 75 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 66 insertions(+), 9 deletions(-)
diff --git a/dlls/winebus.sys/main.c b/dlls/winebus.sys/main.c index 1353df7d000..0e7889386dc 100644 --- a/dlls/winebus.sys/main.c +++ b/dlls/winebus.sys/main.c @@ -401,6 +401,7 @@ static BOOL deliver_next_report(struct device_extension *ext, IRP *irp) { struct hid_report *report; struct list *entry; + ULONG i;
if (!(entry = list_head(&ext->reports))) return FALSE; report = LIST_ENTRY(entry, struct hid_report, entry); @@ -410,6 +411,19 @@ static BOOL deliver_next_report(struct device_extension *ext, IRP *irp) irp->IoStatus.Information = report->length; irp->IoStatus.Status = STATUS_SUCCESS;
+ if (TRACE_ON(plugplay)) + { + TRACE("read input report length %u:\n", report->length); + for (i = 0; i < report->length;) + { + char buffer[256], *buf = buffer; + buf += sprintf(buf, "%08x ", i); + do { buf += sprintf(buf, " %02x", report->buffer[i]); } + while (++i % 16 && i < report->length); + TRACE("%s\n", buffer); + } + } + RtlFreeHeap(GetProcessHeap(), 0, report); return TRUE; } @@ -937,11 +951,9 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) { IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp); struct device_extension *ext = (struct device_extension *)device->DeviceExtension; - ULONG code, buffer_len = irpsp->Parameters.DeviceIoControl.OutputBufferLength; + ULONG i, code, buffer_len = irpsp->Parameters.DeviceIoControl.OutputBufferLength; NTSTATUS status;
- TRACE("(%p, %p)\n", device, irp); - if (device == bus_fdo) { IoSkipCurrentIrpStackLocation(irp); @@ -1026,6 +1038,18 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) memcpy(packet->reportBuffer, ext->last_reports[packet->reportId], packet->reportBufferLen); irp->IoStatus.Information = packet->reportBufferLen; irp->IoStatus.Status = STATUS_SUCCESS; + if (TRACE_ON(plugplay)) + { + TRACE("read input report id %u length %u:\n", packet->reportId, packet->reportBufferLen); + for (i = 0; i < packet->reportBufferLen;) + { + char buffer[256], *buf = buffer; + buf += sprintf(buf, "%08x ", i); + do { buf += sprintf(buf, " %02x", packet->reportBuffer[i]); } + while (++i % 16 && i < packet->reportBufferLen); + TRACE("%s\n", buffer); + } + } break; } case IOCTL_HID_READ_REPORT: @@ -1043,22 +1067,55 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp) case IOCTL_HID_SET_OUTPUT_REPORT: case IOCTL_HID_WRITE_REPORT: { - HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer); - TRACE("IOCTL_HID_WRITE_REPORT / IOCTL_HID_SET_OUTPUT_REPORT\n"); + HID_XFER_PACKET *packet = (HID_XFER_PACKET *)irp->UserBuffer; + if (TRACE_ON(plugplay)) + { + TRACE("write output report id %u length %u:\n", packet->reportId, packet->reportBufferLen); + for (i = 0; i < packet->reportBufferLen;) + { + char buffer[256], *buf = buffer; + buf += sprintf(buf, "%08x ", i); + do { buf += sprintf(buf, " %02x", packet->reportBuffer[i]); } + while (++i % 16 && i < packet->reportBufferLen); + TRACE("%s\n", buffer); + } + } unix_device_set_output_report(device, packet, &irp->IoStatus); break; } case IOCTL_HID_GET_FEATURE: { - HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer); - TRACE("IOCTL_HID_GET_FEATURE\n"); + HID_XFER_PACKET *packet = (HID_XFER_PACKET *)irp->UserBuffer; unix_device_get_feature_report(device, packet, &irp->IoStatus); + if (!irp->IoStatus.Status && TRACE_ON(plugplay)) + { + TRACE("read feature report id %u length %u:\n", packet->reportId, packet->reportBufferLen); + for (i = 0; i < packet->reportBufferLen;) + { + char buffer[256], *buf = buffer; + buf += sprintf(buf, "%08x ", i); + do { buf += sprintf(buf, " %02x", packet->reportBuffer[i]); } + while (++i % 16 && i < packet->reportBufferLen); + TRACE("%s\n", buffer); + } + } break; } case IOCTL_HID_SET_FEATURE: { - HID_XFER_PACKET *packet = (HID_XFER_PACKET*)(irp->UserBuffer); - TRACE("IOCTL_HID_SET_FEATURE\n"); + HID_XFER_PACKET *packet = (HID_XFER_PACKET *)irp->UserBuffer; + if (TRACE_ON(plugplay)) + { + TRACE("write feature report id %u length %u:\n", packet->reportId, packet->reportBufferLen); + for (i = 0; i < packet->reportBufferLen;) + { + char buffer[256], *buf = buffer; + buf += sprintf(buf, "%08x ", i); + do { buf += sprintf(buf, " %02x", packet->reportBuffer[i]); } + while (++i % 16 && i < packet->reportBufferLen); + TRACE("%s\n", buffer); + } + } unix_device_set_feature_report(device, packet, &irp->IoStatus); break; }
On 10/27/21 03:39, Rémi Bernon wrote:
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
Maybe we could merge hid with plugplay too, but it may end up being a bit too much verbose, I'm not completely sure yet.
Personally I'd rather see "plugplay" stop being used by specific drivers.
On 10/27/21 4:30 PM, Zebediah Figura (she/her) wrote:
On 10/27/21 03:39, Rémi Bernon wrote:
Signed-off-by: Rémi Bernon rbernon@codeweavers.com
Maybe we could merge hid with plugplay too, but it may end up being a bit too much verbose, I'm not completely sure yet.
Personally I'd rather see "plugplay" stop being used by specific drivers.
Yeah basically what I meant, I wasn't really thinking about the other plugplay logger.
So either a +winebus for the winebus driver, and +hid for the rest of the HID stack, or +hid for both.