From 4e6638bcc3602852c6f499e55ef8e8dc57b2c3f1 Mon Sep 17 00:00:00 2001 From: Johannes Anderwald Date: Thu, 29 Dec 2011 10:07:00 +0000 Subject: [PATCH] [USB-BRINGUP] - Usage page of zero is not used, increment, the MouHid_ButtonUpFlags / MouHid_ButtonDownFlags array - Mouse clicks now work - Implement flushing of the hid report queue - Driver now works in VBox 4.1.4 + WinXP - Secondary mouse pointer does not move in VBox (either a Vbox bug / WinXP), tested with ms driver and the same results were reveiled svn path=/branches/usb-bringup/; revision=54776 --- drivers/hid/mouhid/mouhid.c | 43 +++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/drivers/hid/mouhid/mouhid.c b/drivers/hid/mouhid/mouhid.c index 4087b4be53b..037ed37c1dc 100644 --- a/drivers/hid/mouhid/mouhid.c +++ b/drivers/hid/mouhid/mouhid.c @@ -12,6 +12,7 @@ static USHORT MouHid_ButtonUpFlags[] = { + 0xFF, /* unused */ MOUSE_LEFT_BUTTON_DOWN, MOUSE_RIGHT_BUTTON_DOWN, MOUSE_MIDDLE_BUTTON_DOWN, @@ -21,6 +22,7 @@ static USHORT MouHid_ButtonUpFlags[] = static USHORT MouHid_ButtonDownFlags[] = { + 0xFF, /* unused */ MOUSE_LEFT_BUTTON_UP, MOUSE_RIGHT_BUTTON_UP, MOUSE_MIDDLE_BUTTON_UP, @@ -400,7 +402,7 @@ MouHid_Close( NTSTATUS NTAPI -MouHid_DeviceControl( +MouHid_InternalDeviceControl( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { @@ -412,7 +414,7 @@ MouHid_DeviceControl( /* get current stack location */ IoStack = IoGetCurrentIrpStackLocation(Irp); - DPRINT1("[MOUHID] DeviceControl %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode); + DPRINT1("[MOUHID] InternalDeviceControl %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode); /* get device extension */ DeviceExtension = (PMOUHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension; @@ -424,6 +426,7 @@ MouHid_DeviceControl( if (IoStack->Parameters.DeviceIoControl.OutputBufferLength < sizeof(MOUSE_ATTRIBUTES)) { /* invalid request */ + DPRINT1("[MOUHID] IOCTL_MOUSE_QUERY_ATTRIBUTES Buffer too small\n"); Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL; IoCompleteRequest(Irp, IO_NO_INCREMENT); return STATUS_BUFFER_TOO_SMALL; @@ -444,6 +447,11 @@ MouHid_DeviceControl( /* queue length */ Attributes->InputDataQueueLength = 2; + DPRINT1("[MOUHID] MouseIdentifier %x\n", Attributes->MouseIdentifier); + DPRINT1("[MOUHID] NumberOfButtons %x\n", Attributes->NumberOfButtons); + DPRINT1("[MOUHID] SampleRate %x\n", Attributes->SampleRate); + DPRINT1("[MOUHID] InputDataQueueLength %x\n", Attributes->InputDataQueueLength); + /* complete request */ Irp->IoStatus.Information = sizeof(MOUSE_ATTRIBUTES); Irp->IoStatus.Status = STATUS_SUCCESS; @@ -504,6 +512,7 @@ MouHid_DeviceControl( return STATUS_INVALID_DEVICE_REQUEST; } + DPRINT1("[MOUHID] Unknown DeviceControl %x\n", IoStack->Parameters.DeviceIoControl.IoControlCode); /* unknown request not supported */ Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; IoCompleteRequest(Irp, IO_NO_INCREMENT); @@ -512,7 +521,7 @@ MouHid_DeviceControl( NTSTATUS NTAPI -MouHid_InternalDeviceControl( +MouHid_DeviceControl( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { @@ -535,7 +544,6 @@ MouHid_Power( IN PIRP Irp) { UNIMPLEMENTED - ASSERT(FALSE); return STATUS_NOT_IMPLEMENTED; } @@ -736,6 +744,32 @@ MouHid_StartDeviceCompletion( return STATUS_MORE_PROCESSING_REQUIRED; } +NTSTATUS +NTAPI +MouHid_Flush( + IN PDEVICE_OBJECT DeviceObject, + IN PIRP Irp) +{ + PIO_STACK_LOCATION IoStack; + PMOUHID_DEVICE_EXTENSION DeviceExtension; + + /* get device extension */ + DeviceExtension = (PMOUHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension; + + /* skip current stack location */ + IoSkipCurrentIrpStackLocation(Irp); + + /* get next stack location */ + IoStack = IoGetNextIrpStackLocation(Irp); + + /* change request to hid flush queue request */ + IoStack->MajorFunction = IRP_MJ_DEVICE_CONTROL; + IoStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_HID_FLUSH_QUEUE; + + /* call device */ + return IoCallDriver(DeviceExtension->NextDeviceObject, Irp); +} + NTSTATUS NTAPI MouHid_Pnp( @@ -915,6 +949,7 @@ DriverEntry( DriverObject->DriverExtension->AddDevice = MouHid_AddDevice; DriverObject->MajorFunction[IRP_MJ_CREATE] = MouHid_Create; DriverObject->MajorFunction[IRP_MJ_CLOSE] = MouHid_Close; + DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = MouHid_Flush; DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = MouHid_DeviceControl; DriverObject->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = MouHid_InternalDeviceControl; DriverObject->MajorFunction[IRP_MJ_POWER] = MouHid_Power;