Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
This test still seems to timeout very rarely on 32bit, I couldn't reproduce locally though...
dlls/hid/tests/device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/hid/tests/device.c b/dlls/hid/tests/device.c index 3dd22b7f068..6693bc8bf5a 100644 --- a/dlls/hid/tests/device.c +++ b/dlls/hid/tests/device.c @@ -215,7 +215,7 @@ static void process_data(HIDP_CAPS Caps, PHIDP_PREPARSED_DATA ppd, CHAR *data, D status = HidP_GetUsages(HidP_Input, i, 0, button_pages, &usage_length, ppd, data, data_length); ok (status == HIDP_STATUS_SUCCESS || usage_length == 0, "HidP_GetUsages failed (%x) but usage length still %i\n", status, usage_length); - if (usage_length) + if (status == HIDP_STATUS_SUCCESS && usage_length) { CHAR report[50]; int count;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hidclass.sys/descriptor.c | 39 +++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 10 deletions(-)
diff --git a/dlls/hidclass.sys/descriptor.c b/dlls/hidclass.sys/descriptor.c index 9c52dee5fe1..0e0d6a6bf54 100644 --- a/dlls/hidclass.sys/descriptor.c +++ b/dlls/hidclass.sys/descriptor.c @@ -464,7 +464,7 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l { int usages_top = 0; USAGE usages[256]; - unsigned int i; + int i;
for (i = index; i < length;) { @@ -479,6 +479,7 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l { /* Long data items: Should be unused */ ERR("Long Data Item, should be unused\n"); + return -1; } else { @@ -506,7 +507,7 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l case TAG_MAIN_FEATURE: for (j = 0; j < caps->ReportCount; j++) { - feature = calloc(1, sizeof(*feature)); + if (!(feature = calloc(1, sizeof(*feature)))) return -1; list_add_tail(&collection->features, &feature->entry); if (bTag == TAG_MAIN_INPUT) feature->type = HidP_Input; @@ -531,7 +532,8 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l break; case TAG_MAIN_COLLECTION: { - struct collection *subcollection = calloc(1, sizeof(struct collection)); + struct collection *subcollection; + if (!(subcollection = calloc(1, sizeof(struct collection)))) return -1; list_add_tail(&collection->collections, &subcollection->entry); subcollection->parent = collection; /* Only set our collection once... @@ -552,13 +554,14 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l
parse_collection(bSize, itemVal, subcollection);
- i = parse_descriptor(descriptor, i+1, length, feature_index, collection_index, subcollection, caps, stack); + if ((i = parse_descriptor(descriptor, i+1, length, feature_index, collection_index, subcollection, caps, stack)) < 0) return i; continue; } case TAG_MAIN_END_COLLECTION: return i; default: ERR("Unknown (bTag: 0x%x, bType: 0x%x)\n", bTag, bType); + return -1; } } else if (bType == TAG_TYPE_GLOBAL) @@ -597,7 +600,8 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l break; case TAG_GLOBAL_PUSH: { - struct caps_stack *saved = malloc(sizeof(*saved)); + struct caps_stack *saved; + if (!(saved = malloc(sizeof(*saved)))) return -1; saved->caps = *caps; TRACE("Push\n"); list_add_tail(stack, &saved->entry); @@ -617,11 +621,15 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l free(saved); } else + { ERR("Pop but no stack!\n"); + return -1; + } break; } default: ERR("Unknown (bTag: 0x%x, bType: 0x%x)\n", bTag, bType); + return -1; } } else if (bType == TAG_TYPE_LOCAL) @@ -630,7 +638,10 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l { case TAG_LOCAL_USAGE: if (usages_top == sizeof(usages)) + { ERR("More than 256 individual usages defined\n"); + return -1; + } else { usages[usages_top++] = getValue(bSize, itemVal, FALSE); @@ -674,10 +685,14 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l break; default: ERR("Unknown (bTag: 0x%x, bType: 0x%x)\n", bTag, bType); + return -1; } } else + { ERR("Unknown (bTag: 0x%x, bType: 0x%x)\n", bTag, bType); + return -1; + }
i += bSize; } @@ -927,7 +942,7 @@ static WINE_HIDP_PREPARSED_DATA* build_PreparseData(struct collection *base_coll nodes_offset = size; size += node_count * sizeof(WINE_HID_LINK_COLLECTION_NODE);
- data = calloc(1, size); + if (!(data = calloc(1, size))) return NULL; data->magic = HID_MAGIC; data->dwSize = size; data->caps.Usage = base_collection->caps.NotRange.Usage; @@ -982,14 +997,18 @@ WINE_HIDP_PREPARSED_DATA* ParseDescriptor(BYTE *descriptor, unsigned int length)
list_init(&caps_stack);
- base = calloc(1, sizeof(*base)); + if (!(base = calloc(1, sizeof(*base)))) return NULL; base->index = 1; list_init(&base->features); list_init(&base->collections); memset(&caps, 0, sizeof(caps));
cidx = 0; - parse_descriptor(descriptor, 0, length, &feature_count, &cidx, base, &caps, &caps_stack); + if (parse_descriptor(descriptor, 0, length, &feature_count, &cidx, base, &caps, &caps_stack) < 0) + { + free_collection(base); + return NULL; + }
debug_collection(base);
@@ -1004,8 +1023,8 @@ WINE_HIDP_PREPARSED_DATA* ParseDescriptor(BYTE *descriptor, unsigned int length) } }
- data = build_PreparseData(base, cidx); - debug_print_preparsed(data); + if ((data = build_PreparseData(base, cidx))) + debug_print_preparsed(data); free_collection(base);
return data;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hidclass.sys/descriptor.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/dlls/hidclass.sys/descriptor.c b/dlls/hidclass.sys/descriptor.c index 0e0d6a6bf54..ec559f67f5f 100644 --- a/dlls/hidclass.sys/descriptor.c +++ b/dlls/hidclass.sys/descriptor.c @@ -122,8 +122,6 @@ struct caps { USHORT Reserved3; } NotRange; } DUMMYUNIONNAME; - - int Delim; };
struct feature { @@ -200,7 +198,7 @@ static void debugstr_caps(const char* type, struct caps *caps) return; TRACE("(%s Caps: UsagePage 0x%x; LogicalMin %i; LogicalMax %i; PhysicalMin %i; " "PhysicalMax %i; UnitsExp %i; Units %i; BitSize %i; ReportID %i; ReportCount %i; " - "Usage %s; StringIndex %s; DesignatorIndex %s; Delim %i;)\n", + "Usage %s; StringIndex %s; DesignatorIndex %s;)\n", type, caps->UsagePage, caps->LogicalMin, @@ -214,8 +212,7 @@ static void debugstr_caps(const char* type, struct caps *caps) caps->ReportCount, debugstr_usages(caps), debugstr_stringindex(caps), - debugstr_designatorindex(caps), - caps->Delim); + debugstr_designatorindex(caps)); }
static void debug_feature(struct feature *feature) @@ -681,8 +678,8 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l caps->IsStringRange = TRUE; break; case TAG_LOCAL_DELIMITER: - caps->Delim = getValue(bSize, itemVal, FALSE); - break; + FIXME("delimiter %d not implemented!\n", itemVal); + return -1; default: ERR("Unknown (bTag: 0x%x, bType: 0x%x)\n", bTag, bType); return -1;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hidclass.sys/descriptor.c | 160 +++++++-------------------------- 1 file changed, 31 insertions(+), 129 deletions(-)
diff --git a/dlls/hidclass.sys/descriptor.c b/dlls/hidclass.sys/descriptor.c index ec559f67f5f..869d1dc1a85 100644 --- a/dlls/hidclass.sys/descriptor.c +++ b/dlls/hidclass.sys/descriptor.c @@ -89,44 +89,9 @@ enum { static const char* const feature_string[] = { "Input", "Output", "Feature" };
-struct caps { - USAGE UsagePage; - LONG LogicalMin; - LONG LogicalMax; - LONG PhysicalMin; - LONG PhysicalMax; - ULONG UnitsExp; - ULONG Units; - USHORT BitSize; - UCHAR ReportID; - USHORT ReportCount; - - BOOLEAN IsRange; - BOOLEAN IsStringRange; - BOOLEAN IsDesignatorRange; - union { - struct { - USAGE UsageMin; - USAGE UsageMax; - USHORT StringMin; - USHORT StringMax; - USHORT DesignatorMin; - USHORT DesignatorMax; - } Range; - struct { - USHORT Usage; - USAGE Reserved1; - USHORT StringIndex; - USHORT Reserved2; - USHORT DesignatorIndex; - USHORT Reserved3; - } NotRange; - } DUMMYUNIONNAME; -}; - struct feature { struct list entry; - struct caps caps; + HIDP_VALUE_CAPS caps;
HIDP_REPORT_TYPE type; BOOLEAN isData; @@ -155,7 +120,7 @@ static const char* const collection_string[] = {
struct collection { struct list entry; - struct caps caps; + HIDP_VALUE_CAPS caps; unsigned int index; unsigned int type; struct collection *parent; @@ -165,10 +130,10 @@ struct collection {
struct caps_stack { struct list entry; - struct caps caps; + HIDP_VALUE_CAPS caps; };
-static const char* debugstr_usages(struct caps *caps) +static const char* debugstr_usages(HIDP_VALUE_CAPS *caps) { if (!caps->IsRange) return wine_dbg_sprintf("[0x%x]", caps->NotRange.Usage); @@ -176,7 +141,7 @@ static const char* debugstr_usages(struct caps *caps) return wine_dbg_sprintf("[0x%x - 0x%x]", caps->Range.UsageMin, caps->Range.UsageMax); }
-static const char* debugstr_stringindex(struct caps *caps) +static const char* debugstr_stringindex(HIDP_VALUE_CAPS *caps) { if (!caps->IsStringRange) return wine_dbg_sprintf("%i", caps->NotRange.StringIndex); @@ -184,7 +149,7 @@ static const char* debugstr_stringindex(struct caps *caps) return wine_dbg_sprintf("[%i - %i]", caps->Range.StringMin, caps->Range.StringMax); }
-static const char* debugstr_designatorindex(struct caps *caps) +static const char* debugstr_designatorindex(HIDP_VALUE_CAPS *caps) { if (!caps->IsDesignatorRange) return wine_dbg_sprintf("%i", caps->NotRange.DesignatorIndex); @@ -192,7 +157,7 @@ static const char* debugstr_designatorindex(struct caps *caps) return wine_dbg_sprintf("[%i - %i]", caps->Range.DesignatorMin, caps->Range.DesignatorMax); }
-static void debugstr_caps(const char* type, struct caps *caps) +static void debugstr_caps(const char* type, HIDP_VALUE_CAPS *caps) { if (!caps) return; @@ -446,7 +411,7 @@ static void parse_collection(unsigned int bSize, int itemVal, } }
-static void new_caps(struct caps *caps) +static void new_caps(HIDP_VALUE_CAPS *caps) { caps->IsRange = 0; caps->IsStringRange = 0; @@ -456,7 +421,7 @@ static void new_caps(struct caps *caps)
static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int length, unsigned int *feature_index, unsigned int *collection_index, - struct collection *collection, struct caps *caps, + struct collection *collection, HIDP_VALUE_CAPS *caps, struct list *stack) { int usages_top = 0; @@ -701,6 +666,7 @@ static void build_elements(WINE_HID_REPORT *wine_report, WINE_HID_ELEMENT *elems struct feature* feature, USHORT *data_index) { WINE_HID_ELEMENT *wine_element = elems + wine_report->elementIdx + wine_report->elementCount; + ULONG index_count;
if (!feature->isData) { @@ -713,95 +679,31 @@ static void build_elements(WINE_HID_REPORT *wine_report, WINE_HID_ELEMENT *elems wine_element->bitCount = (feature->caps.BitSize * feature->caps.ReportCount); wine_report->bitSize += wine_element->bitCount;
- if (feature->caps.BitSize == 1) + wine_element->caps = feature->caps; + wine_element->caps.BitField = feature->BitField; + wine_element->caps.LinkCollection = feature->collection->index; + wine_element->caps.LinkUsage = feature->collection->caps.NotRange.Usage; + wine_element->caps.LinkUsagePage = feature->collection->caps.UsagePage; + wine_element->caps.IsAbsolute = feature->IsAbsolute; + wine_element->caps.HasNull = feature->HasNull; + + if (wine_element->caps.IsRange) { - wine_element->ElementType = ButtonElement; - wine_element->caps.UsagePage = feature->caps.UsagePage; - wine_element->caps.ReportID = feature->caps.ReportID; - wine_element->caps.BitField = feature->BitField; - wine_element->caps.LinkCollection = feature->collection->index; - wine_element->caps.LinkUsage = feature->collection->caps.NotRange.Usage; - wine_element->caps.LinkUsagePage = feature->collection->caps.UsagePage; - wine_element->caps.IsRange = feature->caps.IsRange; - wine_element->caps.IsStringRange = feature->caps.IsStringRange; - wine_element->caps.IsDesignatorRange = feature->caps.IsDesignatorRange; - wine_element->caps.IsAbsolute = feature->IsAbsolute; - if (wine_element->caps.IsRange) - { - wine_element->caps.Range.UsageMin = feature->caps.Range.UsageMin; - wine_element->caps.Range.UsageMax = feature->caps.Range.UsageMax; - wine_element->caps.Range.StringMin = feature->caps.Range.StringMin; - wine_element->caps.Range.StringMax = feature->caps.Range.StringMax; - wine_element->caps.Range.DesignatorMin = feature->caps.Range.DesignatorMin; - wine_element->caps.Range.DesignatorMax = feature->caps.Range.DesignatorMax; - wine_element->caps.Range.DataIndexMin = *data_index; - wine_element->caps.Range.DataIndexMax = *data_index + wine_element->bitCount - 1; - *data_index = *data_index + wine_element->bitCount; - } - else - { - wine_element->caps.NotRange.Usage = feature->caps.NotRange.Usage; - wine_element->caps.NotRange.Reserved1 = feature->caps.NotRange.Usage; - wine_element->caps.NotRange.StringIndex = feature->caps.NotRange.StringIndex; - wine_element->caps.NotRange.Reserved2 = feature->caps.NotRange.StringIndex; - wine_element->caps.NotRange.DesignatorIndex = feature->caps.NotRange.DesignatorIndex; - wine_element->caps.NotRange.Reserved3 = feature->caps.NotRange.DesignatorIndex; - wine_element->caps.NotRange.DataIndex = *data_index; - wine_element->caps.NotRange.Reserved4 = *data_index; - *data_index = *data_index + 1; - } + if (wine_element->caps.BitSize == 1) index_count = wine_element->bitCount - 1; + else index_count = wine_element->caps.Range.UsageMax - wine_element->caps.Range.UsageMin; + wine_element->caps.Range.DataIndexMin = *data_index; + wine_element->caps.Range.DataIndexMax = *data_index + index_count; + *data_index = *data_index + index_count + 1; } else { - wine_element->ElementType = ValueElement; - wine_element->caps.UsagePage = feature->caps.UsagePage; - wine_element->caps.ReportID = feature->caps.ReportID; - wine_element->caps.BitField = feature->BitField; - wine_element->caps.LinkCollection = feature->collection->index; - wine_element->caps.LinkUsage = feature->collection->caps.NotRange.Usage; - wine_element->caps.LinkUsagePage = feature->collection->caps.UsagePage; - wine_element->caps.IsRange = feature->caps.IsRange; - wine_element->caps.IsStringRange = feature->caps.IsStringRange; - wine_element->caps.IsDesignatorRange = feature->caps.IsDesignatorRange; - wine_element->caps.IsAbsolute = feature->IsAbsolute; - wine_element->caps.HasNull = feature->HasNull; - wine_element->caps.BitSize = feature->caps.BitSize; - wine_element->caps.ReportCount = feature->caps.ReportCount; - wine_element->caps.UnitsExp = feature->caps.UnitsExp; - wine_element->caps.Units = feature->caps.Units; - wine_element->caps.LogicalMin = feature->caps.LogicalMin; - wine_element->caps.LogicalMax = feature->caps.LogicalMax; - wine_element->caps.PhysicalMin = feature->caps.PhysicalMin; - wine_element->caps.PhysicalMax = feature->caps.PhysicalMax; - if (wine_element->caps.IsRange) - { - wine_element->caps.Range.UsageMin = feature->caps.Range.UsageMin; - wine_element->caps.Range.UsageMax = feature->caps.Range.UsageMax; - wine_element->caps.Range.StringMin = feature->caps.Range.StringMin; - wine_element->caps.Range.StringMax = feature->caps.Range.StringMax; - wine_element->caps.Range.DesignatorMin = feature->caps.Range.DesignatorMin; - wine_element->caps.Range.DesignatorMax = feature->caps.Range.DesignatorMax; - wine_element->caps.Range.DataIndexMin = *data_index; - wine_element->caps.Range.DataIndexMax = *data_index + - (wine_element->caps.Range.UsageMax - - wine_element->caps.Range.UsageMin); - *data_index = *data_index + - (wine_element->caps.Range.UsageMax - - wine_element->caps.Range.UsageMin) + 1; - } - else - { - wine_element->caps.NotRange.Usage = feature->caps.NotRange.Usage; - wine_element->caps.NotRange.Reserved1 = feature->caps.NotRange.Usage; - wine_element->caps.NotRange.StringIndex = feature->caps.NotRange.StringIndex; - wine_element->caps.NotRange.Reserved2 = feature->caps.NotRange.StringIndex; - wine_element->caps.NotRange.DesignatorIndex = feature->caps.NotRange.DesignatorIndex; - wine_element->caps.NotRange.Reserved3 = feature->caps.NotRange.DesignatorIndex; - wine_element->caps.NotRange.DataIndex = *data_index; - wine_element->caps.NotRange.Reserved4 = *data_index; - *data_index = *data_index + 1; - } + wine_element->caps.NotRange.DataIndex = *data_index; + wine_element->caps.NotRange.Reserved4 = *data_index; + *data_index = *data_index + 1; } + + if (feature->caps.BitSize == 1) wine_element->ElementType = ButtonElement; + else wine_element->ElementType = ValueElement; wine_report->elementCount++; }
@@ -973,7 +875,7 @@ WINE_HIDP_PREPARSED_DATA* ParseDescriptor(BYTE *descriptor, unsigned int length) { WINE_HIDP_PREPARSED_DATA *data = NULL; struct collection *base; - struct caps caps; + HIDP_VALUE_CAPS caps;
struct list caps_stack;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hidclass.sys/descriptor.c | 113 ++++----------------------------- 1 file changed, 14 insertions(+), 99 deletions(-)
diff --git a/dlls/hidclass.sys/descriptor.c b/dlls/hidclass.sys/descriptor.c index 869d1dc1a85..2585ea2a40e 100644 --- a/dlls/hidclass.sys/descriptor.c +++ b/dlls/hidclass.sys/descriptor.c @@ -133,51 +133,16 @@ struct caps_stack { HIDP_VALUE_CAPS caps; };
-static const char* debugstr_usages(HIDP_VALUE_CAPS *caps) +static inline const char *debugstr_hidp_value_caps( HIDP_VALUE_CAPS *caps ) { - if (!caps->IsRange) - return wine_dbg_sprintf("[0x%x]", caps->NotRange.Usage); - else - return wine_dbg_sprintf("[0x%x - 0x%x]", caps->Range.UsageMin, caps->Range.UsageMax); -} - -static const char* debugstr_stringindex(HIDP_VALUE_CAPS *caps) -{ - if (!caps->IsStringRange) - return wine_dbg_sprintf("%i", caps->NotRange.StringIndex); - else - return wine_dbg_sprintf("[%i - %i]", caps->Range.StringMin, caps->Range.StringMax); -} - -static const char* debugstr_designatorindex(HIDP_VALUE_CAPS *caps) -{ - if (!caps->IsDesignatorRange) - return wine_dbg_sprintf("%i", caps->NotRange.DesignatorIndex); - else - return wine_dbg_sprintf("[%i - %i]", caps->Range.DesignatorMin, caps->Range.DesignatorMax); -} - -static void debugstr_caps(const char* type, HIDP_VALUE_CAPS *caps) -{ - if (!caps) - return; - TRACE("(%s Caps: UsagePage 0x%x; LogicalMin %i; LogicalMax %i; PhysicalMin %i; " - "PhysicalMax %i; UnitsExp %i; Units %i; BitSize %i; ReportID %i; ReportCount %i; " - "Usage %s; StringIndex %s; DesignatorIndex %s;)\n", - type, - caps->UsagePage, - caps->LogicalMin, - caps->LogicalMax, - caps->PhysicalMin, - caps->PhysicalMax, - caps->UnitsExp, - caps->Units, - caps->BitSize, - caps->ReportID, - caps->ReportCount, - debugstr_usages(caps), - debugstr_stringindex(caps), - debugstr_designatorindex(caps)); + if (!caps) return "(null)"; + return wine_dbg_sprintf( "RId %d, Usg %02x:%02x-%02x Dat %02x-%02x (%d), Str %d-%d (%d), Des %d-%d (%d), " + "Bits %02x, Als %d, Abs %d, Nul %d, LCol %d LUsg %02x:%02x, BitSz %d, RCnt %d, " + "Unit %x E%+d, Log %+d-%+d, Phy %+d-%+d", + caps->ReportID, caps->UsagePage, caps->Range.UsageMin, caps->Range.UsageMax, caps->Range.DataIndexMin, caps->Range.DataIndexMax, caps->IsRange, + caps->Range.StringMin, caps->Range.StringMax, caps->IsStringRange, caps->Range.DesignatorMin, caps->Range.DesignatorMax, caps->IsDesignatorRange, + caps->BitField, caps->IsAlias, caps->IsAbsolute, caps->HasNull, caps->LinkCollection, caps->LinkUsagePage, caps->LinkUsage, caps->BitSize, caps->ReportCount, + caps->Units, caps->UnitsExp, caps->LogicalMin, caps->LogicalMax, caps->PhysicalMin, caps->PhysicalMax ); }
static void debug_feature(struct feature *feature) @@ -197,7 +162,7 @@ static void debug_feature(struct feature *feature) (feature->Volatile)?"Volatile":"NonVolatile", (feature->BitField)?"BitField":"Buffered");
- debugstr_caps("Feature", &feature->caps); + TRACE("Feature %s\n", debugstr_hidp_value_caps(&feature->caps)); }
static void debug_collection(struct collection *collection) @@ -209,7 +174,7 @@ static void debug_collection(struct collection *collection) TRACE("START Collection %i <<< %s, parent: %p, %i features, %i collections\n", collection->index, collection_string[collection->type], collection->parent, list_count(&collection->features), list_count(&collection->collections)); - debugstr_caps("Collection", &collection->caps); + TRACE("Collection %s\n", debugstr_hidp_value_caps(&collection->caps)); LIST_FOR_EACH_ENTRY(fentry, &collection->features, struct feature, entry) debug_feature(fentry); LIST_FOR_EACH_ENTRY(centry, &collection->collections, struct collection, entry) @@ -218,61 +183,10 @@ static void debug_collection(struct collection *collection) } }
-static void debug_print_button_cap(const CHAR * type, WINE_HID_ELEMENT *wine_element) -{ - if (!wine_element->caps.IsRange) - TRACE("%s Button: 0x%x/0x%04x: ReportId %i, startBit %i/1\n" , type, - wine_element->caps.UsagePage, - wine_element->caps.NotRange.Usage, - wine_element->caps.ReportID, - wine_element->valueStartBit); - else - TRACE("%s Button: 0x%x/[0x%04x-0x%04x]: ReportId %i, startBit %i/%i\n" ,type, - wine_element->caps.UsagePage, - wine_element->caps.Range.UsageMin, - wine_element->caps.Range.UsageMax, - wine_element->caps.ReportID, - wine_element->valueStartBit, - wine_element->bitCount); -} - -static void debug_print_value_cap(const CHAR * type, WINE_HID_ELEMENT *wine_element) -{ - TRACE("%s Value: 0x%x/0x%x: ReportId %i, IsAbsolute %i, HasNull %i, " - "Bit Size %i, ReportCount %i, UnitsExp %i, Units %i, " - "LogicalMin %i, Logical Max %i, PhysicalMin %i, " - "PhysicalMax %i -- StartBit %i/%i\n", type, - wine_element->caps.UsagePage, - wine_element->caps.NotRange.Usage, - wine_element->caps.ReportID, - wine_element->caps.IsAbsolute, - wine_element->caps.HasNull, - wine_element->caps.BitSize, - wine_element->caps.ReportCount, - wine_element->caps.UnitsExp, - wine_element->caps.Units, - wine_element->caps.LogicalMin, - wine_element->caps.LogicalMax, - wine_element->caps.PhysicalMin, - wine_element->caps.PhysicalMax, - wine_element->valueStartBit, - wine_element->bitCount); -} - -static void debug_print_element(const CHAR* type, WINE_HID_ELEMENT *wine_element) -{ - if (wine_element->ElementType == ButtonElement) - debug_print_button_cap(type, wine_element); - else if (wine_element->ElementType == ValueElement) - debug_print_value_cap(type, wine_element); - else - TRACE("%s: UNKNOWN\n", type); -} - static void debug_print_report(const char* type, WINE_HIDP_PREPARSED_DATA *data, WINE_HID_REPORT *report) { - WINE_HID_ELEMENT *elem = HID_ELEMS(data); + WINE_HID_ELEMENT *elems = HID_ELEMS(data); unsigned int i; TRACE("START Report %i <<< %s report : bitSize: %i elementCount: %i\n", report->reportID, @@ -281,7 +195,8 @@ static void debug_print_report(const char* type, WINE_HIDP_PREPARSED_DATA *data, report->elementCount); for (i = 0; i < report->elementCount; i++) { - debug_print_element(type, &elem[report->elementIdx + i]); + WINE_HID_ELEMENT *elem = elems + report->elementIdx + i; + TRACE("%s: %s, StartBit %d, BitCount %d\n", type, debugstr_hidp_value_caps(&elem->caps), elem->valueStartBit, elem->bitCount); } TRACE(">>> END Report %i\n",report->reportID); }
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hid/hidp.c | 36 +++++++++++++++++----------------- dlls/hidclass.sys/descriptor.c | 2 -- include/wine/hid.h | 7 ------- 3 files changed, 18 insertions(+), 27 deletions(-)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index 92c1442d048..a7003717a21 100644 --- a/dlls/hid/hidp.c +++ b/dlls/hid/hidp.c @@ -203,7 +203,7 @@ NTSTATUS WINAPI HidP_GetButtonCaps(HIDP_REPORT_TYPE ReportType, PHIDP_BUTTON_CAP { for (i = 0; i < report[j].elementCount && u < b_count; i++) { - if (elems[report[j].elementIdx + i].ElementType == ButtonElement) + if (elems[report[j].elementIdx + i].caps.BitSize == 1) ButtonCaps[u++] = *(HIDP_BUTTON_CAPS *)&elems[report[j].elementIdx + i].caps; } } @@ -230,7 +230,7 @@ NTSTATUS WINAPI HidP_GetCaps(PHIDP_PREPARSED_DATA PreparsedData,
static NTSTATUS find_usage(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT LinkCollection, USAGE Usage, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, - WINE_ELEMENT_TYPE ElementType, WINE_HID_ELEMENT *element) + USHORT bit_size, WINE_HID_ELEMENT *element) { PWINE_HIDP_PREPARSED_DATA data = (PWINE_HIDP_PREPARSED_DATA)PreparsedData; WINE_HID_ELEMENT *elems = HID_ELEMS(data); @@ -270,7 +270,7 @@ static NTSTATUS find_usage(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT { HIDP_VALUE_CAPS *value = &elems[report->elementIdx + i].caps;
- if (elems[report->elementIdx + i].ElementType != ElementType || + if ((elems[report->elementIdx + i].caps.BitSize == 1) != (bit_size == 1) || value->UsagePage != UsagePage) continue;
@@ -278,13 +278,13 @@ static NTSTATUS find_usage(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT { *element = elems[report->elementIdx + i]; element->valueStartBit += value->BitSize * (Usage - value->Range.UsageMin); - element->bitCount = elems[report->elementIdx + i].ElementType == ValueElement ? value->BitSize: 1; + element->bitCount = elems[report->elementIdx + i].caps.BitSize; return HIDP_STATUS_SUCCESS; } else if (value->NotRange.Usage == Usage) { *element = elems[report->elementIdx + i]; - element->bitCount = elems[report->elementIdx + i].ElementType == ValueElement ? value->BitSize : 1; + element->bitCount = elems[report->elementIdx + i].caps.BitSize; return HIDP_STATUS_SUCCESS; } } @@ -297,7 +297,7 @@ static LONG sign_extend(ULONG value, const WINE_HID_ELEMENT *element) UINT bit_count = element->bitCount;
if ((value & (1 << (bit_count - 1))) - && element->ElementType == ValueElement + && element->caps.BitSize != 1 && element->caps.LogicalMin < 0) { value -= (1 << bit_count); @@ -326,7 +326,7 @@ NTSTATUS WINAPI HidP_GetScaledUsageValue(HIDP_REPORT_TYPE ReportType, USAGE Usag TRACE("(%i, %x, %i, %i, %p, %p, %p, %i)\n", ReportType, UsagePage, LinkCollection, Usage, UsageValue, PreparsedData, Report, ReportLength);
- rc = find_usage(ReportType, UsagePage, LinkCollection, Usage, PreparsedData, Report, ValueElement, &element); + rc = find_usage(ReportType, UsagePage, LinkCollection, Usage, PreparsedData, Report, 0, &element);
if (rc == HIDP_STATUS_SUCCESS) { @@ -352,7 +352,7 @@ NTSTATUS WINAPI HidP_GetUsageValue(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, TRACE("(%i, %x, %i, %i, %p, %p, %p, %i)\n", ReportType, UsagePage, LinkCollection, Usage, UsageValue, PreparsedData, Report, ReportLength);
- rc = find_usage(ReportType, UsagePage, LinkCollection, Usage, PreparsedData, Report, ValueElement, &element); + rc = find_usage(ReportType, UsagePage, LinkCollection, Usage, PreparsedData, Report, 0, &element);
if (rc == HIDP_STATUS_SUCCESS) { @@ -374,7 +374,7 @@ NTSTATUS WINAPI HidP_GetUsageValueArray(HIDP_REPORT_TYPE ReportType, USAGE Usage TRACE("(%i, %x, %i, %i, %p, %u, %p, %p, %i)\n", ReportType, UsagePage, LinkCollection, Usage, UsageValue, UsageValueByteLength, PreparsedData, Report, ReportLength);
- rc = find_usage(ReportType, UsagePage, LinkCollection, Usage, PreparsedData, Report, ValueElement, &element); + rc = find_usage(ReportType, UsagePage, LinkCollection, Usage, PreparsedData, Report, 0, &element);
if (rc == HIDP_STATUS_SUCCESS) { @@ -435,7 +435,7 @@ NTSTATUS WINAPI HidP_GetUsages(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USH uCount = 0; for (i = 0; i < report->elementCount && uCount < *UsageLength; i++) { - if (elems[report->elementIdx + i].ElementType == ButtonElement && + if (elems[report->elementIdx + i].caps.BitSize == 1 && elems[report->elementIdx + i].caps.UsagePage == UsagePage) { int k; @@ -514,7 +514,7 @@ NTSTATUS WINAPI HidP_GetValueCaps(HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS { for (i = 0; i < report[j].elementCount && u < v_count; i++) { - if (elems[report[j].elementIdx + i].ElementType == ValueElement) + if (elems[report[j].elementIdx + i].caps.BitSize != 1) ValueCaps[u++] = elems[report[j].elementIdx + i].caps; } } @@ -607,7 +607,7 @@ ULONG WINAPI HidP_MaxUsageListLength(HIDP_REPORT_TYPE ReportType, USAGE UsagePag int j; for (j = 0; j < report[i].elementCount; j++) { - if (elems[report[i].elementIdx + j].ElementType == ButtonElement && + if (elems[report[i].elementIdx + j].caps.BitSize == 1 && (UsagePage == 0 || elems[report[i].elementIdx + j].caps.UsagePage == UsagePage)) { if (elems[report[i].elementIdx + j].caps.IsRange) @@ -631,7 +631,7 @@ NTSTATUS WINAPI HidP_SetUsageValue(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, TRACE("(%i, %x, %i, %i, %i, %p, %p, %i)\n", ReportType, UsagePage, LinkCollection, Usage, UsageValue, PreparsedData, Report, ReportLength);
- rc = find_usage(ReportType, UsagePage, LinkCollection, Usage, PreparsedData, Report, ValueElement, &element); + rc = find_usage(ReportType, UsagePage, LinkCollection, Usage, PreparsedData, Report, 0, &element);
if (rc == HIDP_STATUS_SUCCESS) { @@ -657,7 +657,7 @@ NTSTATUS WINAPI HidP_SetUsages(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USH for (i = 0; i < *UsageLength; i++) { rc = find_usage(ReportType, UsagePage, LinkCollection, - UsageList[i], PreparsedData, Report, ButtonElement, &element); + UsageList[i], PreparsedData, Report, 1, &element); if (rc == HIDP_STATUS_SUCCESS) { rc = set_report_data((BYTE*)Report, ReportLength, @@ -734,7 +734,7 @@ NTSTATUS WINAPI HidP_GetSpecificButtonCaps(HIDP_REPORT_TYPE ReportType, { for (i = 0; i < report[j].elementCount && u < b_count; i++) { - if (elems[report[j].elementIdx + i].ElementType == ButtonElement && + if (elems[report[j].elementIdx + i].caps.BitSize == 1 && (UsagePage == 0 || UsagePage == elems[report[j].elementIdx + i].caps.UsagePage) && (LinkCollection == 0 || LinkCollection == elems[report[j].elementIdx + i].caps.LinkCollection) && (Usage == 0 || ( @@ -804,7 +804,7 @@ NTSTATUS WINAPI HidP_GetSpecificValueCaps(HIDP_REPORT_TYPE ReportType, { for (i = 0; i < report[j].elementCount && u < v_count; i++) { - if (elems[report[j].elementIdx + i].ElementType == ValueElement && + if (elems[report[j].elementIdx + i].caps.BitSize != 1 && (UsagePage == 0 || UsagePage == elems[report[j].elementIdx + i].caps.UsagePage) && (LinkCollection == 0 || LinkCollection == elems[report[j].elementIdx + i].caps.LinkCollection) && (Usage == 0 || Usage == elems[report[j].elementIdx + i].caps.NotRange.Usage)) @@ -861,7 +861,7 @@ NTSTATUS WINAPI HidP_GetUsagesEx(HIDP_REPORT_TYPE ReportType, USHORT LinkCollect
for (i = 0; i < report->elementCount; i++) { - if (elems[report->elementIdx + i].ElementType == ButtonElement) + if (elems[report->elementIdx + i].caps.BitSize == 1) { int k; WINE_HID_ELEMENT *element = &elems[report->elementIdx + i]; @@ -945,7 +945,7 @@ NTSTATUS WINAPI HidP_GetData(HIDP_REPORT_TYPE ReportType, HIDP_DATA *DataList, U for (i = 0; i < report->elementCount; i++) { WINE_HID_ELEMENT *element = &elems[report->elementIdx + i]; - if (element->ElementType == ButtonElement) + if (element->caps.BitSize == 1) { int k; for (k=0; k < element->bitCount; k++) diff --git a/dlls/hidclass.sys/descriptor.c b/dlls/hidclass.sys/descriptor.c index 2585ea2a40e..9364400275a 100644 --- a/dlls/hidclass.sys/descriptor.c +++ b/dlls/hidclass.sys/descriptor.c @@ -617,8 +617,6 @@ static void build_elements(WINE_HID_REPORT *wine_report, WINE_HID_ELEMENT *elems *data_index = *data_index + 1; }
- if (feature->caps.BitSize == 1) wine_element->ElementType = ButtonElement; - else wine_element->ElementType = ValueElement; wine_report->elementCount++; }
diff --git a/include/wine/hid.h b/include/wine/hid.h index 38d84bc96af..cfb4f389eb9 100644 --- a/include/wine/hid.h +++ b/include/wine/hid.h @@ -31,15 +31,8 @@
#define HID_MAGIC 0x8491759
-typedef enum __WINE_ELEMENT_TYPE { - UnknownElement = 0, - ButtonElement, - ValueElement, -} WINE_ELEMENT_TYPE; - typedef struct __WINE_ELEMENT { - WINE_ELEMENT_TYPE ElementType; UINT valueStartBit; UINT bitCount; HIDP_VALUE_CAPS caps;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=92010
Your paranoid android.
=== debiant2 (32 bit report) ===
hid: device: Timeout