hidclass.sys: Only drop input reports when length is too short.

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>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2021-12-02 10:47:44 +01:00 committed by Alexandre Julliard
parent b431dceeca
commit c2f473d6c4
1 changed files with 11 additions and 7 deletions

View File

@ -322,7 +322,6 @@ static DWORD CALLBACK hid_device_thread(void *args)
packet = malloc( sizeof(*packet) + desc->InputLength ); packet = malloc( sizeof(*packet) + desc->InputLength );
buffer = (BYTE *)(packet + 1); buffer = (BYTE *)(packet + 1);
packet->reportBuffer = buffer;
report = find_report_with_type_and_id( ext, HidP_Input, 0, TRUE ); report = find_report_with_type_and_id( ext, HidP_Input, 0, TRUE );
if (!report) WARN("no input report found.\n"); if (!report) WARN("no input report found.\n");
@ -331,6 +330,7 @@ static DWORD CALLBACK hid_device_thread(void *args)
do do
{ {
packet->reportId = buffer[0] = report_id; packet->reportId = buffer[0] = report_id;
packet->reportBuffer = buffer;
packet->reportBufferLen = desc->InputLength; packet->reportBufferLen = desc->InputLength;
if (!report_id) if (!report_id)
@ -345,13 +345,17 @@ static DWORD CALLBACK hid_device_thread(void *args)
if (io.Status == STATUS_SUCCESS) if (io.Status == STATUS_SUCCESS)
{ {
if (!report_id) io.Information++; if (!report_id) io.Information++;
packet->reportId = buffer[0]; if (!(report = find_report_with_type_and_id( ext, HidP_Input, buffer[0], FALSE )))
packet->reportBuffer = buffer; WARN( "dropping unknown input id %u\n", buffer[0] );
packet->reportBufferLen = io.Information; else if (!polled && io.Information < report->InputLength)
WARN( "dropping short report, len %u expected %u\n", (ULONG)io.Information, report->InputLength );
report = find_report_with_type_and_id( ext, HidP_Input, buffer[0], FALSE ); else
if (polled || (report && report->InputLength == io.Information)) {
packet->reportId = buffer[0];
packet->reportBuffer = buffer;
packet->reportBufferLen = io.Information;
hid_device_queue_input( device, packet ); hid_device_queue_input( device, packet );
}
} }
res = WaitForSingleObject(ext->u.pdo.halt_event, polled ? ext->u.pdo.poll_interval : 0); res = WaitForSingleObject(ext->u.pdo.halt_event, polled ? ext->u.pdo.poll_interval : 0);