Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hid/hidp.c | 24 +++++++++++------------- dlls/hidclass.sys/descriptor.c | 10 +++++----- include/wine/hid.h | 1 - 3 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index 4532f656008..3cd524d4af0 100644 --- a/dlls/hid/hidp.c +++ b/dlls/hid/hidp.c @@ -278,13 +278,11 @@ 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; return HIDP_STATUS_SUCCESS; } else if (value->NotRange.Usage == Usage) { *element = elems[report->elementIdx + i]; - element->bitCount = elems[report->elementIdx + i].caps.BitSize; return HIDP_STATUS_SUCCESS; } } @@ -294,7 +292,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.BitSize * element->caps.ReportCount);
if ((value & (1 << (bit_count - 1))) && element->caps.BitSize != 1 @@ -332,7 +330,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.BitSize * element.caps.ReportCount, &rawValue); if (rc != HIDP_STATUS_SUCCESS) return rc; *UsageValue = logical_to_physical(sign_extend(rawValue, &element), &element); @@ -357,7 +355,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.BitSize * element.caps.ReportCount, UsageValue); }
return rc; @@ -378,10 +376,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.BitSize || !element.caps.ReportCount) 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.BitSize * element.caps.ReportCount, element.caps.ReportCount, UsageValue, UsageValueByteLength); }
@@ -440,7 +438,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.BitSize * element->caps.ReportCount; k++) { UINT v = 0; NTSTATUS rc = get_report_data((BYTE*)Report, ReportLength, @@ -636,7 +634,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.BitSize * element.caps.ReportCount, UsageValue); }
return rc; @@ -661,7 +659,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.BitSize * element.caps.ReportCount, -1); }
if (rc != HIDP_STATUS_SUCCESS) @@ -865,7 +863,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.BitSize * element->caps.ReportCount; k++) { UINT v = 0; NTSTATUS rc = get_report_data((BYTE*)Report, ReportLength, @@ -948,7 +946,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.BitSize * element->caps.ReportCount; k++) { UINT v = 0; NTSTATUS rc = get_report_data((BYTE*)Report, ReportLength, @@ -972,7 +970,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.BitSize * element->caps.ReportCount, &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..f39552c6228 100644 --- a/dlls/hidclass.sys/descriptor.c +++ b/dlls/hidclass.sys/descriptor.c @@ -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); } @@ -581,7 +581,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; + ULONG index_count, bit_count;
if (!feature->isData) { @@ -598,12 +598,12 @@ static void build_elements(WINE_HID_REPORT *wine_report, WINE_HID_ELEMENT *elems 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; + bit_count = (wine_element->caps.BitSize * wine_element->caps.ReportCount); + wine_report->bitSize += bit_count;
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 = bit_count - 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/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;