Author: janderwald
Date: Fri Jan 6 18:32:35 2012
New Revision: 54852
URL:
http://svn.reactos.org/svn/reactos?rev=54852&view=rev
Log:
[USB-BRINGUP]
- Implement IOCTL_KEYBOARD_QUERY_ATTRIBUTES, IOCTL_INTERNAL_KEYBOARD_CONNECT,
IOCTL_INTERNAL_KEYBOARD_DISCONNECT, IOCTL_INTERNAL_KEYBOARD_ENABLE,
IOCTL_INTERNAL_KEYBOARD_DISABLE
Modified:
branches/usb-bringup/drivers/hid/kbdhid/kbdhid.c
branches/usb-bringup/drivers/hid/kbdhid/kbdhid.h
Modified: branches/usb-bringup/drivers/hid/kbdhid/kbdhid.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/hid/kbdhid/…
==============================================================================
--- branches/usb-bringup/drivers/hid/kbdhid/kbdhid.c [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/hid/kbdhid/kbdhid.c [iso-8859-1] Fri Jan 6 18:32:35
2012
@@ -249,6 +249,8 @@
{
PIO_STACK_LOCATION IoStack;
PKBDHID_DEVICE_EXTENSION DeviceExtension;
+ PCONNECT_DATA Data;
+ PKEYBOARD_ATTRIBUTES Attributes;
/* get current stack location */
IoStack = IoGetCurrentIrpStackLocation(Irp);
@@ -258,9 +260,131 @@
/* 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;
+ 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)
+ {
+ /* not implemented */
+ DPRINT1("IOCTL_KEYBOARD_QUERY_INDICATORS not implemented\n");
+ ASSERT(FALSE);
+ Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_NOT_IMPLEMENTED;
+ }
+ else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_KEYBOARD_QUERY_TYPEMATIC)
+ {
+ /* not implemented */
+ DPRINT1("IOCTL_KEYBOARD_QUERY_TYPEMATIC not implemented\n");
+ ASSERT(FALSE);
+ Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_NOT_IMPLEMENTED;
+ }
+ else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_KEYBOARD_SET_INDICATORS)
+ {
+ /* not implemented */
+ DPRINT1("IOCTL_KEYBOARD_SET_INDICATORS not implemented\n");
+ ASSERT(FALSE);
+ Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_NOT_IMPLEMENTED;
+ }
+ else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_KEYBOARD_SET_TYPEMATIC)
+ {
+ /* not implemented */
+ DPRINT1("IOCTL_KEYBOARD_SET_TYPEMATIC not implemented\n");
+ ASSERT(FALSE);
+ Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_NOT_IMPLEMENTED;
+ }
+ else if (IoStack->Parameters.DeviceIoControl.IoControlCode ==
IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION)
+ {
+ /* not implemented */
+ DPRINT1("IOCTL_KEYBOARD_QUERY_INDICATOR_TRANSLATION not
implemented\n");
+ ASSERT(FALSE);
+ Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
+ IoCompleteRequest(Irp, IO_NO_INCREMENT);
+ return STATUS_NOT_IMPLEMENTED;
+ }
+
+ /* unknown control code */
DPRINT1("[KBDHID] Unknown DeviceControl %x\n",
IoStack->Parameters.DeviceIoControl.IoControlCode);
-
- ASSERT(FALSE);
/* unknown request not supported */
Irp->IoStatus.Status = STATUS_NOT_SUPPORTED;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
@@ -624,6 +748,20 @@
/* init device extension */
DeviceExtension->NextDeviceObject = NextDeviceObject;
KeInitializeEvent(&DeviceExtension->ReadCompletionEvent, NotificationEvent,
FALSE);
+
+ /* init keyboard attributes */
+ DeviceExtension->Attributes.KeyboardIdentifier.Type = KEYBOARD_TYPE_UNKNOWN;
+ DeviceExtension->Attributes.KeyboardIdentifier.Subtype = MICROSOFT_KBD_101_TYPE;
+ DeviceExtension->Attributes.NumberOfFunctionKeys = MICROSOFT_KBD_FUNC;
+ DeviceExtension->Attributes.NumberOfIndicators = 3; // caps, num lock, scroll
lock
+ DeviceExtension->Attributes.NumberOfKeysTotal = 101;
+ DeviceExtension->Attributes.InputDataQueueLength = 1;
+ DeviceExtension->Attributes.KeyRepeatMinimum.Rate =
KEYBOARD_TYPEMATIC_RATE_MINIMUM;
+ DeviceExtension->Attributes.KeyRepeatMinimum.Delay =
KEYBOARD_TYPEMATIC_DELAY_MINIMUM;
+ DeviceExtension->Attributes.KeyRepeatMaximum.Rate =
KEYBOARD_TYPEMATIC_RATE_DEFAULT;
+ DeviceExtension->Attributes.KeyRepeatMaximum.Delay =
KEYBOARD_TYPEMATIC_DELAY_MAXIMUM;
+
+ /* allocate irp */
DeviceExtension->Irp = IoAllocateIrp(NextDeviceObject->StackSize, FALSE);
/* FIXME handle allocation error */
Modified: branches/usb-bringup/drivers/hid/kbdhid/kbdhid.h
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/hid/kbdhid/…
==============================================================================
--- branches/usb-bringup/drivers/hid/kbdhid/kbdhid.h [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/hid/kbdhid/kbdhid.h [iso-8859-1] Fri Jan 6 18:32:35
2012
@@ -6,8 +6,9 @@
#include <hidpddi.h>
#include <hidpi.h>
#include <debug.h>
-#include <ntddmou.h>
#include <kbdmou.h>
+//#include <kbd.h>
+#include <ntddkbd.h>
#include <debug.h>
@@ -98,9 +99,30 @@
//
UCHAR StopReadReport;
+ //
+ // keyboard attributes
+ //
+ KEYBOARD_ATTRIBUTES Attributes;
+
}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
+
+/* FIXME: write kbd.h */
+#define MICROSOFT_KBD_FUNC 12
+#define KEYBOARD_TYPE_UNKNOWN (0x51)
+#define MICROSOFT_KBD_101_TYPE 0
+
+
NTSTATUS
KbdHid_InitiateRead(
IN PKBDHID_DEVICE_EXTENSION DeviceExtension);
+