Author: janderwald
Date: Tue Jan 31 19:00:45 2012
New Revision: 55357
URL:
http://svn.reactos.org/svn/reactos?rev=55357&view=rev
Log:
[HIDPARSE]
- Implement HidP_GetUsagesEx
- HidP_GetUsagesEx uses HidP_GetUsages with undefined usage page
- Required for hid usb support
- Check if there is a maximum set. In that case verify if a usage maximum has been set and
apply it to the currnt usage. Fixes asserts while usb composite device installation
(keyboard)
Modified:
branches/usb-bringup-trunk/lib/drivers/hidparser/api.c
branches/usb-bringup-trunk/lib/drivers/hidparser/parser.c
Modified: branches/usb-bringup-trunk/lib/drivers/hidparser/api.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/lib/drivers/h…
==============================================================================
--- branches/usb-bringup-trunk/lib/drivers/hidparser/api.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/lib/drivers/hidparser/api.c [iso-8859-1] Tue Jan 31
19:00:45 2012
@@ -345,6 +345,7 @@
PHID_REPORT_ITEM ReportItem;
UCHAR Activated;
ULONG Data;
+ PUSAGE_AND_PAGE UsageAndPage = NULL;
//
// get report
@@ -366,6 +367,17 @@
return HIDPARSER_STATUS_INVALID_REPORT_LENGTH;
}
+ //
+ // cast to usage and page
+ //
+ if (UsagePage == HID_USAGE_PAGE_UNDEFINED)
+ {
+ //
+ // the caller requested any set usages
+ //
+ UsageAndPage = (PUSAGE_AND_PAGE)UsageList;
+ }
+
for(Index = 0; Index < Report->ItemCount; Index++)
{
//
@@ -384,17 +396,20 @@
//
CurrentUsagePage = (ReportItem->UsageMinimum >> 16);
- //
- // does usage match
- //
- if (UsagePage != CurrentUsagePage)
- continue;
+ if (UsagePage != HID_USAGE_PAGE_UNDEFINED)
+ {
+ //
+ // does usage match
+ //
+ if (UsagePage != CurrentUsagePage)
+ continue;
+ }
//
// check if the specified usage is activated
//
ASSERT(ReportItem->ByteOffset < ReportDescriptorLength);
- ASSERT(ReportItem->BitCount < 8);
+ ASSERT(ReportItem->BitCount <= 8);
//
// one extra shift for skipping the prepended report id
@@ -428,10 +443,21 @@
continue;
}
- //
- // store item
- //
- UsageList[ItemCount] = (ReportItem->UsageMinimum & 0xFFFF);
+ if (UsagePage != HID_USAGE_PAGE_UNDEFINED)
+ {
+ //
+ // store item
+ //
+ UsageList[ItemCount] = (ReportItem->UsageMinimum & 0xFFFF);
+ }
+ else
+ {
+ //
+ // store usage and page
+ //
+ UsageAndPage[ItemCount].Usage = (ReportItem->UsageMinimum & 0xFFFF);
+ UsageAndPage[ItemCount].UsagePage = CurrentUsagePage;
+ }
ItemCount++;
}
@@ -443,10 +469,21 @@
return HIDPARSER_STATUS_BUFFER_TOO_SMALL;
}
- //
- // success, clear rest of array
- //
- Parser->Zero(&UsageList[ItemCount], (*UsageLength - ItemCount) *
sizeof(USAGE));
+ if (UsagePage == HID_USAGE_PAGE_UNDEFINED)
+ {
+ //
+ // success, clear rest of array
+ //
+ Parser->Zero(&UsageAndPage[ItemCount], (*UsageLength - ItemCount) *
sizeof(USAGE_AND_PAGE));
+ }
+ else
+ {
+ //
+ // success, clear rest of array
+ //
+ Parser->Zero(&UsageList[ItemCount], (*UsageLength - ItemCount) *
sizeof(USAGE));
+ }
+
//
// store result size
Modified: branches/usb-bringup-trunk/lib/drivers/hidparser/parser.c
URL:
http://svn.reactos.org/svn/reactos/branches/usb-bringup-trunk/lib/drivers/h…
==============================================================================
--- branches/usb-bringup-trunk/lib/drivers/hidparser/parser.c [iso-8859-1] (original)
+++ branches/usb-bringup-trunk/lib/drivers/hidparser/parser.c [iso-8859-1] Tue Jan 31
19:00:45 2012
@@ -535,20 +535,21 @@
// get usage minimum from local state
//
UsageValue = LocalItemState->UsageMinimum;
- ASSERT(LocalItemState->UsageMinimumSet);
- ASSERT(LocalItemState->UsageMaximumSet);
//
// append item index
//
UsageValue.u.Extended += ReportItemIndex;
- if (UsageValue.u.Extended > LocalItemState->UsageMaximum.u.Extended)
+ if (LocalItemState->UsageMaximumSet)
{
- //
- // maximum reached
- //
- UsageValue.u.Extended = LocalItemState->UsageMaximum.u.Extended;
+ if (UsageValue.u.Extended >
LocalItemState->UsageMaximum.u.Extended)
+ {
+ //
+ // maximum reached
+ //
+ UsageValue.u.Extended = LocalItemState->UsageMaximum.u.Extended;
+ }
}
}