Author: janderwald
Date: Sat Jan 7 10:24:10 2012
New Revision: 54858
URL:
http://svn.reactos.org/svn/reactos?rev=54858&view=rev
Log:
[USB-BRINGUP]
- Partly implement HidP_TranslateUsageAndPagesToI8042ScanCodes
- Needs key modifier state function to work correctly
- KBDHID should now receive translated keys (without key modifiers)
Modified:
branches/usb-bringup/drivers/hid/hidparse/hidparse.c
branches/usb-bringup/lib/drivers/hidparser/api.c
branches/usb-bringup/lib/drivers/hidparser/hidparser.c
branches/usb-bringup/lib/drivers/hidparser/hidparser.h
Modified: branches/usb-bringup/drivers/hid/hidparse/hidparse.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/drivers/hid/hidpars…
==============================================================================
--- branches/usb-bringup/drivers/hid/hidparse/hidparse.c [iso-8859-1] (original)
+++ branches/usb-bringup/drivers/hid/hidparse/hidparse.c [iso-8859-1] Sat Jan 7 10:24:10
2012
@@ -322,6 +322,37 @@
HIDAPI
NTSTATUS
NTAPI
+HidP_TranslateUsageAndPagesToI8042ScanCodes(
+ IN PUSAGE_AND_PAGE ChangedUsageList,
+ IN ULONG UsageListLength,
+ IN HIDP_KEYBOARD_DIRECTION KeyAction,
+ IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
+ IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
+ IN PVOID InsertCodesContext)
+{
+ HID_PARSER Parser;
+
+ //
+ // sanity check
+ //
+ ASSERT(ReportType == HidP_Input || ReportType == HidP_Output || ReportType ==
HidP_Feature);
+
+ //
+ // init parser
+ //
+ HidParser_InitParser(AllocFunction, FreeFunction, ZeroFunction, CopyFunction,
DebugFunction, NULL, &Parser);
+
+ //
+ // translate usage pages
+ //
+ return HidParser_TranslateUsageAndPagesToI8042ScanCodes(Parser, UsageListLength,
KeyAction, ModifierState, InsertCodesProcedure, InsertCodesContext);
+}
+
+
+
+HIDAPI
+NTSTATUS
+NTAPI
HidP_GetButtonCaps(
HIDP_REPORT_TYPE ReportType,
PHIDP_BUTTON_CAPS ButtonCaps,
@@ -491,22 +522,6 @@
HIDAPI
NTSTATUS
NTAPI
-HidP_TranslateUsageAndPagesToI8042ScanCodes(
- IN PUSAGE_AND_PAGE ChangedUsageList,
- IN ULONG UsageListLength,
- IN HIDP_KEYBOARD_DIRECTION KeyAction,
- IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
- IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
- IN PVOID InsertCodesContext)
-{
- UNIMPLEMENTED
- ASSERT(FALSE);
- return STATUS_NOT_IMPLEMENTED;
-}
-
-HIDAPI
-NTSTATUS
-NTAPI
HidP_SetUsages(
IN HIDP_REPORT_TYPE ReportType,
IN USAGE UsagePage,
Modified: branches/usb-bringup/lib/drivers/hidparser/api.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/lib/drivers/hidpars…
==============================================================================
--- branches/usb-bringup/lib/drivers/hidparser/api.c [iso-8859-1] (original)
+++ branches/usb-bringup/lib/drivers/hidparser/api.c [iso-8859-1] Sat Jan 7 10:24:10
2012
@@ -11,6 +11,27 @@
#include "parser.h"
+static ULONG KeyboardScanCodes[256] =
+{
+ 0, 0, 0, 0, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38,
+ 50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 2, 3,
+ 4, 5, 6, 7, 8, 9, 10, 11, 28, 1, 14, 15, 57, 12, 13, 26,
+ 27, 43, 43, 39, 40, 41, 51, 52, 53, 58, 59, 60, 61, 62, 63, 64,
+ 65, 66, 67, 68, 87, 88, 99, 70,119,110,102,104,111,107,109,106,
+ 105,108,103, 69, 98, 55, 74, 78, 96, 79, 80, 81, 75, 76, 77, 71,
+ 72, 73, 82, 83, 86,127,116,117,183,184,185,186,187,188,189,190,
+ 191,192,193,194,134,138,130,132,128,129,131,137,133,135,136,113,
+ 115,114, 0, 0, 0,121, 0, 89, 93,124, 92, 94, 95, 0, 0, 0,
+ 122,123, 90, 91, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 29, 42, 56,125, 97, 54,100,126,164,166,165,163,161,115,114,113,
+ 150,158,159,128,136,177,178,176,142,152,173,140
+};
+
+
ULONG
HidParser_NumberOfTopCollections(
@@ -951,3 +972,106 @@
//
return HIDPARSER_STATUS_USAGE_NOT_FOUND;
}
+
+ULONG
+HidParser_GetScanCode(
+ IN USAGE Usage)
+{
+ if (Usage < sizeof(KeyboardScanCodes) / sizeof(KeyboardScanCodes[0]))
+ {
+ //
+ // valid usage
+ //
+ return KeyboardScanCodes[Usage];
+ }
+
+ //
+ // invalid usage
+ //
+ return 0;
+}
+
+VOID
+HidParser_DispatchKey(
+ IN PCHAR ScanCodes,
+ IN HIDP_KEYBOARD_DIRECTION KeyAction,
+ IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
+ IN PVOID InsertCodesContext)
+{
+ ULONG Index;
+ ULONG Length = 0;
+
+ //
+ // count code length
+ //
+ for(Index = 0; Index < sizeof(ULONG); Index++)
+ {
+ if (ScanCodes[Index] == 0)
+ {
+ //
+ // last scan code
+ //
+ break;
+ }
+
+ //
+ // is this a key break
+ //
+ if (KeyAction == HidP_KeyboardBreak)
+ {
+ //
+ // add break
+ //
+ ScanCodes[Index] |= KEY_BREAK;
+ }
+
+ //
+ // more scan counts
+ //
+ Length++;
+ }
+
+ if (Length > 0)
+ {
+ //
+ // dispatch scan codes
+ //
+ InsertCodesProcedure(InsertCodesContext, ScanCodes, Length);
+ }
+}
+
+
+HIDPARSER_STATUS
+HidParser_TranslateUsage(
+ IN PHID_PARSER Parser,
+ IN USAGE Usage,
+ IN HIDP_KEYBOARD_DIRECTION KeyAction,
+ IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
+ IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
+ IN PVOID InsertCodesContext)
+{
+ ULONG ScanCode;
+
+ //
+ // get scan code
+ //
+ ScanCode = HidParser_GetScanCode(Usage);
+ if (!ScanCode)
+ {
+ //
+ // invalid lookup or no scan code available
+ //
+ return HIDPARSER_STATUS_I8042_TRANS_UNKNOWN;
+ }
+
+ //
+ // FIXME: translate modifier states
+ //
+
+ HidParser_DispatchKey((PCHAR)&ScanCode, KeyAction, InsertCodesProcedure,
InsertCodesContext);
+
+ //
+ // done
+ //
+ return HIDPARSER_STATUS_SUCCESS;
+}
Modified: branches/usb-bringup/lib/drivers/hidparser/hidparser.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/lib/drivers/hidpars…
==============================================================================
--- branches/usb-bringup/lib/drivers/hidparser/hidparser.c [iso-8859-1] (original)
+++ branches/usb-bringup/lib/drivers/hidparser/hidparser.c [iso-8859-1] Sat Jan 7
10:24:10 2012
@@ -14,8 +14,29 @@
TranslateHidParserStatus(
IN HIDPARSER_STATUS Status)
{
- UNIMPLEMENTED
- return STATUS_NOT_IMPLEMENTED;
+ switch(Status)
+ {
+ case HIDPARSER_STATUS_INSUFFICIENT_RESOURCES:
+ return HIDP_STATUS_INTERNAL_ERROR;
+ case HIDPARSER_STATUS_NOT_IMPLEMENTED:
+ return HIDP_STATUS_NOT_IMPLEMENTED;
+ case HIDPARSER_STATUS_REPORT_NOT_FOUND:
+ return HIDP_STATUS_REPORT_DOES_NOT_EXIST;
+ case HIDPARSER_STATUS_INVALID_REPORT_LENGTH:
+ return HIDP_STATUS_INVALID_REPORT_LENGTH;
+ case HIDPARSER_STATUS_INVALID_REPORT_TYPE:
+ return HIDP_STATUS_INVALID_REPORT_TYPE;
+ case HIDPARSER_STATUS_BUFFER_TOO_SMALL:
+ return HIDP_STATUS_BUFFER_TOO_SMALL;
+ case HIDPARSER_STATUS_USAGE_NOT_FOUND:
+ return HIDP_STATUS_USAGE_NOT_FOUND;
+ case HIDPARSER_STATUS_I8042_TRANS_UNKNOWN:
+ return HIDP_STATUS_I8042_TRANS_UNKNOWN;
+ case HIDPARSER_STATUS_COLLECTION_NOT_FOUND:
+ return HIDP_STATUS_NOT_IMPLEMENTED; //FIXME
+ }
+ DPRINT1("TranslateHidParserStatus Status %ld not implemented\n", Status);
+ return HIDP_STATUS_NOT_IMPLEMENTED;
}
NTSTATUS
@@ -631,6 +652,77 @@
//
return TranslateHidParserStatus(ParserStatus);
}
+
+HIDAPI
+NTSTATUS
+NTAPI
+HidParser_TranslateUsageAndPagesToI8042ScanCodes(
+ IN PHID_PARSER Parser,
+ IN PUSAGE_AND_PAGE ChangedUsageList,
+ IN ULONG UsageListLength,
+ IN HIDP_KEYBOARD_DIRECTION KeyAction,
+ IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
+ IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
+ IN PVOID InsertCodesContext)
+{
+ ULONG Index;
+ HIDPARSER_STATUS Status = HIDPARSER_STATUS_SUCCESS;
+
+ for(Index = 0; Index < UsageListLength; Index++)
+ {
+ //
+ // check current usage
+ //
+ if (ChangedUsageList[Index].UsagePage == HID_USAGE_PAGE_KEYBOARD)
+ {
+ //
+ // process usage
+ //
+ Status = HidParser_TranslateUsage(Parser, ChangedUsageList[Index].Usage,
KeyAction, ModifierState, InsertCodesProcedure, InsertCodesContext);
+ }
+ else if (ChangedUsageList[Index].UsagePage == HID_USAGE_PAGE_CONSUMER)
+ {
+ //
+ // FIXME: implement me
+ //
+ UNIMPLEMENTED
+ Status = HIDPARSER_STATUS_NOT_IMPLEMENTED;
+ }
+ else
+ {
+ //
+ // invalid page
+ //
+ DPRINT1("[HIDPARSE] Error unexpected usage page %x\n",
ChangedUsageList[Index].UsagePage);
+ return HIDP_STATUS_I8042_TRANS_UNKNOWN;
+ }
+
+ //
+ // check status
+ //
+ if (Status != HIDPARSER_STATUS_SUCCESS)
+ {
+ //
+ // failed
+ //
+ return TranslateHidParserStatus(Status);
+ }
+ }
+
+ if (Status != HIDPARSER_STATUS_SUCCESS)
+ {
+ //
+ // failed
+ //
+ return TranslateHidParserStatus(Status);
+ }
+
+ //
+ // done
+ //
+ return HIDP_STATUS_SUCCESS;
+}
+
HIDAPI
NTSTATUS
@@ -937,22 +1029,6 @@
HIDAPI
NTSTATUS
NTAPI
-HidParser_TranslateUsageAndPagesToI8042ScanCodes(
- IN PUSAGE_AND_PAGE ChangedUsageList,
- IN ULONG UsageListLength,
- IN HIDP_KEYBOARD_DIRECTION KeyAction,
- IN OUT PHIDP_KEYBOARD_MODIFIER_STATE ModifierState,
- IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
- IN PVOID InsertCodesContext)
-{
- UNIMPLEMENTED
- ASSERT(FALSE);
- return STATUS_NOT_IMPLEMENTED;
-}
-
-HIDAPI
-NTSTATUS
-NTAPI
HidParser_SetUsages(
IN HIDP_REPORT_TYPE ReportType,
IN USAGE UsagePage,
Modified: branches/usb-bringup/lib/drivers/hidparser/hidparser.h
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup/lib/drivers/hidpars…
==============================================================================
--- branches/usb-bringup/lib/drivers/hidparser/hidparser.h [iso-8859-1] (original)
+++ branches/usb-bringup/lib/drivers/hidparser/hidparser.h [iso-8859-1] Sat Jan 7
10:24:10 2012
@@ -44,7 +44,8 @@
HIDPARSER_STATUS_INVALID_REPORT_LENGTH = -5,
HIDPARSER_STATUS_INVALID_REPORT_TYPE = -6,
HIDPARSER_STATUS_BUFFER_TOO_SMALL = -7,
- HIDPARSER_STATUS_USAGE_NOT_FOUND = 8
+ HIDPARSER_STATUS_USAGE_NOT_FOUND = -8,
+ HIDPARSER_STATUS_I8042_TRANS_UNKNOWN = -9
}HIDPARSER_STATUS_CODES;
typedef struct