Rémi Bernon : hidclass.sys: Factor all HIDP_VALUE_CAPS debug helpers.
Alexandre Julliard
julliard at winehq.org
Mon Jun 7 16:30:36 CDT 2021
Module: wine
Branch: master
Commit: c3d8a9803c9f6263ed56c1ebe1921ea194807bb3
URL: https://source.winehq.org/git/wine.git/?a=commit;h=c3d8a9803c9f6263ed56c1ebe1921ea194807bb3
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Mon Jun 7 11:07:00 2021 +0200
hidclass.sys: Factor all HIDP_VALUE_CAPS debug helpers.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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);
}
More information about the wine-cvs
mailing list