Do the usage preprocessing also for collections. While the collection handles
the conversion, it makes it easier to do it for all items the same. This fixes the missing initialization of the usage stack as pointed out by caz_haiku in #7354, thanks for the pointer! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40953 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
6391a79957
commit
baba9584dd
@ -103,6 +103,32 @@ HIDParser::ParseReportDescriptor(const uint8 *reportDescriptor,
|
||||
switch (item->type) {
|
||||
case ITEM_TYPE_MAIN:
|
||||
{
|
||||
// preprocess the local state if relevant (usages for
|
||||
// collections and report items)
|
||||
if (item->tag != ITEM_TAG_MAIN_END_COLLECTION) {
|
||||
// make all usages extended for easier later processing
|
||||
for (uint32 i = 0; i < usageStackUsed; i++) {
|
||||
if (usageStack[i].is_extended)
|
||||
continue;
|
||||
usageStack[i].u.s.usage_page = globalState.usage_page;
|
||||
usageStack[i].is_extended = true;
|
||||
}
|
||||
|
||||
if (!localState.usage_minimum.is_extended) {
|
||||
// the specs say if one of them is extended they must
|
||||
// both be extended, so if the minimum isn't, the
|
||||
// maximum mustn't either.
|
||||
localState.usage_minimum.u.s.usage_page
|
||||
= localState.usage_maximum.u.s.usage_page
|
||||
= globalState.usage_page;
|
||||
localState.usage_minimum.is_extended
|
||||
= localState.usage_maximum.is_extended = true;
|
||||
}
|
||||
|
||||
localState.usage_stack = usageStack;
|
||||
localState.usage_stack_used = usageStackUsed;
|
||||
}
|
||||
|
||||
if (item->tag == ITEM_TAG_MAIN_COLLECTION) {
|
||||
HIDCollection *newCollection
|
||||
= new(std::nothrow) HIDCollection(collection,
|
||||
@ -154,28 +180,6 @@ HIDParser::ParseReportDescriptor(const uint8 *reportDescriptor,
|
||||
if (target == NULL)
|
||||
break;
|
||||
|
||||
// make all usages extended for easier later processing
|
||||
for (uint32 i = 0; i < usageStackUsed; i++) {
|
||||
if (usageStack[i].is_extended)
|
||||
continue;
|
||||
usageStack[i].u.s.usage_page = globalState.usage_page;
|
||||
usageStack[i].is_extended = true;
|
||||
}
|
||||
|
||||
if (!localState.usage_minimum.is_extended) {
|
||||
// the specs say if one of them is extended they must
|
||||
// both be extended, so if the minimum isn't, the
|
||||
// maximum mustn't either.
|
||||
localState.usage_minimum.u.s.usage_page
|
||||
= localState.usage_maximum.u.s.usage_page
|
||||
= globalState.usage_page;
|
||||
localState.usage_minimum.is_extended
|
||||
= localState.usage_maximum.is_extended = true;
|
||||
}
|
||||
|
||||
localState.usage_stack = usageStack;
|
||||
localState.usage_stack_used = usageStackUsed;
|
||||
|
||||
// fill in a sensible default if the index isn't set
|
||||
if (!localState.designator_index_set) {
|
||||
localState.designator_index
|
||||
|
Loading…
Reference in New Issue
Block a user