hidclass.sys: Pass a KEVENT to IoBuildDeviceIoControlRequest() in hid_device_thread().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f343235c6e
commit
5cc9c5ab51
|
@ -290,13 +290,6 @@ static void HID_Device_processQueue(DEVICE_OBJECT *device)
|
||||||
HeapFree(GetProcessHeap(), 0, packet);
|
HeapFree(GetProcessHeap(), 0, packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS WINAPI read_Completion(DEVICE_OBJECT *deviceObject, IRP *irp, void *context)
|
|
||||||
{
|
|
||||||
HANDLE event = context;
|
|
||||||
SetEvent(event);
|
|
||||||
return STATUS_MORE_PROCESSING_REQUIRED;
|
|
||||||
}
|
|
||||||
|
|
||||||
static DWORD CALLBACK hid_device_thread(void *args)
|
static DWORD CALLBACK hid_device_thread(void *args)
|
||||||
{
|
{
|
||||||
DEVICE_OBJECT *device = (DEVICE_OBJECT*)args;
|
DEVICE_OBJECT *device = (DEVICE_OBJECT*)args;
|
||||||
|
@ -305,11 +298,8 @@ static DWORD CALLBACK hid_device_thread(void *args)
|
||||||
IO_STATUS_BLOCK irp_status;
|
IO_STATUS_BLOCK irp_status;
|
||||||
HID_XFER_PACKET *packet;
|
HID_XFER_PACKET *packet;
|
||||||
DWORD rc;
|
DWORD rc;
|
||||||
HANDLE event;
|
|
||||||
NTSTATUS ntrc;
|
|
||||||
|
|
||||||
BASE_DEVICE_EXTENSION *ext = device->DeviceExtension;
|
BASE_DEVICE_EXTENSION *ext = device->DeviceExtension;
|
||||||
event = CreateEventA(NULL, TRUE, FALSE, NULL);
|
|
||||||
|
|
||||||
packet = HeapAlloc(GetProcessHeap(), 0, sizeof(*packet) + ext->preparseData->caps.InputReportByteLength);
|
packet = HeapAlloc(GetProcessHeap(), 0, sizeof(*packet) + ext->preparseData->caps.InputReportByteLength);
|
||||||
packet->reportBuffer = (BYTE *)packet + sizeof(*packet);
|
packet->reportBuffer = (BYTE *)packet + sizeof(*packet);
|
||||||
|
@ -318,29 +308,25 @@ static DWORD CALLBACK hid_device_thread(void *args)
|
||||||
{
|
{
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
ResetEvent(event);
|
KEVENT event;
|
||||||
|
|
||||||
|
KeInitializeEvent(&event, NotificationEvent, FALSE);
|
||||||
|
|
||||||
packet->reportBufferLen = ext->preparseData->caps.InputReportByteLength;
|
packet->reportBufferLen = ext->preparseData->caps.InputReportByteLength;
|
||||||
packet->reportId = 0;
|
packet->reportId = 0;
|
||||||
|
|
||||||
irp = IoBuildDeviceIoControlRequest(IOCTL_HID_GET_INPUT_REPORT,
|
irp = IoBuildDeviceIoControlRequest(IOCTL_HID_GET_INPUT_REPORT, device,
|
||||||
device, NULL, 0, packet, sizeof(*packet), TRUE, NULL,
|
NULL, 0, packet, sizeof(*packet), TRUE, &event, &irp_status);
|
||||||
&irp_status);
|
|
||||||
|
|
||||||
IoSetCompletionRoutine(irp, read_Completion, event, TRUE, TRUE, TRUE);
|
if (IoCallDriver(device, irp) == STATUS_PENDING)
|
||||||
ntrc = IoCallDriver(device, irp);
|
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
|
||||||
|
|
||||||
if (ntrc == STATUS_PENDING)
|
if (irp_status.u.Status == STATUS_SUCCESS)
|
||||||
WaitForSingleObject(event, INFINITE);
|
|
||||||
|
|
||||||
if (irp->IoStatus.u.Status == STATUS_SUCCESS)
|
|
||||||
{
|
{
|
||||||
RingBuffer_Write(ext->ring_buffer, packet);
|
RingBuffer_Write(ext->ring_buffer, packet);
|
||||||
HID_Device_processQueue(device);
|
HID_Device_processQueue(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
IoCompleteRequest(irp, IO_NO_INCREMENT );
|
|
||||||
|
|
||||||
rc = WaitForSingleObject(ext->halt_event, ext->poll_interval ? ext->poll_interval : DEFAULT_POLL_INTERVAL);
|
rc = WaitForSingleObject(ext->halt_event, ext->poll_interval ? ext->poll_interval : DEFAULT_POLL_INTERVAL);
|
||||||
|
|
||||||
if (rc == WAIT_OBJECT_0)
|
if (rc == WAIT_OBJECT_0)
|
||||||
|
@ -355,28 +341,23 @@ static DWORD CALLBACK hid_device_thread(void *args)
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
ResetEvent(event);
|
KEVENT event;
|
||||||
|
|
||||||
irp = IoBuildDeviceIoControlRequest(IOCTL_HID_READ_REPORT,
|
KeInitializeEvent(&event, NotificationEvent, FALSE);
|
||||||
device, NULL, 0, packet->reportBuffer,
|
|
||||||
ext->preparseData->caps.InputReportByteLength, TRUE, NULL,
|
|
||||||
&irp_status);
|
|
||||||
|
|
||||||
IoSetCompletionRoutine(irp, read_Completion, event, TRUE, TRUE, TRUE);
|
irp = IoBuildDeviceIoControlRequest(IOCTL_HID_READ_REPORT, device, NULL, 0, packet->reportBuffer,
|
||||||
ntrc = IoCallDriver(device, irp);
|
ext->preparseData->caps.InputReportByteLength, TRUE, &event, &irp_status);
|
||||||
|
|
||||||
if (ntrc == STATUS_PENDING)
|
if (IoCallDriver(device, irp) == STATUS_PENDING)
|
||||||
{
|
KeWaitForSingleObject(&event, Executive, KernelMode, FALSE, NULL);
|
||||||
WaitForSingleObject(event, INFINITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
rc = WaitForSingleObject(ext->halt_event, 0);
|
rc = WaitForSingleObject(ext->halt_event, 0);
|
||||||
if (rc == WAIT_OBJECT_0)
|
if (rc == WAIT_OBJECT_0)
|
||||||
exit_now = TRUE;
|
exit_now = TRUE;
|
||||||
|
|
||||||
if (!exit_now && irp->IoStatus.u.Status == STATUS_SUCCESS)
|
if (!exit_now && irp_status.u.Status == STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
packet->reportBufferLen = irp->IoStatus.Information;
|
packet->reportBufferLen = irp_status.Information;
|
||||||
if (ext->preparseData->reports[0].reportID)
|
if (ext->preparseData->reports[0].reportID)
|
||||||
packet->reportId = packet->reportBuffer[0];
|
packet->reportId = packet->reportBuffer[0];
|
||||||
else
|
else
|
||||||
|
@ -385,15 +366,11 @@ static DWORD CALLBACK hid_device_thread(void *args)
|
||||||
HID_Device_processQueue(device);
|
HID_Device_processQueue(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
IoCompleteRequest(irp, IO_NO_INCREMENT );
|
|
||||||
|
|
||||||
if (exit_now)
|
if (exit_now)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseHandle(event);
|
|
||||||
|
|
||||||
TRACE("Device thread exiting\n");
|
TRACE("Device thread exiting\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue