Author: tfaber
Date: Sat May 11 10:23:54 2013
New Revision: 58989
URL:
http://svn.reactos.org/svn/reactos?rev=58989&view=rev
Log:
[KBDHID][MOUHID]
- Use switch instead of nested ifs
- Remove some unnecessary casts
- Fix some spacing issues
Modified:
trunk/reactos/drivers/hid/kbdhid/kbdhid.c
trunk/reactos/drivers/hid/kbdhid/kbdhid.h
trunk/reactos/drivers/hid/mouhid/mouhid.c
trunk/reactos/drivers/hid/mouhid/mouhid.h
Modified: trunk/reactos/drivers/hid/kbdhid/kbdhid.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/hid/kbdhid/kbdhid.…
==============================================================================
--- trunk/reactos/drivers/hid/kbdhid/kbdhid.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/hid/kbdhid/kbdhid.c [iso-8859-1] Sat May 11 10:23:54 2013
@@ -50,7 +50,7 @@
/* get device extension */
DeviceExtension = (PKBDHID_DEVICE_EXTENSION)Context;
- for(Index = 0; Index < Length; Index++)
+ for (Index = 0; Index < Length; Index++)
{
DPRINT("[KBDHID] ScanCode Index %lu ScanCode %x\n", Index,
NewScanCodes[Index] & 0xFF);
@@ -84,7 +84,7 @@
InputData.MakeCode = NewScanCodes[Index] & 0x7F;
/* dispatch scan codes */
- KbdHid_DispatchInputData((PKBDHID_DEVICE_EXTENSION)Context, &InputData);
+ KbdHid_DispatchInputData(Context, &InputData);
}
/* done */
@@ -136,24 +136,46 @@
/* get current usages */
ButtonLength = DeviceExtension->UsageListLength;
- Status = HidP_GetUsagesEx(HidP_Input, HIDP_LINK_COLLECTION_UNSPECIFIED,
DeviceExtension->CurrentUsageList, &ButtonLength,
DeviceExtension->PreparsedData, DeviceExtension->Report,
DeviceExtension->ReportLength);
+ Status = HidP_GetUsagesEx(HidP_Input,
+ HIDP_LINK_COLLECTION_UNSPECIFIED,
+ DeviceExtension->CurrentUsageList,
+ &ButtonLength,
+ DeviceExtension->PreparsedData,
+ DeviceExtension->Report,
+ DeviceExtension->ReportLength);
ASSERT(Status == HIDP_STATUS_SUCCESS);
/* FIXME check if needs mapping */
/* get usage difference */
- Status = HidP_UsageAndPageListDifference(DeviceExtension->PreviousUsageList,
DeviceExtension->CurrentUsageList, DeviceExtension->BreakUsageList,
DeviceExtension->MakeUsageList, DeviceExtension->UsageListLength);
+ Status = HidP_UsageAndPageListDifference(DeviceExtension->PreviousUsageList,
+ DeviceExtension->CurrentUsageList,
+ DeviceExtension->BreakUsageList,
+ DeviceExtension->MakeUsageList,
+ DeviceExtension->UsageListLength);
ASSERT(Status == HIDP_STATUS_SUCCESS);
/* replace previous usage list with current list */
- RtlMoveMemory(DeviceExtension->PreviousUsageList,
DeviceExtension->CurrentUsageList, sizeof(USAGE_AND_PAGE) *
DeviceExtension->UsageListLength);
+ RtlMoveMemory(DeviceExtension->PreviousUsageList,
+ DeviceExtension->CurrentUsageList,
+ sizeof(USAGE_AND_PAGE) * DeviceExtension->UsageListLength);
/* translate break usage list */
- HidP_TranslateUsageAndPagesToI8042ScanCodes(DeviceExtension->BreakUsageList,
DeviceExtension->UsageListLength, HidP_Keyboard_Break,
&DeviceExtension->ModifierState, KbdHid_InsertScanCodes, DeviceExtension);
+ HidP_TranslateUsageAndPagesToI8042ScanCodes(DeviceExtension->BreakUsageList,
+ DeviceExtension->UsageListLength,
+ HidP_Keyboard_Break,
+ &DeviceExtension->ModifierState,
+ KbdHid_InsertScanCodes,
+ DeviceExtension);
ASSERT(Status == HIDP_STATUS_SUCCESS);
/* translate new usage list */
- HidP_TranslateUsageAndPagesToI8042ScanCodes(DeviceExtension->MakeUsageList,
DeviceExtension->UsageListLength, HidP_Keyboard_Make,
&DeviceExtension->ModifierState, KbdHid_InsertScanCodes, DeviceExtension);
+ HidP_TranslateUsageAndPagesToI8042ScanCodes(DeviceExtension->MakeUsageList,
+ DeviceExtension->UsageListLength,
+ HidP_Keyboard_Make,
+ &DeviceExtension->ModifierState,
+ KbdHid_InsertScanCodes,
+ DeviceExtension);
ASSERT(Status == HIDP_STATUS_SUCCESS);
/* re-init read */
@@ -343,166 +365,168 @@
/* get device extension */
DeviceExtension = (PKBDHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
- if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_KEYBOARD_QUERY_ATTRIBUTES)
- {
- /* verify output buffer length */
- 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;
+ switch (IoStack->Parameters.DeviceIoControl.IoControlCode)
+ {
+ case IOCTL_KEYBOARD_QUERY_ATTRIBUTES:
+ /* verify output buffer length */
+ 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;
+ }
+
+ /* get output buffer */
+ Attributes = (PKEYBOARD_ATTRIBUTES)Irp->AssociatedIrp.SystemBuffer;
+
+ /* copy attributes */
+ RtlCopyMemory(Attributes,
+ &DeviceExtension->Attributes,
+ sizeof(KEYBOARD_ATTRIBUTES));
+
+ /* complete request */
+ Irp->IoStatus.Information = sizeof(MOUSE_ATTRIBUTES);
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
+
+ case IOCTL_INTERNAL_KEYBOARD_CONNECT:
+ /* verify input buffer length */
+ if (IoStack->Parameters.DeviceIoControl.InputBufferLength <
sizeof(CONNECT_DATA))
+ {
+ /* invalid request */
+ Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* is it already connected */
+ if (DeviceExtension->ClassService)
+ {
+ /* already connected */
+ Irp->IoStatus.Status = STATUS_SHARING_VIOLATION;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SHARING_VIOLATION;
+ }
+
+ /* get connect data */
+ Data =
(PCONNECT_DATA)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
+
+ /* store connect details */
+ DeviceExtension->ClassDeviceObject = Data->ClassDeviceObject;
+ DeviceExtension->ClassService = Data->ClassService;
+
+ /* completed successfully */
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
+
+ case IOCTL_INTERNAL_KEYBOARD_DISCONNECT:
+ /* not implemented */
+ Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_BUFFER_TOO_SMALL;
- }
-
- /* get output buffer */
- Attributes = (PKEYBOARD_ATTRIBUTES)Irp->AssociatedIrp.SystemBuffer;
-
- /* copy attributes */
- RtlCopyMemory(Attributes, &DeviceExtension->Attributes,
sizeof(KEYBOARD_ATTRIBUTES));
-
- /* complete request */
- Irp->IoStatus.Information = sizeof(MOUSE_ATTRIBUTES);
- Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_SUCCESS;
- }
- else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_INTERNAL_KEYBOARD_CONNECT)
- {
- /* verify input buffer length */
- if (IoStack->Parameters.DeviceIoControl.InputBufferLength <
sizeof(CONNECT_DATA))
- {
- /* invalid request */
- Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_INVALID_PARAMETER;
- }
-
- /* is it already connected */
- if (DeviceExtension->ClassService)
- {
- /* already connected */
- Irp->IoStatus.Status = STATUS_SHARING_VIOLATION;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_SHARING_VIOLATION;
- }
-
- /* get connect data */
- Data = (PCONNECT_DATA)IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
-
- /* store connect details */
- DeviceExtension->ClassDeviceObject = Data->ClassDeviceObject;
- DeviceExtension->ClassService = Data->ClassService;
-
- /* completed successfully */
- Irp->IoStatus.Status = STATUS_SUCCESS;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_SUCCESS;
- }
- else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_INTERNAL_KEYBOARD_DISCONNECT)
- {
- /* not implemented */
- Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_NOT_IMPLEMENTED;
- }
- else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_INTERNAL_KEYBOARD_ENABLE)
- {
- /* not supported */
- Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_NOT_SUPPORTED;
- }
- else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_INTERNAL_KEYBOARD_DISABLE)
- {
- /* not supported */
- Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_NOT_SUPPORTED;
- }
- else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_KEYBOARD_QUERY_INDICATORS)
- {
- if (IoStack->Parameters.DeviceIoControl.OutputBufferLength <
sizeof(KEYBOARD_INDICATOR_PARAMETERS))
- {
- /* invalid parameter */
- Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_INVALID_PARAMETER;
- }
-
- /* copy indicators */
- RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
&DeviceExtension->KeyboardIndicator, sizeof(KEYBOARD_INDICATOR_PARAMETERS));
-
- /* complete request */
- Irp->IoStatus.Status = STATUS_SUCCESS;
- Irp->IoStatus.Information = sizeof(KEYBOARD_INDICATOR_PARAMETERS);
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_NOT_IMPLEMENTED;
- }
- else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_KEYBOARD_QUERY_TYPEMATIC)
- {
- if (IoStack->Parameters.DeviceIoControl.OutputBufferLength <
sizeof(KEYBOARD_TYPEMATIC_PARAMETERS))
- {
- /* invalid parameter */
- Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_INVALID_PARAMETER;
- }
-
- /* copy indicators */
- RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
&DeviceExtension->KeyboardTypematic, sizeof(KEYBOARD_TYPEMATIC_PARAMETERS));
-
- /* done */
- Irp->IoStatus.Status = STATUS_SUCCESS;
- Irp->IoStatus.Information = sizeof(KEYBOARD_TYPEMATIC_PARAMETERS);
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_SUCCESS;
- }
- else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_KEYBOARD_SET_INDICATORS)
- {
- if (IoStack->Parameters.DeviceIoControl.InputBufferLength <
sizeof(KEYBOARD_INDICATOR_PARAMETERS))
- {
- /* invalid parameter */
- Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_INVALID_PARAMETER;
- }
-
- /* copy indicators */
- RtlCopyMemory(&DeviceExtension->KeyboardIndicator,
Irp->AssociatedIrp.SystemBuffer, sizeof(KEYBOARD_INDICATOR_PARAMETERS));
-
- /* done */
- Irp->IoStatus.Status = STATUS_SUCCESS;
- Irp->IoStatus.Information = 0;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_SUCCESS;
- }
- else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_KEYBOARD_SET_TYPEMATIC)
- {
- if (IoStack->Parameters.DeviceIoControl.InputBufferLength <
sizeof(KEYBOARD_TYPEMATIC_PARAMETERS))
- {
- /* invalid parameter */
- Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_INVALID_PARAMETER;
- }
-
- /* copy indicators */
- RtlCopyMemory(&DeviceExtension->KeyboardTypematic,
Irp->AssociatedIrp.SystemBuffer, sizeof(KEYBOARD_TYPEMATIC_PARAMETERS));
-
- /* done */
- Irp->IoStatus.Status = STATUS_SUCCESS;
- Irp->IoStatus.Information = 0;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_SUCCESS;
- }
- else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION)
- {
- /* not implemented */
- DPRINT1("IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION not
implemented\n");
- Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
- return STATUS_NOT_IMPLEMENTED;
+ return STATUS_NOT_IMPLEMENTED;
+
+ case IOCTL_INTERNAL_KEYBOARD_ENABLE:
+ /* not supported */
+ Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_NOT_SUPPORTED;
+
+ case IOCTL_INTERNAL_KEYBOARD_DISABLE:
+ /* not supported */
+ Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_NOT_SUPPORTED;
+
+ case IOCTL_KEYBOARD_QUERY_INDICATORS:
+ if (IoStack->Parameters.DeviceIoControl.OutputBufferLength <
sizeof(KEYBOARD_INDICATOR_PARAMETERS))
+ {
+ /* invalid parameter */
+ Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* copy indicators */
+ RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
+ &DeviceExtension->KeyboardIndicator,
+ sizeof(KEYBOARD_INDICATOR_PARAMETERS));
+
+ /* complete request */
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ Irp->IoStatus.Information = sizeof(KEYBOARD_INDICATOR_PARAMETERS);
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_NOT_IMPLEMENTED;
+
+ case IOCTL_KEYBOARD_QUERY_TYPEMATIC:
+ if (IoStack->Parameters.DeviceIoControl.OutputBufferLength <
sizeof(KEYBOARD_TYPEMATIC_PARAMETERS))
+ {
+ /* invalid parameter */
+ Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* copy indicators */
+ RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
+ &DeviceExtension->KeyboardTypematic,
+ sizeof(KEYBOARD_TYPEMATIC_PARAMETERS));
+
+ /* done */
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ Irp->IoStatus.Information = sizeof(KEYBOARD_TYPEMATIC_PARAMETERS);
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
+
+ case IOCTL_KEYBOARD_SET_INDICATORS:
+ if (IoStack->Parameters.DeviceIoControl.InputBufferLength <
sizeof(KEYBOARD_INDICATOR_PARAMETERS))
+ {
+ /* invalid parameter */
+ Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* copy indicators */
+ RtlCopyMemory(&DeviceExtension->KeyboardIndicator,
+ Irp->AssociatedIrp.SystemBuffer,
+ sizeof(KEYBOARD_INDICATOR_PARAMETERS));
+
+ /* done */
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ Irp->IoStatus.Information = 0;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
+
+ case IOCTL_KEYBOARD_SET_TYPEMATIC:
+ if (IoStack->Parameters.DeviceIoControl.InputBufferLength <
sizeof(KEYBOARD_TYPEMATIC_PARAMETERS))
+ {
+ /* invalid parameter */
+ Irp->IoStatus.Status = STATUS_INVALID_PARAMETER;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ /* copy indicators */
+ RtlCopyMemory(&DeviceExtension->KeyboardTypematic,
+ Irp->AssociatedIrp.SystemBuffer,
+ sizeof(KEYBOARD_TYPEMATIC_PARAMETERS));
+
+ /* done */
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+ Irp->IoStatus.Information = 0;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_SUCCESS;
+
+ case IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION:
+ /* not implemented */
+ DPRINT1("IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION not
implemented\n");
+ Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_NOT_IMPLEMENTED;
}
/* unknown control code */
@@ -563,7 +587,15 @@
KeInitializeEvent(&Event, NotificationEvent, FALSE);
/* build request */
- Irp = IoBuildDeviceIoControlRequest(IoControlCode,
DeviceExtension->NextDeviceObject, InputBuffer, InputBufferSize, OutputBuffer,
OutputBufferSize, FALSE, &Event, &IoStatus);
+ Irp = IoBuildDeviceIoControlRequest(IoControlCode,
+ DeviceExtension->NextDeviceObject,
+ InputBuffer,
+ InputBufferSize,
+ OutputBuffer,
+ OutputBufferSize,
+ FALSE,
+ &Event,
+ &IoStatus);
if (!Irp)
{
/* no memory */
@@ -600,7 +632,12 @@
DeviceExtension = (PKBDHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
/* query collection information */
- Status = KbdHid_SubmitRequest(DeviceObject, IOCTL_HID_GET_COLLECTION_INFORMATION, 0,
NULL, sizeof(HID_COLLECTION_INFORMATION), &Information);
+ Status = KbdHid_SubmitRequest(DeviceObject,
+ IOCTL_HID_GET_COLLECTION_INFORMATION,
+ 0,
+ NULL,
+ sizeof(HID_COLLECTION_INFORMATION),
+ &Information);
if (!NT_SUCCESS(Status))
{
/* failed to query collection information */
@@ -618,7 +655,12 @@
}
/* now obtain the preparsed data */
- Status = KbdHid_SubmitRequest(DeviceObject, IOCTL_HID_GET_COLLECTION_DESCRIPTOR, 0,
NULL, Information.DescriptorSize, PreparsedData);
+ Status = KbdHid_SubmitRequest(DeviceObject,
+ IOCTL_HID_GET_COLLECTION_DESCRIPTOR,
+ 0,
+ NULL,
+ Information.DescriptorSize,
+ PreparsedData);
if (!NT_SUCCESS(Status))
{
/* failed to get preparsed data */
@@ -639,7 +681,7 @@
DPRINT("[KBDHID] Usage %x UsagePage %x InputReportLength %lu\n",
Capabilities.Usage, Capabilities.UsagePage, Capabilities.InputReportByteLength);
- /* init input report*/
+ /* init input report */
DeviceExtension->ReportLength = Capabilities.InputReportByteLength;
ASSERT(DeviceExtension->ReportLength);
DeviceExtension->Report = (PCHAR)ExAllocatePool(NonPagedPool,
DeviceExtension->ReportLength);
@@ -647,7 +689,11 @@
RtlZeroMemory(DeviceExtension->Report, DeviceExtension->ReportLength);
/* build mdl */
- DeviceExtension->ReportMDL = IoAllocateMdl(DeviceExtension->Report,
DeviceExtension->ReportLength, FALSE, FALSE, NULL);
+ DeviceExtension->ReportMDL = IoAllocateMdl(DeviceExtension->Report,
+ DeviceExtension->ReportLength,
+ FALSE,
+ FALSE,
+ NULL);
ASSERT(DeviceExtension->ReportMDL);
/* init mdl */
@@ -752,88 +798,86 @@
IoStack = IoGetCurrentIrpStackLocation(Irp);
DPRINT("[KBDHID] IRP_MJ_PNP Request: %x\n", IoStack->MinorFunction);
- if (IoStack->MinorFunction == IRP_MN_STOP_DEVICE ||
- IoStack->MinorFunction == IRP_MN_CANCEL_REMOVE_DEVICE ||
- IoStack->MinorFunction == IRP_MN_QUERY_STOP_DEVICE ||
- IoStack->MinorFunction == IRP_MN_CANCEL_STOP_DEVICE ||
- IoStack->MinorFunction == IRP_MN_QUERY_REMOVE_DEVICE)
- {
- /* indicate success */
- Irp->IoStatus.Status = STATUS_SUCCESS;
-
- /* skip irp stack location */
- IoSkipCurrentIrpStackLocation(Irp);
-
- /* dispatch to lower device */
- return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
- }
- else if (IoStack->MinorFunction == IRP_MN_REMOVE_DEVICE)
- {
- /* FIXME synchronization */
-
- /* cancel irp */
- IoCancelIrp(DeviceExtension->Irp);
-
- /* indicate success */
- Irp->IoStatus.Status = STATUS_SUCCESS;
-
- /* skip irp stack location */
- IoSkipCurrentIrpStackLocation(Irp);
-
- /* dispatch to lower device */
- Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
-
- IoFreeIrp(DeviceExtension->Irp);
- IoDetachDevice(DeviceExtension->NextDeviceObject);
- IoDeleteDevice(DeviceObject);
- return Status;
- }
- else if (IoStack->MinorFunction == IRP_MN_START_DEVICE)
- {
- /* init event */
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
-
- /* copy stack location */
- IoCopyCurrentIrpStackLocationToNext (Irp);
-
- /* set completion routine */
- IoSetCompletionRoutine(Irp, KbdHid_StartDeviceCompletion, &Event, TRUE, TRUE,
TRUE);
- Irp->IoStatus.Status = 0;
-
- /* pass request */
- Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
- if (Status == STATUS_PENDING)
- {
- KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
- Status = Irp->IoStatus.Status;
- }
-
- if (!NT_SUCCESS(Status))
- {
- /* failed */
+ switch (IoStack->MinorFunction)
+ {
+ case IRP_MN_STOP_DEVICE:
+ case IRP_MN_CANCEL_REMOVE_DEVICE:
+ case IRP_MN_QUERY_STOP_DEVICE:
+ case IRP_MN_CANCEL_STOP_DEVICE:
+ case IRP_MN_QUERY_REMOVE_DEVICE:
+ /* indicate success */
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+
+ /* skip irp stack location */
+ IoSkipCurrentIrpStackLocation(Irp);
+
+ /* dispatch to lower device */
+ return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
+
+ case IRP_MN_REMOVE_DEVICE:
+ /* FIXME synchronization */
+
+ /* cancel irp */
+ IoCancelIrp(DeviceExtension->Irp);
+
+ /* indicate success */
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+
+ /* skip irp stack location */
+ IoSkipCurrentIrpStackLocation(Irp);
+
+ /* dispatch to lower device */
+ Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
+
+ IoFreeIrp(DeviceExtension->Irp);
+ IoDetachDevice(DeviceExtension->NextDeviceObject);
+ IoDeleteDevice(DeviceObject);
+ return Status;
+
+ case IRP_MN_START_DEVICE:
+ /* init event */
+ KeInitializeEvent(&Event, NotificationEvent, FALSE);
+
+ /* copy stack location */
+ IoCopyCurrentIrpStackLocationToNext (Irp);
+
+ /* set completion routine */
+ IoSetCompletionRoutine(Irp, KbdHid_StartDeviceCompletion, &Event, TRUE,
TRUE, TRUE);
+ Irp->IoStatus.Status = 0;
+
+ /* pass request */
+ Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
+ if (Status == STATUS_PENDING)
+ {
+ KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
+ Status = Irp->IoStatus.Status;
+ }
+
+ if (!NT_SUCCESS(Status))
+ {
+ /* failed */
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return Status;
+ }
+
+ /* lets start the device */
+ Status = KbdHid_StartDevice(DeviceObject);
+ DPRINT("KbdHid_StartDevice %x\n", Status);
+
+ /* complete request */
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+ /* done */
return Status;
- }
-
- /* lets start the device */
- Status = KbdHid_StartDevice(DeviceObject);
- DPRINT("KbdHid_StartDevice %x\n", Status);
-
- /* complete request */
- Irp->IoStatus.Status = Status;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
- /* done */
- return Status;
- }
- else
- {
- /* skip irp stack location */
- IoSkipCurrentIrpStackLocation(Irp);
-
- /* dispatch to lower device */
- return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
+
+ default:
+ /* skip irp stack location */
+ IoSkipCurrentIrpStackLocation(Irp);
+
+ /* dispatch to lower device */
+ return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
}
}
@@ -849,7 +893,13 @@
POWER_STATE State;
/* create device object */
- Status = IoCreateDevice(DriverObject, sizeof(KBDHID_DEVICE_EXTENSION), NULL,
FILE_DEVICE_KEYBOARD, 0, FALSE, &DeviceObject);
+ Status = IoCreateDevice(DriverObject,
+ sizeof(KBDHID_DEVICE_EXTENSION),
+ NULL,
+ FILE_DEVICE_KEYBOARD,
+ 0,
+ FALSE,
+ &DeviceObject);
if (!NT_SUCCESS(Status))
{
/* failed to create device object */
Modified: trunk/reactos/drivers/hid/kbdhid/kbdhid.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/hid/kbdhid/kbdhid.…
==============================================================================
--- trunk/reactos/drivers/hid/kbdhid/kbdhid.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/hid/kbdhid/kbdhid.h [iso-8859-1] Sat May 11 10:23:54 2013
@@ -26,7 +26,7 @@
PIRP Irp;
//
- // event
+ // event
//
KEVENT ReadCompletionEvent;
@@ -125,12 +125,12 @@
}KBDHID_DEVICE_EXTENSION, *PKBDHID_DEVICE_EXTENSION;
/* defaults from kbfiltr.h */
-#define KEYBOARD_TYPEMATIC_RATE_MINIMUM 2
-#define KEYBOARD_TYPEMATIC_RATE_MAXIMUM 30
-#define KEYBOARD_TYPEMATIC_RATE_DEFAULT 30
-#define KEYBOARD_TYPEMATIC_DELAY_MINIMUM 250
-#define KEYBOARD_TYPEMATIC_DELAY_MAXIMUM 1000
-#define KEYBOARD_TYPEMATIC_DELAY_DEFAULT 250
+#define KEYBOARD_TYPEMATIC_RATE_MINIMUM 2
+#define KEYBOARD_TYPEMATIC_RATE_MAXIMUM 30
+#define KEYBOARD_TYPEMATIC_RATE_DEFAULT 30
+#define KEYBOARD_TYPEMATIC_DELAY_MINIMUM 250
+#define KEYBOARD_TYPEMATIC_DELAY_MAXIMUM 1000
+#define KEYBOARD_TYPEMATIC_DELAY_DEFAULT 250
/* FIXME: write kbd.h */
#define MICROSOFT_KBD_FUNC 12
@@ -143,4 +143,3 @@
NTSTATUS
KbdHid_InitiateRead(
IN PKBDHID_DEVICE_EXTENSION DeviceExtension);
-
Modified: trunk/reactos/drivers/hid/mouhid/mouhid.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/hid/mouhid/mouhid.…
==============================================================================
--- trunk/reactos/drivers/hid/mouhid/mouhid.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/hid/mouhid/mouhid.c [iso-8859-1] Sat May 11 10:23:54 2013
@@ -10,7 +10,7 @@
#include "mouhid.h"
-static USHORT MouHid_ButtonUpFlags[] =
+static USHORT MouHid_ButtonUpFlags[] =
{
0xFF, /* unused */
MOUSE_LEFT_BUTTON_DOWN,
@@ -20,7 +20,7 @@
MOUSE_BUTTON_5_DOWN
};
-static USHORT MouHid_ButtonDownFlags[] =
+static USHORT MouHid_ButtonDownFlags[] =
{
0xFF, /* unused */
MOUSE_LEFT_BUTTON_UP,
@@ -44,7 +44,14 @@
*LastY = 0;
/* get scaled usage value x */
- Status = HidP_GetScaledUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC,
HIDP_LINK_COLLECTION_UNSPECIFIED, HID_USAGE_GENERIC_X, (PLONG)LastX,
DeviceExtension->PreparsedData, DeviceExtension->Report,
DeviceExtension->ReportLength);
+ Status = HidP_GetScaledUsageValue(HidP_Input,
+ HID_USAGE_PAGE_GENERIC,
+ HIDP_LINK_COLLECTION_UNSPECIFIED,
+ HID_USAGE_GENERIC_X,
+ LastX,
+ DeviceExtension->PreparsedData,
+ DeviceExtension->Report,
+ DeviceExtension->ReportLength);
if (Status != HIDP_STATUS_SUCCESS)
{
/* FIXME: handle more errors */
@@ -54,7 +61,14 @@
DeviceExtension->MouseAbsolute = TRUE;
/* get unscaled value */
- Status = HidP_GetUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC,
HIDP_LINK_COLLECTION_UNSPECIFIED, HID_USAGE_GENERIC_X, (PULONG)&ValueX,
DeviceExtension->PreparsedData, DeviceExtension->Report,
DeviceExtension->ReportLength);
+ Status = HidP_GetUsageValue(HidP_Input,
+ HID_USAGE_PAGE_GENERIC,
+ HIDP_LINK_COLLECTION_UNSPECIFIED,
+ HID_USAGE_GENERIC_X,
+ &ValueX,
+ DeviceExtension->PreparsedData,
+ DeviceExtension->Report,
+ DeviceExtension->ReportLength);
/* FIXME handle error */
ASSERT(Status == HIDP_STATUS_SUCCESS);
@@ -67,7 +81,14 @@
}
/* get scaled usage value y */
- Status = HidP_GetScaledUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC,
HIDP_LINK_COLLECTION_UNSPECIFIED, HID_USAGE_GENERIC_Y, (PLONG)LastY,
DeviceExtension->PreparsedData, DeviceExtension->Report,
DeviceExtension->ReportLength);
+ Status = HidP_GetScaledUsageValue(HidP_Input,
+ HID_USAGE_PAGE_GENERIC,
+ HIDP_LINK_COLLECTION_UNSPECIFIED,
+ HID_USAGE_GENERIC_Y,
+ LastY,
+ DeviceExtension->PreparsedData,
+ DeviceExtension->Report,
+ DeviceExtension->ReportLength);
if (Status != HIDP_STATUS_SUCCESS)
{
// FIXME: handle more errors
@@ -77,7 +98,14 @@
DeviceExtension->MouseAbsolute = TRUE;
// get unscaled value
- Status = HidP_GetUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC,
HIDP_LINK_COLLECTION_UNSPECIFIED, HID_USAGE_GENERIC_Y, (PULONG)&ValueY,
DeviceExtension->PreparsedData, DeviceExtension->Report,
DeviceExtension->ReportLength);
+ Status = HidP_GetUsageValue(HidP_Input,
+ HID_USAGE_PAGE_GENERIC,
+ HIDP_LINK_COLLECTION_UNSPECIFIED,
+ HID_USAGE_GENERIC_Y,
+ &ValueY,
+ DeviceExtension->PreparsedData,
+ DeviceExtension->Report,
+ DeviceExtension->ReportLength);
/* FIXME handle error */
ASSERT(Status == HIDP_STATUS_SUCCESS);
@@ -107,7 +135,14 @@
/* get usages */
CurrentUsageListLength = DeviceExtension->UsageListLength;
- Status = HidP_GetUsages(HidP_Input, HID_USAGE_PAGE_BUTTON,
HIDP_LINK_COLLECTION_UNSPECIFIED, DeviceExtension->CurrentUsageList,
&CurrentUsageListLength, DeviceExtension->PreparsedData,
DeviceExtension->Report, DeviceExtension->ReportLength);
+ Status = HidP_GetUsages(HidP_Input,
+ HID_USAGE_PAGE_BUTTON,
+ HIDP_LINK_COLLECTION_UNSPECIFIED,
+ DeviceExtension->CurrentUsageList,
+ &CurrentUsageListLength,
+ DeviceExtension->PreparsedData,
+ DeviceExtension->Report,
+ DeviceExtension->ReportLength);
if (Status != HIDP_STATUS_SUCCESS)
{
DPRINT1("MouHid_GetButtonFlags failed to get usages with %x\n",
Status);
@@ -115,7 +150,11 @@
}
/* extract usage list difference */
- Status = HidP_UsageListDifference(DeviceExtension->PreviousUsageList,
DeviceExtension->CurrentUsageList, DeviceExtension->BreakUsageList,
DeviceExtension->MakeUsageList, DeviceExtension->UsageListLength);
+ Status = HidP_UsageListDifference(DeviceExtension->PreviousUsageList,
+ DeviceExtension->CurrentUsageList,
+ DeviceExtension->BreakUsageList,
+ DeviceExtension->MakeUsageList,
+ DeviceExtension->UsageListLength);
if (Status != HIDP_STATUS_SUCCESS)
{
DPRINT1("MouHid_GetButtonFlags failed to get usages with %x\n",
Status);
@@ -140,7 +179,7 @@
/* move to next index*/
Index++;
- }while(Index < DeviceExtension->UsageListLength);
+ } while (Index < DeviceExtension->UsageListLength);
}
if (DeviceExtension->UsageListLength)
@@ -161,7 +200,7 @@
/* move to next index*/
Index++;
- }while(Index < DeviceExtension->UsageListLength);
+ } while (Index < DeviceExtension->UsageListLength);
}
/* now switch the previous list with current list */
@@ -258,7 +297,14 @@
{
/* get usage */
UsageValue = 0;
- Status = HidP_GetScaledUsageValue(HidP_Input, HID_USAGE_PAGE_GENERIC,
HIDP_LINK_COLLECTION_UNSPECIFIED, HID_USAGE_GENERIC_WHEEL, &UsageValue,
DeviceExtension->PreparsedData, DeviceExtension->Report,
DeviceExtension->ReportLength);
+ Status = HidP_GetScaledUsageValue(HidP_Input,
+ HID_USAGE_PAGE_GENERIC,
+ HIDP_LINK_COLLECTION_UNSPECIFIED,
+ HID_USAGE_GENERIC_WHEEL,
+ &UsageValue,
+ DeviceExtension->PreparsedData,
+ DeviceExtension->Report,
+ DeviceExtension->ReportLength);
if (Status == HIDP_STATUS_SUCCESS && UsageValue != 0)
{
/* store wheel status */
@@ -332,7 +378,7 @@
IN PIRP Irp,
IN PVOID Context)
{
- KeSetEvent((PKEVENT)Context, 0, FALSE);
+ KeSetEvent(Context, 0, FALSE);
return STATUS_MORE_PROCESSING_REQUIRED;
}
@@ -470,8 +516,9 @@
DeviceExtension = (PMOUHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
/* handle requests */
- if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_MOUSE_QUERY_ATTRIBUTES)
- {
+ switch (IoStack->Parameters.DeviceIoControl.IoControlCode)
+ {
+ case IOCTL_MOUSE_QUERY_ATTRIBUTES:
/* verify output buffer length */
if (IoStack->Parameters.DeviceIoControl.OutputBufferLength <
sizeof(MOUSE_ATTRIBUTES))
{
@@ -507,9 +554,8 @@
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
- }
- else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_INTERNAL_MOUSE_CONNECT)
- {
+
+ case IOCTL_INTERNAL_MOUSE_CONNECT:
/* verify input buffer length */
if (IoStack->Parameters.DeviceIoControl.InputBufferLength <
sizeof(CONNECT_DATA))
{
@@ -539,23 +585,20 @@
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
- }
- else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_INTERNAL_MOUSE_DISCONNECT)
- {
+
+ case IOCTL_INTERNAL_MOUSE_DISCONNECT:
/* not supported */
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_NOT_IMPLEMENTED;
- }
- else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_INTERNAL_MOUSE_ENABLE)
- {
+
+ case IOCTL_INTERNAL_MOUSE_ENABLE:
/* not supported */
Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_NOT_SUPPORTED;
- }
- else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_INTERNAL_MOUSE_DISABLE)
- {
+
+ case IOCTL_INTERNAL_MOUSE_DISABLE:
/* not supported */
Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
@@ -619,7 +662,15 @@
KeInitializeEvent(&Event, NotificationEvent, FALSE);
/* build request */
- Irp = IoBuildDeviceIoControlRequest(IoControlCode,
DeviceExtension->NextDeviceObject, InputBuffer, InputBufferSize, OutputBuffer,
OutputBufferSize, FALSE, &Event, &IoStatus);
+ Irp = IoBuildDeviceIoControlRequest(IoControlCode,
+ DeviceExtension->NextDeviceObject,
+ InputBuffer,
+ InputBufferSize,
+ OutputBuffer,
+ OutputBufferSize,
+ FALSE,
+ &Event,
+ &IoStatus);
if (!Irp)
{
/* no memory */
@@ -658,7 +709,12 @@
DeviceExtension = (PMOUHID_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
/* query collection information */
- Status = MouHid_SubmitRequest(DeviceObject, IOCTL_HID_GET_COLLECTION_INFORMATION, 0,
NULL, sizeof(HID_COLLECTION_INFORMATION), &Information);
+ Status = MouHid_SubmitRequest(DeviceObject,
+ IOCTL_HID_GET_COLLECTION_INFORMATION,
+ 0,
+ NULL,
+ sizeof(HID_COLLECTION_INFORMATION),
+ &Information);
if (!NT_SUCCESS(Status))
{
/* failed to query collection information */
@@ -676,7 +732,12 @@
}
/* now obtain the preparsed data */
- Status = MouHid_SubmitRequest(DeviceObject, IOCTL_HID_GET_COLLECTION_DESCRIPTOR, 0,
NULL, Information.DescriptorSize, PreparsedData);
+ Status = MouHid_SubmitRequest(DeviceObject,
+ IOCTL_HID_GET_COLLECTION_DESCRIPTOR,
+ 0,
+ NULL,
+ Information.DescriptorSize,
+ PreparsedData);
if (!NT_SUCCESS(Status))
{
/* failed to get preparsed data */
@@ -713,14 +774,20 @@
RtlZeroMemory(DeviceExtension->Report, DeviceExtension->ReportLength);
/* build mdl */
- DeviceExtension->ReportMDL = IoAllocateMdl(DeviceExtension->Report,
DeviceExtension->ReportLength, FALSE, FALSE, NULL);
+ DeviceExtension->ReportMDL = IoAllocateMdl(DeviceExtension->Report,
+ DeviceExtension->ReportLength,
+ FALSE,
+ FALSE,
+ NULL);
ASSERT(DeviceExtension->ReportMDL);
/* init mdl */
MmBuildMdlForNonPagedPool(DeviceExtension->ReportMDL);
/* get max number of buttons */
- Buttons = HidP_MaxUsageListLength(HidP_Input, HID_USAGE_PAGE_BUTTON, PreparsedData);
+ Buttons = HidP_MaxUsageListLength(HidP_Input,
+ HID_USAGE_PAGE_BUTTON,
+ PreparsedData);
DPRINT("[MOUHID] Buttons %lu\n", Buttons);
ASSERT(Buttons > 0);
@@ -750,15 +817,33 @@
DeviceExtension->PreparsedData = PreparsedData;
ValueCapsLength = 1;
- HidP_GetSpecificValueCaps(HidP_Input, HID_USAGE_PAGE_GENERIC,
HIDP_LINK_COLLECTION_UNSPECIFIED, HID_USAGE_GENERIC_X,
&DeviceExtension->ValueCapsX, &ValueCapsLength, PreparsedData);
+ HidP_GetSpecificValueCaps(HidP_Input,
+ HID_USAGE_PAGE_GENERIC,
+ HIDP_LINK_COLLECTION_UNSPECIFIED,
+ HID_USAGE_GENERIC_X,
+ &DeviceExtension->ValueCapsX,
+ &ValueCapsLength,
+ PreparsedData);
ValueCapsLength = 1;
- HidP_GetSpecificValueCaps(HidP_Input, HID_USAGE_PAGE_GENERIC,
HIDP_LINK_COLLECTION_UNSPECIFIED, HID_USAGE_GENERIC_Y,
&DeviceExtension->ValueCapsY, &ValueCapsLength, PreparsedData);
+ HidP_GetSpecificValueCaps(HidP_Input,
+ HID_USAGE_PAGE_GENERIC,
+ HIDP_LINK_COLLECTION_UNSPECIFIED,
+ HID_USAGE_GENERIC_Y,
+ &DeviceExtension->ValueCapsY,
+ &ValueCapsLength,
+ PreparsedData);
/* now check for wheel mouse support */
ValueCapsLength = 1;
- Status = HidP_GetSpecificValueCaps(HidP_Input, HID_USAGE_PAGE_GENERIC,
HIDP_LINK_COLLECTION_UNSPECIFIED, HID_USAGE_GENERIC_WHEEL, &ValueCaps,
&ValueCapsLength, PreparsedData);
- if (Status == HIDP_STATUS_SUCCESS )
+ Status = HidP_GetSpecificValueCaps(HidP_Input,
+ HID_USAGE_PAGE_GENERIC,
+ HIDP_LINK_COLLECTION_UNSPECIFIED,
+ HID_USAGE_GENERIC_WHEEL,
+ &ValueCaps,
+ &ValueCapsLength,
+ PreparsedData);
+ if (Status == HIDP_STATUS_SUCCESS)
{
/* mouse has wheel support */
DeviceExtension->MouseIdentifier = WHEELMOUSE_HID_HARDWARE;
@@ -769,7 +854,13 @@
{
/* check if the mouse has z-axis */
ValueCapsLength = 1;
- Status = HidP_GetSpecificValueCaps(HidP_Input, HID_USAGE_PAGE_GENERIC,
HIDP_LINK_COLLECTION_UNSPECIFIED, HID_USAGE_GENERIC_Z, &ValueCaps,
&ValueCapsLength, PreparsedData);
+ Status = HidP_GetSpecificValueCaps(HidP_Input,
+ HID_USAGE_PAGE_GENERIC,
+ HIDP_LINK_COLLECTION_UNSPECIFIED,
+ HID_USAGE_GENERIC_Z,
+ &ValueCaps,
+ &ValueCapsLength,
+ PreparsedData);
if (Status == HIDP_STATUS_SUCCESS && ValueCapsLength == 1)
{
/* wheel support */
@@ -838,101 +929,99 @@
IoStack = IoGetCurrentIrpStackLocation(Irp);
DPRINT("[MOUHID] IRP_MJ_PNP Request: %x\n", IoStack->MinorFunction);
- if (IoStack->MinorFunction == IRP_MN_STOP_DEVICE ||
- IoStack->MinorFunction == IRP_MN_CANCEL_REMOVE_DEVICE ||
- IoStack->MinorFunction == IRP_MN_QUERY_STOP_DEVICE ||
- IoStack->MinorFunction == IRP_MN_CANCEL_STOP_DEVICE ||
- IoStack->MinorFunction == IRP_MN_QUERY_REMOVE_DEVICE)
- {
- /* indicate success */
- Irp->IoStatus.Status = STATUS_SUCCESS;
-
- /* skip irp stack location */
- IoSkipCurrentIrpStackLocation(Irp);
-
- /* dispatch to lower device */
- return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
- }
- else if (IoStack->MinorFunction == IRP_MN_REMOVE_DEVICE)
- {
- /* FIXME synchronization */
-
- /* request stop */
- DeviceExtension->StopReadReport = TRUE;
-
- /* cancel irp */
- IoCancelIrp(DeviceExtension->Irp);
-
- /* indicate success */
- Irp->IoStatus.Status = STATUS_SUCCESS;
-
- /* skip irp stack location */
- IoSkipCurrentIrpStackLocation(Irp);
-
- /* dispatch to lower device */
- Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
-
- /* wait for completion of stop event */
- KeWaitForSingleObject(&DeviceExtension->ReadCompletionEvent, Executive,
KernelMode, FALSE, NULL);
-
- /* free irp */
- IoFreeIrp(DeviceExtension->Irp);
-
- /* detach device */
- IoDetachDevice(DeviceExtension->NextDeviceObject);
-
- /* delete device */
- IoDeleteDevice(DeviceObject);
-
- /* done */
- return Status;
- }
- else if (IoStack->MinorFunction == IRP_MN_START_DEVICE)
- {
- /* init event */
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
-
- /* copy stack location */
- IoCopyCurrentIrpStackLocationToNext (Irp);
-
- /* set completion routine */
- IoSetCompletionRoutine(Irp, MouHid_StartDeviceCompletion, &Event, TRUE, TRUE,
TRUE);
- Irp->IoStatus.Status = 0;
-
- /* pass request */
- Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
- if (Status == STATUS_PENDING)
- {
- KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
- Status = Irp->IoStatus.Status;
- }
-
- if (!NT_SUCCESS(Status))
- {
- /* failed */
+ switch (IoStack->MinorFunction)
+ {
+ case IRP_MN_STOP_DEVICE:
+ case IRP_MN_CANCEL_REMOVE_DEVICE:
+ case IRP_MN_QUERY_STOP_DEVICE:
+ case IRP_MN_CANCEL_STOP_DEVICE:
+ case IRP_MN_QUERY_REMOVE_DEVICE:
+ /* indicate success */
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+
+ /* skip irp stack location */
+ IoSkipCurrentIrpStackLocation(Irp);
+
+ /* dispatch to lower device */
+ return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
+
+ case IRP_MN_REMOVE_DEVICE:
+ /* FIXME synchronization */
+
+ /* request stop */
+ DeviceExtension->StopReadReport = TRUE;
+
+ /* cancel irp */
+ IoCancelIrp(DeviceExtension->Irp);
+
+ /* indicate success */
+ Irp->IoStatus.Status = STATUS_SUCCESS;
+
+ /* skip irp stack location */
+ IoSkipCurrentIrpStackLocation(Irp);
+
+ /* dispatch to lower device */
+ Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
+
+ /* wait for completion of stop event */
+ KeWaitForSingleObject(&DeviceExtension->ReadCompletionEvent,
Executive, KernelMode, FALSE, NULL);
+
+ /* free irp */
+ IoFreeIrp(DeviceExtension->Irp);
+
+ /* detach device */
+ IoDetachDevice(DeviceExtension->NextDeviceObject);
+
+ /* delete device */
+ IoDeleteDevice(DeviceObject);
+
+ /* done */
+ return Status;
+
+ case IRP_MN_START_DEVICE:
+ /* init event */
+ KeInitializeEvent(&Event, NotificationEvent, FALSE);
+
+ /* copy stack location */
+ IoCopyCurrentIrpStackLocationToNext (Irp);
+
+ /* set completion routine */
+ IoSetCompletionRoutine(Irp, MouHid_StartDeviceCompletion, &Event, TRUE,
TRUE, TRUE);
+ Irp->IoStatus.Status = 0;
+
+ /* pass request */
+ Status = IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
+ if (Status == STATUS_PENDING)
+ {
+ KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
+ Status = Irp->IoStatus.Status;
+ }
+
+ if (!NT_SUCCESS(Status))
+ {
+ /* failed */
+ Irp->IoStatus.Status = Status;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return Status;
+ }
+
+ /* lets start the device */
+ Status = MouHid_StartDevice(DeviceObject);
+ DPRINT("MouHid_StartDevice %x\n", Status);
+
+ /* complete request */
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
+
+ /* done */
return Status;
- }
-
- /* lets start the device */
- Status = MouHid_StartDevice(DeviceObject);
- DPRINT("MouHid_StartDevice %x\n", Status);
-
- /* complete request */
- Irp->IoStatus.Status = Status;
- IoCompleteRequest(Irp, IO_NO_INCREMENT);
-
- /* done */
- return Status;
- }
- else
- {
- /* skip irp stack location */
- IoSkipCurrentIrpStackLocation(Irp);
-
- /* dispatch to lower device */
- return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
+
+ default:
+ /* skip irp stack location */
+ IoSkipCurrentIrpStackLocation(Irp);
+
+ /* dispatch to lower device */
+ return IoCallDriver(DeviceExtension->NextDeviceObject, Irp);
}
}
@@ -948,7 +1037,13 @@
POWER_STATE State;
/* create device object */
- Status = IoCreateDevice(DriverObject, sizeof(MOUHID_DEVICE_EXTENSION), NULL,
FILE_DEVICE_MOUSE, 0, FALSE, &DeviceObject);
+ Status = IoCreateDevice(DriverObject,
+ sizeof(MOUHID_DEVICE_EXTENSION),
+ NULL,
+ FILE_DEVICE_MOUSE,
+ 0,
+ FALSE,
+ &DeviceObject);
if (!NT_SUCCESS(Status))
{
/* failed to create device object */
Modified: trunk/reactos/drivers/hid/mouhid/mouhid.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/hid/mouhid/mouhid.…
==============================================================================
--- trunk/reactos/drivers/hid/mouhid/mouhid.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/hid/mouhid/mouhid.h [iso-8859-1] Sat May 11 10:23:54 2013
@@ -25,7 +25,7 @@
PIRP Irp;
//
- // event
+ // event
//
KEVENT ReadCompletionEvent;