The bit count should not be required as there's already BitSize and ReportCount, but the code currently requires it. I'll be removed later.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hid/hidp.c | 26 +++++++++++++------------- dlls/hidclass.sys/descriptor.c | 15 +++++++-------- include/ddk/hidpi.h | 3 ++- include/wine/hid.h | 1 - 4 files changed, 22 insertions(+), 23 deletions(-)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index 4532f656008..66c1dbab89b 100644 --- a/dlls/hid/hidp.c +++ b/dlls/hid/hidp.c @@ -278,13 +278,13 @@ static NTSTATUS find_usage(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT { *element = elems[report->elementIdx + i]; element->caps.StartBit += value->BitSize * (Usage - value->Range.UsageMin); - element->bitCount = elems[report->elementIdx + i].caps.BitSize; + element->caps.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].caps.BitSize; + element->caps.BitCount = elems[report->elementIdx + i].caps.BitSize; return HIDP_STATUS_SUCCESS; } } @@ -294,7 +294,7 @@ static NTSTATUS find_usage(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT
static LONG sign_extend(ULONG value, const WINE_HID_ELEMENT *element) { - UINT bit_count = element->bitCount; + UINT bit_count = element->caps.BitCount;
if ((value & (1 << (bit_count - 1))) && element->caps.BitSize != 1 @@ -332,7 +332,7 @@ NTSTATUS WINAPI HidP_GetScaledUsageValue(HIDP_REPORT_TYPE ReportType, USAGE Usag { ULONG rawValue; rc = get_report_data((BYTE*)Report, ReportLength, - element.caps.StartBit, element.bitCount, &rawValue); + element.caps.StartBit, element.caps.BitCount, &rawValue); if (rc != HIDP_STATUS_SUCCESS) return rc; *UsageValue = logical_to_physical(sign_extend(rawValue, &element), &element); @@ -357,7 +357,7 @@ NTSTATUS WINAPI HidP_GetUsageValue(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, if (rc == HIDP_STATUS_SUCCESS) { return get_report_data((BYTE*)Report, ReportLength, - element.caps.StartBit, element.bitCount, UsageValue); + element.caps.StartBit, element.caps.BitCount, UsageValue); }
return rc; @@ -378,10 +378,10 @@ NTSTATUS WINAPI HidP_GetUsageValueArray(HIDP_REPORT_TYPE ReportType, USAGE Usage
if (rc == HIDP_STATUS_SUCCESS) { - if (element.caps.IsRange || element.caps.ReportCount <= 1 || !element.bitCount) + if (element.caps.IsRange || element.caps.ReportCount <= 1 || !element.caps.BitCount) return HIDP_STATUS_NOT_VALUE_ARRAY;
- return get_report_data_array((BYTE*)Report, ReportLength, element.caps.StartBit, element.bitCount, + return get_report_data_array((BYTE*)Report, ReportLength, element.caps.StartBit, element.caps.BitCount, element.caps.ReportCount, UsageValue, UsageValueByteLength); }
@@ -440,7 +440,7 @@ NTSTATUS WINAPI HidP_GetUsages(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USH { int k; WINE_HID_ELEMENT *element = &elems[report->elementIdx + i]; - for (k=0; k < element->bitCount; k++) + for (k=0; k < element->caps.BitCount; k++) { UINT v = 0; NTSTATUS rc = get_report_data((BYTE*)Report, ReportLength, @@ -636,7 +636,7 @@ NTSTATUS WINAPI HidP_SetUsageValue(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, if (rc == HIDP_STATUS_SUCCESS) { return set_report_data((BYTE*)Report, ReportLength, - element.caps.StartBit, element.bitCount, UsageValue); + element.caps.StartBit, element.caps.BitCount, UsageValue); }
return rc; @@ -661,7 +661,7 @@ NTSTATUS WINAPI HidP_SetUsages(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USH if (rc == HIDP_STATUS_SUCCESS) { rc = set_report_data((BYTE*)Report, ReportLength, - element.caps.StartBit, element.bitCount, -1); + element.caps.StartBit, element.caps.BitCount, -1); }
if (rc != HIDP_STATUS_SUCCESS) @@ -865,7 +865,7 @@ NTSTATUS WINAPI HidP_GetUsagesEx(HIDP_REPORT_TYPE ReportType, USHORT LinkCollect { int k; WINE_HID_ELEMENT *element = &elems[report->elementIdx + i]; - for (k=0; k < element->bitCount; k++) + for (k=0; k < element->caps.BitCount; k++) { UINT v = 0; NTSTATUS rc = get_report_data((BYTE*)Report, ReportLength, @@ -948,7 +948,7 @@ NTSTATUS WINAPI HidP_GetData(HIDP_REPORT_TYPE ReportType, HIDP_DATA *DataList, U if (element->caps.BitSize == 1) { int k; - for (k=0; k < element->bitCount; k++) + for (k=0; k < element->caps.BitCount; k++) { UINT v = 0; NTSTATUS rc = get_report_data((BYTE*)Report, ReportLength, @@ -972,7 +972,7 @@ NTSTATUS WINAPI HidP_GetData(HIDP_REPORT_TYPE ReportType, HIDP_DATA *DataList, U { UINT v; NTSTATUS rc = get_report_data((BYTE*)Report, ReportLength, - element->caps.StartBit, element->bitCount, &v); + element->caps.StartBit, element->caps.BitCount, &v); if (rc != HIDP_STATUS_SUCCESS) return rc; DataList[uCount].DataIndex = element->caps.NotRange.DataIndex; diff --git a/dlls/hidclass.sys/descriptor.c b/dlls/hidclass.sys/descriptor.c index 9cf6f311fca..dfb612550ee 100644 --- a/dlls/hidclass.sys/descriptor.c +++ b/dlls/hidclass.sys/descriptor.c @@ -137,12 +137,12 @@ static inline const char *debugstr_hidp_value_caps( HIDP_VALUE_CAPS *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, BitStrt %d, BitSz %d, RCnt %d, " - "Unit %x E%+d, Log %+d-%+d, Phy %+d-%+d", + "Bits %02x, Als %d, Abs %d, Nul %d, LCol %d LUsg %02x:%02x, BitStrt %d, BitCnt %d, " + "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->StartBit, - caps->BitSize, caps->ReportCount, caps->Units, caps->UnitsExp, caps->LogicalMin, caps->LogicalMax, caps->PhysicalMin, caps->PhysicalMax ); + caps->BitCount, caps->BitSize, caps->ReportCount, caps->Units, caps->UnitsExp, caps->LogicalMin, caps->LogicalMax, caps->PhysicalMin, caps->PhysicalMax ); }
static void debug_feature(struct feature *feature) @@ -196,7 +196,7 @@ static void debug_print_report(const char* type, WINE_HIDP_PREPARSED_DATA *data, for (i = 0; i < report->elementCount; i++) { WINE_HID_ELEMENT *elem = elems + report->elementIdx + i; - TRACE("%s: %s, BitCount %d\n", type, debugstr_hidp_value_caps(&elem->caps), elem->bitCount); + TRACE("%s: %s\n", type, debugstr_hidp_value_caps(&elem->caps)); } TRACE(">>> END Report %i\n",report->reportID); } @@ -597,13 +597,12 @@ static void build_elements(WINE_HID_REPORT *wine_report, WINE_HID_ELEMENT *elems wine_element->caps.IsAbsolute = feature->IsAbsolute; wine_element->caps.HasNull = feature->HasNull; wine_element->caps.StartBit = wine_report->bitSize; - - wine_element->bitCount = (wine_element->caps.BitSize * wine_element->caps.ReportCount); - wine_report->bitSize += wine_element->bitCount; + wine_element->caps.BitCount = (wine_element->caps.BitSize * wine_element->caps.ReportCount); + wine_report->bitSize += wine_element->caps.BitCount;
if (wine_element->caps.IsRange) { - if (wine_element->caps.BitSize == 1) index_count = wine_element->bitCount - 1; + if (wine_element->caps.BitSize == 1) index_count = wine_element->caps.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; diff --git a/include/ddk/hidpi.h b/include/ddk/hidpi.h index 9da84f38531..cdbe3d2810a 100644 --- a/include/ddk/hidpi.h +++ b/include/ddk/hidpi.h @@ -84,8 +84,9 @@ typedef struct _HIDP_VALUE_CAPS USHORT BitSize; USHORT ReportCount; #ifdef __WINESRC__ - USHORT Reserved2[3]; + USHORT Reserved2[1]; ULONG StartBit; + ULONG BitCount; #else USHORT Reserved2[5]; #endif diff --git a/include/wine/hid.h b/include/wine/hid.h index 0c0d3fdca99..9528e598022 100644 --- a/include/wine/hid.h +++ b/include/wine/hid.h @@ -33,7 +33,6 @@
typedef struct __WINE_ELEMENT { - UINT bitCount; HIDP_VALUE_CAPS caps; } WINE_HID_ELEMENT;