[HIDPARSER]
authorJohannes Anderwald <johannes.anderwald@reactos.org>
Wed, 1 Feb 2012 13:34:20 +0000 (13:34 +0000)
committerJohannes Anderwald <johannes.anderwald@reactos.org>
Wed, 1 Feb 2012 13:34:20 +0000 (13:34 +0000)
- A key break code indicator is 0x80, not 0x1
[USBCCGP]
- Silence debug print
[KBDHID]
- Implement IOCTL_KEYBOARD_QUERY_INDICATORS, IOCTL_KEYBOARD_SET_INDICATORS
- Partly implement dispatching to kbdclass
- Kbdclass now receives keys from kbdhid. Not yet fully working
- Tested in XP+ ReactOS USB Stack + ReactOS HID stack + USB Composite Device Keyboard

svn path=/branches/usb-bringup-trunk/; revision=55368

drivers/hid/kbdhid/kbdhid.c
drivers/hid/kbdhid/kbdhid.h
drivers/usb/usbccgp/pdo.c
lib/drivers/hidparser/api.c

index 4eafcec..5c8471a 100644 (file)
@@ -42,16 +42,36 @@ KbdHid_InsertScanCodes(
     IN PCHAR  NewScanCodes,
     IN ULONG  Length)
 {
-    //KEYBOARD_INPUT_DATA InputData;
+    KEYBOARD_INPUT_DATA InputData;
     ULONG Index;
+    PKBDHID_DEVICE_EXTENSION DeviceExtension;
+
+    /* get device extension */
+    DeviceExtension = (PKBDHID_DEVICE_EXTENSION)Context;
 
     for(Index = 0; Index < Length; Index++)
     {
         DPRINT1("[KBDHID] ScanCode Index %lu ScanCode %x\n", Index, NewScanCodes[Index] & 0xFF);
+
         //
-        // TODO: set up input data
+        // set up input data
         //
-        //KbdHid_DispatchInputData((PKBDHID_DEVICE_EXTENSION)Context, &InputData);
+        RtlZeroMemory(&InputData, sizeof(KEYBOARD_INPUT_DATA));
+
+        /* use keyboard unit id */
+        InputData.UnitId = DeviceExtension->KeyboardIndicator.UnitId;
+
+        if (NewScanCodes[Index] > 0x7F)
+        {
+            /* scan codes greater than 0x7F are a key break */
+            InputData.Flags |= KEY_BREAK;
+        }
+
+        /* store key code */
+        InputData.MakeCode = NewScanCodes[Index];
+
+        /* dispatch scan codes */
+        KbdHid_DispatchInputData((PKBDHID_DEVICE_EXTENSION)Context, &InputData);
     }
 
     //
@@ -391,9 +411,20 @@ KbdHid_InternalDeviceControl(
     }
     else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KEYBOARD_QUERY_INDICATORS)
     {
-        /* not implemented */
-        DPRINT1("IOCTL_KEYBOARD_QUERY_INDICATORS not implemented\n");
-        Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
+        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;
     }
@@ -407,11 +438,22 @@ KbdHid_InternalDeviceControl(
     }
     else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KEYBOARD_SET_INDICATORS)
     {
-        /* not implemented */
-        DPRINT1("IOCTL_KEYBOARD_SET_INDICATORS not implemented\n");
-        Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
+        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_NOT_IMPLEMENTED;
+        return STATUS_SUCCESS;
     }
     else if (IoStack->Parameters.DeviceIoControl.IoControlCode == IOCTL_KEYBOARD_SET_TYPEMATIC)
     {
index 0324ad4..9ec2397 100644 (file)
@@ -109,6 +109,12 @@ typedef struct
     //
     HIDP_KEYBOARD_MODIFIER_STATE ModifierState;
 
+    //
+    // keyboard indicator state
+    //
+    KEYBOARD_INDICATOR_PARAMETERS KeyboardIndicator;
+
+
 }KBDHID_DEVICE_EXTENSION, *PKBDHID_DEVICE_EXTENSION;
 
 /* defaults from kbfiltr.h */
index 256284e..22d0697 100644 (file)
@@ -850,7 +850,7 @@ PDO_HandleInternalDeviceControl(
         //
         Urb = (PURB)IoStack->Parameters.Others.Argument1;
         ASSERT(Urb);
-        DPRINT1("IOCTL_INTERNAL_USB_SUBMIT_URB Function %x\n", Urb->UrbHeader.Function);
+        DPRINT("IOCTL_INTERNAL_USB_SUBMIT_URB Function %x\n", Urb->UrbHeader.Function);
 
         if (Urb->UrbHeader.Function == URB_FUNCTION_SELECT_CONFIGURATION)
         {
index 8d5859c..c37673d 100644 (file)
@@ -663,9 +663,9 @@ HidParser_DispatchKey(
         if (KeyAction == HidP_Keyboard_Break)
         {
             //
-            // add break
+            // add break - see USB HID to PS/2 Scan Code Translation Table
             //
-            ScanCodes[Index] |= KEY_BREAK;
+            ScanCodes[Index] |= 0x80;
         }
 
         //
@@ -711,7 +711,6 @@ HidParser_TranslateUsage(
     //
     // FIXME: translate modifier states
     //
-       DPRINT1("Usage %x ScanCode %x\n", Usage, ScanCode);
     HidParser_DispatchKey((PCHAR)&ScanCode, KeyAction, InsertCodesProcedure, InsertCodesContext);
 
     //