mirror of
https://github.com/reactos/reactos.git
synced 2024-07-31 08:39:05 +00:00
[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) svn path=/branches/usb-bringup-trunk/; revision=55357
This commit is contained in:
parent
3bb6d463d3
commit
d0cec1a401
|
@ -345,6 +345,7 @@ HidParser_GetUsagesWithReport(
|
||||||
PHID_REPORT_ITEM ReportItem;
|
PHID_REPORT_ITEM ReportItem;
|
||||||
UCHAR Activated;
|
UCHAR Activated;
|
||||||
ULONG Data;
|
ULONG Data;
|
||||||
|
PUSAGE_AND_PAGE UsageAndPage = NULL;
|
||||||
|
|
||||||
//
|
//
|
||||||
// get report
|
// get report
|
||||||
|
@ -366,6 +367,17 @@ HidParser_GetUsagesWithReport(
|
||||||
return HIDPARSER_STATUS_INVALID_REPORT_LENGTH;
|
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++)
|
for(Index = 0; Index < Report->ItemCount; Index++)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
@ -384,17 +396,20 @@ HidParser_GetUsagesWithReport(
|
||||||
//
|
//
|
||||||
CurrentUsagePage = (ReportItem->UsageMinimum >> 16);
|
CurrentUsagePage = (ReportItem->UsageMinimum >> 16);
|
||||||
|
|
||||||
//
|
if (UsagePage != HID_USAGE_PAGE_UNDEFINED)
|
||||||
// does usage match
|
{
|
||||||
//
|
//
|
||||||
if (UsagePage != CurrentUsagePage)
|
// does usage match
|
||||||
continue;
|
//
|
||||||
|
if (UsagePage != CurrentUsagePage)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// check if the specified usage is activated
|
// check if the specified usage is activated
|
||||||
//
|
//
|
||||||
ASSERT(ReportItem->ByteOffset < ReportDescriptorLength);
|
ASSERT(ReportItem->ByteOffset < ReportDescriptorLength);
|
||||||
ASSERT(ReportItem->BitCount < 8);
|
ASSERT(ReportItem->BitCount <= 8);
|
||||||
|
|
||||||
//
|
//
|
||||||
// one extra shift for skipping the prepended report id
|
// one extra shift for skipping the prepended report id
|
||||||
|
@ -428,10 +443,21 @@ HidParser_GetUsagesWithReport(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
if (UsagePage != HID_USAGE_PAGE_UNDEFINED)
|
||||||
// store item
|
{
|
||||||
//
|
//
|
||||||
UsageList[ItemCount] = (ReportItem->UsageMinimum & 0xFFFF);
|
// store item
|
||||||
|
//
|
||||||
|
UsageList[ItemCount] = (ReportItem->UsageMinimum & 0xFFFF);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// store usage and page
|
||||||
|
//
|
||||||
|
UsageAndPage[ItemCount].Usage = (ReportItem->UsageMinimum & 0xFFFF);
|
||||||
|
UsageAndPage[ItemCount].UsagePage = CurrentUsagePage;
|
||||||
|
}
|
||||||
ItemCount++;
|
ItemCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -443,10 +469,21 @@ HidParser_GetUsagesWithReport(
|
||||||
return HIDPARSER_STATUS_BUFFER_TOO_SMALL;
|
return HIDPARSER_STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
if (UsagePage == HID_USAGE_PAGE_UNDEFINED)
|
||||||
// success, clear rest of array
|
{
|
||||||
//
|
//
|
||||||
Parser->Zero(&UsageList[ItemCount], (*UsageLength - ItemCount) * sizeof(USAGE));
|
// 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
|
// store result size
|
||||||
|
|
|
@ -535,20 +535,21 @@ HidParser_InitReportItem(
|
||||||
// get usage minimum from local state
|
// get usage minimum from local state
|
||||||
//
|
//
|
||||||
UsageValue = LocalItemState->UsageMinimum;
|
UsageValue = LocalItemState->UsageMinimum;
|
||||||
ASSERT(LocalItemState->UsageMinimumSet);
|
|
||||||
ASSERT(LocalItemState->UsageMaximumSet);
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// append item index
|
// append item index
|
||||||
//
|
//
|
||||||
UsageValue.u.Extended += ReportItemIndex;
|
UsageValue.u.Extended += ReportItemIndex;
|
||||||
|
|
||||||
if (UsageValue.u.Extended > LocalItemState->UsageMaximum.u.Extended)
|
if (LocalItemState->UsageMaximumSet)
|
||||||
{
|
{
|
||||||
//
|
if (UsageValue.u.Extended > LocalItemState->UsageMaximum.u.Extended)
|
||||||
// maximum reached
|
{
|
||||||
//
|
//
|
||||||
UsageValue.u.Extended = LocalItemState->UsageMaximum.u.Extended;
|
// maximum reached
|
||||||
|
//
|
||||||
|
UsageValue.u.Extended = LocalItemState->UsageMaximum.u.Extended;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue