And add some warnings when we do.
This otherwise makes the effect state reports from the tests to be always dropped as they are shorter than the returned length, which is the read buffer size and the maximum input report length.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hidclass.sys/device.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/dlls/hidclass.sys/device.c b/dlls/hidclass.sys/device.c index fb21e230ec4..dd288a82b67 100644 --- a/dlls/hidclass.sys/device.c +++ b/dlls/hidclass.sys/device.c @@ -322,7 +322,6 @@ static DWORD CALLBACK hid_device_thread(void *args)
packet = malloc( sizeof(*packet) + desc->InputLength ); buffer = (BYTE *)(packet + 1); - packet->reportBuffer = buffer;
report = find_report_with_type_and_id( ext, HidP_Input, 0, TRUE ); if (!report) WARN("no input report found.\n"); @@ -331,6 +330,7 @@ static DWORD CALLBACK hid_device_thread(void *args) do { packet->reportId = buffer[0] = report_id; + packet->reportBuffer = buffer; packet->reportBufferLen = desc->InputLength;
if (!report_id) @@ -345,13 +345,17 @@ static DWORD CALLBACK hid_device_thread(void *args) if (io.Status == STATUS_SUCCESS) { if (!report_id) io.Information++; - packet->reportId = buffer[0]; - packet->reportBuffer = buffer; - packet->reportBufferLen = io.Information; - - report = find_report_with_type_and_id( ext, HidP_Input, buffer[0], FALSE ); - if (polled || (report && report->InputLength == io.Information)) + if (!(report = find_report_with_type_and_id( ext, HidP_Input, buffer[0], FALSE ))) + WARN( "dropping unknown input id %u\n", buffer[0] ); + else if (!polled && io.Information < report->InputLength) + WARN( "dropping short report, len %u expected %u\n", (ULONG)io.Information, report->InputLength ); + else + { + packet->reportId = buffer[0]; + packet->reportBuffer = buffer; + packet->reportBufferLen = io.Information; hid_device_queue_input( device, packet ); + } }
res = WaitForSingleObject(ext->u.pdo.halt_event, polled ? ext->u.pdo.poll_interval : 0);