Author: rharabien
Date: Mon Mar 5 19:58:43 2012
New Revision: 56053
URL:
http://svn.reactos.org/svn/reactos?rev=56053&view=rev
Log:
[HIDPARSER]
- Implement translating customer page to scan-codes
Modified:
trunk/reactos/lib/drivers/hidparser/api.c
trunk/reactos/lib/drivers/hidparser/hidparser.c
trunk/reactos/lib/drivers/hidparser/hidparser.h
Modified: trunk/reactos/lib/drivers/hidparser/api.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/hidparser/api.…
==============================================================================
--- trunk/reactos/lib/drivers/hidparser/api.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/hidparser/api.c [iso-8859-1] Mon Mar 5 19:58:43 2012
@@ -31,6 +31,32 @@
/* F */ 0x0096, 0x009e, 0x009f, 0x0080, 0x0088, 0x00b1, 0x00b2, 0x00b0, 0x008e, 0x0098,
0x00ad, 0x008c, 0x0000, 0x0000, 0x0000, 0x0000,
};
+static struct
+{
+ USAGE Usage;
+ ULONG ScanCode;
+} CustomerScanCodes[] =
+{
+ { 0x00B5, 0xE019 },
+ { 0x00B6, 0xE010 },
+ { 0x00B7, 0xE024 },
+ { 0x00CD, 0xE022 },
+ { 0x00E2, 0xE020 },
+ { 0x00E9, 0xE030 },
+ { 0x00EA, 0xE02E },
+ { 0x0183, 0xE06D },
+ { 0x018A, 0xE06C },
+ { 0x0192, 0xE021 },
+ { 0x0194, 0xE06B },
+ { 0x0221, 0xE065 },
+ { 0x0223, 0xE032 },
+ { 0x0224, 0xE06A },
+ { 0x0225, 0xE069 },
+ { 0x0226, 0xE068 },
+ { 0x0227, 0xE067 },
+ { 0x022A, 0xE066 },
+};
+
#define NTOHS(n) (((((unsigned short)(n) & 0xFF)) << 8) | (((unsigned short)(n)
& 0xFF00) >> 8))
HIDPARSER_STATUS
@@ -646,7 +672,7 @@
}
ULONG
-HidParser_GetScanCode(
+HidParser_GetScanCodeFromKbdUsage(
IN USAGE Usage)
{
if (Usage < sizeof(KeyboardScanCodes) / sizeof(KeyboardScanCodes[0]))
@@ -655,6 +681,33 @@
// valid usage
//
return KeyboardScanCodes[Usage];
+ }
+
+ //
+ // invalid usage
+ //
+ return 0;
+}
+
+ULONG
+HidParser_GetScanCodeFromCustUsage(
+ IN USAGE Usage)
+{
+ ULONG i;
+
+ //
+ // find usage in array
+ //
+ for (i = 0; i < sizeof(CustomerScanCodes) / sizeof(CustomerScanCodes[0]); ++i)
+ {
+ if (CustomerScanCodes[i].Usage == Usage)
+ {
+ //
+ // valid usage
+ //
+ return CustomerScanCodes[i].ScanCode;
+ }
+
}
//
@@ -712,9 +765,8 @@
}
}
-
HIDPARSER_STATUS
-HidParser_TranslateUsage(
+HidParser_TranslateKbdUsage(
IN PHID_PARSER Parser,
IN USAGE Usage,
IN HIDP_KEYBOARD_DIRECTION KeyAction,
@@ -729,7 +781,7 @@
//
// get scan code
//
- ScanCode = HidParser_GetScanCode(Usage);
+ ScanCode = HidParser_GetScanCodeFromKbdUsage(Usage);
if (!ScanCode)
{
//
@@ -775,3 +827,46 @@
//
return HIDPARSER_STATUS_SUCCESS;
}
+
+HIDPARSER_STATUS
+HidParser_TranslateCustUsage(
+ 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_GetScanCodeFromCustUsage(Usage);
+ if (!ScanCode)
+ {
+ //
+ // invalid lookup or no scan code available
+ //
+ DPRINT1("No Scan code for Usage %x\n", Usage);
+ return HIDPARSER_STATUS_I8042_TRANS_UNKNOWN;
+ }
+
+ if (ScanCode & 0xFF00)
+ {
+ //
+ // swap scan code
+ //
+ ScanCode = NTOHS(ScanCode);
+ }
+
+ //
+ // FIXME: translate modifier states
+ //
+ HidParser_DispatchKey((PCHAR)&ScanCode, KeyAction, InsertCodesProcedure,
InsertCodesContext);
+
+ //
+ // done
+ //
+ return HIDPARSER_STATUS_SUCCESS;
+}
Modified: trunk/reactos/lib/drivers/hidparser/hidparser.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/hidparser/hidp…
==============================================================================
--- trunk/reactos/lib/drivers/hidparser/hidparser.c [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/hidparser/hidparser.c [iso-8859-1] Mon Mar 5 19:58:43 2012
@@ -681,17 +681,16 @@
if (ChangedUsageList[Index].UsagePage == HID_USAGE_PAGE_KEYBOARD)
{
//
- // process usage
+ // process keyboard usage
//
- Status = HidParser_TranslateUsage(Parser, ChangedUsageList[Index].Usage,
KeyAction, ModifierState, InsertCodesProcedure, InsertCodesContext);
+ Status = HidParser_TranslateKbdUsage(Parser, ChangedUsageList[Index].Usage,
KeyAction, ModifierState, InsertCodesProcedure, InsertCodesContext);
}
else if (ChangedUsageList[Index].UsagePage == HID_USAGE_PAGE_CONSUMER)
{
//
- // FIXME: implement me
+ // process consumer usage
//
- UNIMPLEMENTED
- Status = HIDPARSER_STATUS_NOT_IMPLEMENTED;
+ Status = HidParser_TranslateCustUsage(Parser, ChangedUsageList[Index].Usage,
KeyAction, ModifierState, InsertCodesProcedure, InsertCodesContext);
}
else
{
Modified: trunk/reactos/lib/drivers/hidparser/hidparser.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/drivers/hidparser/hidp…
==============================================================================
--- trunk/reactos/lib/drivers/hidparser/hidparser.h [iso-8859-1] (original)
+++ trunk/reactos/lib/drivers/hidparser/hidparser.h [iso-8859-1] Mon Mar 5 19:58:43 2012
@@ -430,7 +430,7 @@
IN ULONG ReportLength);
HIDPARSER_STATUS
-HidParser_TranslateUsage(
+HidParser_TranslateKbdUsage(
IN PHID_PARSER Parser,
IN USAGE Usage,
IN HIDP_KEYBOARD_DIRECTION KeyAction,
@@ -438,6 +438,15 @@
IN PHIDP_INSERT_SCANCODES InsertCodesProcedure,
IN PVOID InsertCodesContext);
+HIDPARSER_STATUS
+HidParser_TranslateCustUsage(
+ 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);
+
HIDAPI
NTSTATUS
NTAPI