It's only going to be used for internal HID preparsed data, to save a custom struct.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com ---
v3: Should really be no-op, add a BitCount in the Reserved2 fields for now, but we'll drop it later.
Supersedes: 207499-207501
dlls/hid/hidp.c | 20 ++++++++++---------- dlls/hidclass.sys/descriptor.c | 17 ++++++++--------- include/ddk/hidpi.h | 5 +++++ include/wine/hid.h | 1 - 4 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index 2933c2ff7ef..4532f656008 100644 --- a/dlls/hid/hidp.c +++ b/dlls/hid/hidp.c @@ -277,7 +277,7 @@ static NTSTATUS find_usage(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT if (value->IsRange && value->Range.UsageMin <= Usage && Usage <= value->Range.UsageMax) { *element = elems[report->elementIdx + i]; - element->valueStartBit += value->BitSize * (Usage - value->Range.UsageMin); + element->caps.StartBit += value->BitSize * (Usage - value->Range.UsageMin); element->bitCount = elems[report->elementIdx + i].caps.BitSize; return HIDP_STATUS_SUCCESS; } @@ -332,7 +332,7 @@ NTSTATUS WINAPI HidP_GetScaledUsageValue(HIDP_REPORT_TYPE ReportType, USAGE Usag { ULONG rawValue; rc = get_report_data((BYTE*)Report, ReportLength, - element.valueStartBit, element.bitCount, &rawValue); + element.caps.StartBit, element.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.valueStartBit, element.bitCount, UsageValue); + element.caps.StartBit, element.bitCount, UsageValue); }
return rc; @@ -381,7 +381,7 @@ NTSTATUS WINAPI HidP_GetUsageValueArray(HIDP_REPORT_TYPE ReportType, USAGE Usage if (element.caps.IsRange || element.caps.ReportCount <= 1 || !element.bitCount) return HIDP_STATUS_NOT_VALUE_ARRAY;
- return get_report_data_array((BYTE*)Report, ReportLength, element.valueStartBit, element.bitCount, + return get_report_data_array((BYTE*)Report, ReportLength, element.caps.StartBit, element.bitCount, element.caps.ReportCount, UsageValue, UsageValueByteLength); }
@@ -444,7 +444,7 @@ NTSTATUS WINAPI HidP_GetUsages(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USH { UINT v = 0; NTSTATUS rc = get_report_data((BYTE*)Report, ReportLength, - element->valueStartBit + k, 1, &v); + element->caps.StartBit + k, 1, &v); if (rc != HIDP_STATUS_SUCCESS) return rc; found = TRUE; @@ -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.valueStartBit, element.bitCount, UsageValue); + element.caps.StartBit, element.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.valueStartBit, element.bitCount, -1); + element.caps.StartBit, element.bitCount, -1); }
if (rc != HIDP_STATUS_SUCCESS) @@ -869,7 +869,7 @@ NTSTATUS WINAPI HidP_GetUsagesEx(HIDP_REPORT_TYPE ReportType, USHORT LinkCollect { UINT v = 0; NTSTATUS rc = get_report_data((BYTE*)Report, ReportLength, - element->valueStartBit + k, 1, &v); + element->caps.StartBit + k, 1, &v); if (rc != HIDP_STATUS_SUCCESS) return rc; if (v) @@ -952,7 +952,7 @@ NTSTATUS WINAPI HidP_GetData(HIDP_REPORT_TYPE ReportType, HIDP_DATA *DataList, U { UINT v = 0; NTSTATUS rc = get_report_data((BYTE*)Report, ReportLength, - element->valueStartBit + k, 1, &v); + element->caps.StartBit + k, 1, &v); if (rc != HIDP_STATUS_SUCCESS) return rc; if (v) @@ -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->valueStartBit, element->bitCount, &v); + element->caps.StartBit, element->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 65c2f9aadae..9cf6f311fca 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, BitSz %d, RCnt %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", 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 ); + 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 ); }
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, StartBit %d, BitCount %d\n", type, debugstr_hidp_value_caps(&elem->caps), elem->valueStartBit, elem->bitCount); + TRACE("%s: %s, BitCount %d\n", type, debugstr_hidp_value_caps(&elem->caps), elem->bitCount); } TRACE(">>> END Report %i\n",report->reportID); } @@ -589,11 +589,6 @@ static void build_elements(WINE_HID_REPORT *wine_report, WINE_HID_ELEMENT *elems return; }
- wine_element->valueStartBit = wine_report->bitSize; - - wine_element->bitCount = (feature->caps.BitSize * feature->caps.ReportCount); - wine_report->bitSize += wine_element->bitCount; - wine_element->caps = feature->caps; wine_element->caps.BitField = feature->BitField; wine_element->caps.LinkCollection = feature->collection->index; @@ -601,6 +596,10 @@ static void build_elements(WINE_HID_REPORT *wine_report, WINE_HID_ELEMENT *elems wine_element->caps.LinkUsagePage = feature->collection->caps.UsagePage; 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;
if (wine_element->caps.IsRange) { diff --git a/include/ddk/hidpi.h b/include/ddk/hidpi.h index fb497f3282f..9da84f38531 100644 --- a/include/ddk/hidpi.h +++ b/include/ddk/hidpi.h @@ -83,7 +83,12 @@ typedef struct _HIDP_VALUE_CAPS UCHAR Reserved; USHORT BitSize; USHORT ReportCount; +#ifdef __WINESRC__ + USHORT Reserved2[3]; + ULONG StartBit; +#else USHORT Reserved2[5]; +#endif ULONG UnitsExp; ULONG Units; LONG LogicalMin; diff --git a/include/wine/hid.h b/include/wine/hid.h index cfb4f389eb9..0c0d3fdca99 100644 --- a/include/wine/hid.h +++ b/include/wine/hid.h @@ -33,7 +33,6 @@
typedef struct __WINE_ELEMENT { - UINT valueStartBit; UINT bitCount; HIDP_VALUE_CAPS caps; } WINE_HID_ELEMENT;
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;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hid/hidp.c | 158 ++++++++++++++++----------------- dlls/hidclass.sys/descriptor.c | 50 +++++------ include/wine/hid.h | 7 +- 3 files changed, 105 insertions(+), 110 deletions(-)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index 66c1dbab89b..60274c79ac0 100644 --- a/dlls/hid/hidp.c +++ b/dlls/hid/hidp.c @@ -161,7 +161,7 @@ NTSTATUS WINAPI HidP_GetButtonCaps(HIDP_REPORT_TYPE ReportType, PHIDP_BUTTON_CAP PUSHORT ButtonCapsLength, PHIDP_PREPARSED_DATA PreparsedData) { PWINE_HIDP_PREPARSED_DATA data = (PWINE_HIDP_PREPARSED_DATA)PreparsedData; - WINE_HID_ELEMENT *elems = HID_ELEMS(data); + HIDP_VALUE_CAPS *elems = HID_ELEMS(data); WINE_HID_REPORT *report = NULL; USHORT b_count = 0, r_count = 0; int i,j,u; @@ -203,8 +203,8 @@ 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].caps.BitSize == 1) - ButtonCaps[u++] = *(HIDP_BUTTON_CAPS *)&elems[report[j].elementIdx + i].caps; + if (elems[report[j].elementIdx + i].BitSize == 1) + ButtonCaps[u++] = *(HIDP_BUTTON_CAPS *)&elems[report[j].elementIdx + i]; } }
@@ -230,10 +230,10 @@ 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, - USHORT bit_size, WINE_HID_ELEMENT *element) + USHORT bit_size, HIDP_VALUE_CAPS *element) { PWINE_HIDP_PREPARSED_DATA data = (PWINE_HIDP_PREPARSED_DATA)PreparsedData; - WINE_HID_ELEMENT *elems = HID_ELEMS(data); + HIDP_VALUE_CAPS *elems = HID_ELEMS(data); WINE_HID_REPORT *report = NULL; USHORT v_count = 0, r_count = 0; int i; @@ -268,23 +268,23 @@ static NTSTATUS find_usage(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT
for (i = 0; i < report->elementCount; i++) { - HIDP_VALUE_CAPS *value = &elems[report->elementIdx + i].caps; + HIDP_VALUE_CAPS *value = &elems[report->elementIdx + i];
- if ((elems[report->elementIdx + i].caps.BitSize == 1) != (bit_size == 1) || + if ((elems[report->elementIdx + i].BitSize == 1) != (bit_size == 1) || value->UsagePage != UsagePage) continue;
if (value->IsRange && value->Range.UsageMin <= Usage && Usage <= value->Range.UsageMax) { *element = elems[report->elementIdx + i]; - element->caps.StartBit += value->BitSize * (Usage - value->Range.UsageMin); - element->caps.BitCount = elems[report->elementIdx + i].caps.BitSize; + element->StartBit += value->BitSize * (Usage - value->Range.UsageMin); + element->BitCount = elems[report->elementIdx + i].BitSize; return HIDP_STATUS_SUCCESS; } else if (value->NotRange.Usage == Usage) { *element = elems[report->elementIdx + i]; - element->caps.BitCount = elems[report->elementIdx + i].caps.BitSize; + element->BitCount = elems[report->elementIdx + i].BitSize; return HIDP_STATUS_SUCCESS; } } @@ -292,27 +292,27 @@ static NTSTATUS find_usage(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USHORT return HIDP_STATUS_USAGE_NOT_FOUND; }
-static LONG sign_extend(ULONG value, const WINE_HID_ELEMENT *element) +static LONG sign_extend(ULONG value, const HIDP_VALUE_CAPS *element) { - UINT bit_count = element->caps.BitCount; + UINT bit_count = element->BitCount;
if ((value & (1 << (bit_count - 1))) - && element->caps.BitSize != 1 - && element->caps.LogicalMin < 0) + && element->BitSize != 1 + && element->LogicalMin < 0) { value -= (1 << bit_count); } return value; }
-static LONG logical_to_physical(LONG value, const WINE_HID_ELEMENT *element) +static LONG logical_to_physical(LONG value, const HIDP_VALUE_CAPS *element) { - if (element->caps.PhysicalMin || element->caps.PhysicalMax) + if (element->PhysicalMin || element->PhysicalMax) { - value = (((ULONGLONG)(value - element->caps.LogicalMin) - * (element->caps.PhysicalMax - element->caps.PhysicalMin)) - / (element->caps.LogicalMax - element->caps.LogicalMin)) - + element->caps.PhysicalMin; + value = (((ULONGLONG)(value - element->LogicalMin) + * (element->PhysicalMax - element->PhysicalMin)) + / (element->LogicalMax - element->LogicalMin)) + + element->PhysicalMin; } return value; } @@ -322,7 +322,7 @@ NTSTATUS WINAPI HidP_GetScaledUsageValue(HIDP_REPORT_TYPE ReportType, USAGE Usag PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength) { NTSTATUS rc; - WINE_HID_ELEMENT element; + HIDP_VALUE_CAPS element; TRACE("(%i, %x, %i, %i, %p, %p, %p, %i)\n", ReportType, UsagePage, LinkCollection, Usage, UsageValue, PreparsedData, Report, ReportLength);
@@ -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.caps.BitCount, &rawValue); + element.StartBit, element.BitCount, &rawValue); if (rc != HIDP_STATUS_SUCCESS) return rc; *UsageValue = logical_to_physical(sign_extend(rawValue, &element), &element); @@ -346,7 +346,7 @@ NTSTATUS WINAPI HidP_GetUsageValue(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USAGE Usage, PULONG UsageValue, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength) { - WINE_HID_ELEMENT element; + HIDP_VALUE_CAPS element; NTSTATUS rc;
TRACE("(%i, %x, %i, %i, %p, %p, %p, %i)\n", ReportType, UsagePage, LinkCollection, Usage, UsageValue, @@ -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.caps.BitCount, UsageValue); + element.StartBit, element.BitCount, UsageValue); }
return rc; @@ -368,7 +368,7 @@ NTSTATUS WINAPI HidP_GetUsageValueArray(HIDP_REPORT_TYPE ReportType, USAGE Usage USAGE Usage, PCHAR UsageValue, USHORT UsageValueByteLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength) { - WINE_HID_ELEMENT element; + HIDP_VALUE_CAPS element; NTSTATUS rc;
TRACE("(%i, %x, %i, %i, %p, %u, %p, %p, %i)\n", ReportType, UsagePage, LinkCollection, Usage, UsageValue, @@ -378,11 +378,11 @@ NTSTATUS WINAPI HidP_GetUsageValueArray(HIDP_REPORT_TYPE ReportType, USAGE Usage
if (rc == HIDP_STATUS_SUCCESS) { - if (element.caps.IsRange || element.caps.ReportCount <= 1 || !element.caps.BitCount) + if (element.IsRange || element.ReportCount <= 1 || !element.BitCount) return HIDP_STATUS_NOT_VALUE_ARRAY;
- return get_report_data_array((BYTE*)Report, ReportLength, element.caps.StartBit, element.caps.BitCount, - element.caps.ReportCount, UsageValue, UsageValueByteLength); + return get_report_data_array((BYTE*)Report, ReportLength, element.StartBit, element.BitCount, + element.ReportCount, UsageValue, UsageValueByteLength); }
return rc; @@ -394,7 +394,7 @@ NTSTATUS WINAPI HidP_GetUsages(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USH PCHAR Report, ULONG ReportLength) { PWINE_HIDP_PREPARSED_DATA data = (PWINE_HIDP_PREPARSED_DATA)PreparsedData; - WINE_HID_ELEMENT *elems = HID_ELEMS(data); + HIDP_VALUE_CAPS *elems = HID_ELEMS(data); WINE_HID_REPORT *report = NULL; BOOL found = FALSE; USHORT b_count = 0, r_count = 0; @@ -435,16 +435,16 @@ 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].caps.BitSize == 1 && - elems[report->elementIdx + i].caps.UsagePage == UsagePage) + if (elems[report->elementIdx + i].BitSize == 1 && + elems[report->elementIdx + i].UsagePage == UsagePage) { int k; - WINE_HID_ELEMENT *element = &elems[report->elementIdx + i]; - for (k=0; k < element->caps.BitCount; k++) + HIDP_VALUE_CAPS *element = &elems[report->elementIdx + i]; + for (k=0; k < element->BitCount; k++) { UINT v = 0; NTSTATUS rc = get_report_data((BYTE*)Report, ReportLength, - element->caps.StartBit + k, 1, &v); + element->StartBit + k, 1, &v); if (rc != HIDP_STATUS_SUCCESS) return rc; found = TRUE; @@ -452,7 +452,7 @@ NTSTATUS WINAPI HidP_GetUsages(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USH { if (uCount == *UsageLength) return HIDP_STATUS_BUFFER_TOO_SMALL; - UsageList[uCount] = element->caps.Range.UsageMin + k; + UsageList[uCount] = element->Range.UsageMin + k; uCount++; } } @@ -472,7 +472,7 @@ NTSTATUS WINAPI HidP_GetValueCaps(HIDP_REPORT_TYPE ReportType, PHIDP_VALUE_CAPS PUSHORT ValueCapsLength, PHIDP_PREPARSED_DATA PreparsedData) { PWINE_HIDP_PREPARSED_DATA data = (PWINE_HIDP_PREPARSED_DATA)PreparsedData; - WINE_HID_ELEMENT *elems = HID_ELEMS(data); + HIDP_VALUE_CAPS *elems = HID_ELEMS(data); WINE_HID_REPORT *report = NULL; USHORT v_count = 0, r_count = 0; int i,j,u; @@ -514,8 +514,8 @@ 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].caps.BitSize != 1) - ValueCaps[u++] = elems[report[j].elementIdx + i].caps; + if (elems[report[j].elementIdx + i].BitSize != 1) + ValueCaps[u++] = elems[report[j].elementIdx + i]; } }
@@ -571,7 +571,7 @@ NTSTATUS WINAPI HidP_InitializeReportForID(HIDP_REPORT_TYPE ReportType, UCHAR Re ULONG WINAPI HidP_MaxUsageListLength(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, PHIDP_PREPARSED_DATA PreparsedData) { PWINE_HIDP_PREPARSED_DATA data = (PWINE_HIDP_PREPARSED_DATA)PreparsedData; - WINE_HID_ELEMENT *elems = HID_ELEMS(data); + HIDP_VALUE_CAPS *elems = HID_ELEMS(data); WINE_HID_REPORT *report = NULL; int r_count; int i; @@ -607,12 +607,12 @@ 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].caps.BitSize == 1 && - (UsagePage == 0 || elems[report[i].elementIdx + j].caps.UsagePage == UsagePage)) + if (elems[report[i].elementIdx + j].BitSize == 1 && + (UsagePage == 0 || elems[report[i].elementIdx + j].UsagePage == UsagePage)) { - if (elems[report[i].elementIdx + j].caps.IsRange) - count += (elems[report[i].elementIdx + j].caps.Range.UsageMax - - elems[report[i].elementIdx + j].caps.Range.UsageMin) + 1; + if (elems[report[i].elementIdx + j].IsRange) + count += (elems[report[i].elementIdx + j].Range.UsageMax - + elems[report[i].elementIdx + j].Range.UsageMin) + 1; else count++; } @@ -625,7 +625,7 @@ NTSTATUS WINAPI HidP_SetUsageValue(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USAGE Usage, ULONG UsageValue, PHIDP_PREPARSED_DATA PreparsedData, CHAR *Report, ULONG ReportLength) { - WINE_HID_ELEMENT element; + HIDP_VALUE_CAPS element; NTSTATUS rc;
TRACE("(%i, %x, %i, %i, %i, %p, %p, %i)\n", ReportType, UsagePage, LinkCollection, Usage, UsageValue, @@ -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.caps.BitCount, UsageValue); + element.StartBit, element.BitCount, UsageValue); }
return rc; @@ -647,7 +647,7 @@ NTSTATUS WINAPI HidP_SetUsages(HIDP_REPORT_TYPE ReportType, USAGE UsagePage, USH PUSAGE UsageList, PULONG UsageLength, PHIDP_PREPARSED_DATA PreparsedData, PCHAR Report, ULONG ReportLength) { - WINE_HID_ELEMENT element; + HIDP_VALUE_CAPS element; NTSTATUS rc; ULONG i;
@@ -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.caps.BitCount, -1); + element.StartBit, element.BitCount, -1); }
if (rc != HIDP_STATUS_SUCCESS) @@ -691,7 +691,7 @@ NTSTATUS WINAPI HidP_GetSpecificButtonCaps(HIDP_REPORT_TYPE ReportType, HIDP_BUTTON_CAPS *ButtonCaps, USHORT *ButtonCapsLength, PHIDP_PREPARSED_DATA PreparsedData) { WINE_HIDP_PREPARSED_DATA *data = (WINE_HIDP_PREPARSED_DATA*)PreparsedData; - WINE_HID_ELEMENT *elems = HID_ELEMS(data); + HIDP_VALUE_CAPS *elems = HID_ELEMS(data); WINE_HID_REPORT *report = NULL; USHORT b_count = 0, r_count = 0; int i,j,u; @@ -734,17 +734,17 @@ 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].caps.BitSize == 1 && - (UsagePage == 0 || UsagePage == elems[report[j].elementIdx + i].caps.UsagePage) && - (LinkCollection == 0 || LinkCollection == elems[report[j].elementIdx + i].caps.LinkCollection) && + if (elems[report[j].elementIdx + i].BitSize == 1 && + (UsagePage == 0 || UsagePage == elems[report[j].elementIdx + i].UsagePage) && + (LinkCollection == 0 || LinkCollection == elems[report[j].elementIdx + i].LinkCollection) && (Usage == 0 || ( - (!elems[report[j].elementIdx + i].caps.IsRange && - Usage == elems[report[j].elementIdx + i].caps.NotRange.Usage)) || - (elems[report[j].elementIdx + i].caps.IsRange && - Usage >= elems[report[j].elementIdx + i].caps.Range.UsageMin && - Usage <= elems[report[j].elementIdx + i].caps.Range.UsageMax))) + (!elems[report[j].elementIdx + i].IsRange && + Usage == elems[report[j].elementIdx + i].NotRange.Usage)) || + (elems[report[j].elementIdx + i].IsRange && + Usage >= elems[report[j].elementIdx + i].Range.UsageMin && + Usage <= elems[report[j].elementIdx + i].Range.UsageMax))) { - ButtonCaps[u++] = *(HIDP_BUTTON_CAPS *)&elems[report[j].elementIdx + i].caps; + ButtonCaps[u++] = *(HIDP_BUTTON_CAPS *)&elems[report[j].elementIdx + i]; } } } @@ -761,7 +761,7 @@ NTSTATUS WINAPI HidP_GetSpecificValueCaps(HIDP_REPORT_TYPE ReportType, HIDP_VALUE_CAPS *ValueCaps, USHORT *ValueCapsLength, PHIDP_PREPARSED_DATA PreparsedData) { WINE_HIDP_PREPARSED_DATA *data = (PWINE_HIDP_PREPARSED_DATA)PreparsedData; - WINE_HID_ELEMENT *elems = HID_ELEMS(data); + HIDP_VALUE_CAPS *elems = HID_ELEMS(data); WINE_HID_REPORT *report = NULL; USHORT v_count = 0, r_count = 0; int i,j,u; @@ -804,12 +804,12 @@ 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].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)) + if (elems[report[j].elementIdx + i].BitSize != 1 && + (UsagePage == 0 || UsagePage == elems[report[j].elementIdx + i].UsagePage) && + (LinkCollection == 0 || LinkCollection == elems[report[j].elementIdx + i].LinkCollection) && + (Usage == 0 || Usage == elems[report[j].elementIdx + i].NotRange.Usage)) { - ValueCaps[u++] = elems[report[j].elementIdx + i].caps; + ValueCaps[u++] = elems[report[j].elementIdx + i]; } } } @@ -824,7 +824,7 @@ NTSTATUS WINAPI HidP_GetUsagesEx(HIDP_REPORT_TYPE ReportType, USHORT LinkCollect ULONG *UsageLength, PHIDP_PREPARSED_DATA PreparsedData, CHAR *Report, ULONG ReportLength) { WINE_HIDP_PREPARSED_DATA *data = (WINE_HIDP_PREPARSED_DATA*)PreparsedData; - WINE_HID_ELEMENT *elems = HID_ELEMS(data); + HIDP_VALUE_CAPS *elems = HID_ELEMS(data); WINE_HID_REPORT *report = NULL; USHORT b_count = 0, r_count = 0; int i,uCount = 0; @@ -861,23 +861,23 @@ NTSTATUS WINAPI HidP_GetUsagesEx(HIDP_REPORT_TYPE ReportType, USHORT LinkCollect
for (i = 0; i < report->elementCount; i++) { - if (elems[report->elementIdx + i].caps.BitSize == 1) + if (elems[report->elementIdx + i].BitSize == 1) { int k; - WINE_HID_ELEMENT *element = &elems[report->elementIdx + i]; - for (k=0; k < element->caps.BitCount; k++) + HIDP_VALUE_CAPS *element = &elems[report->elementIdx + i]; + for (k=0; k < element->BitCount; k++) { UINT v = 0; NTSTATUS rc = get_report_data((BYTE*)Report, ReportLength, - element->caps.StartBit + k, 1, &v); + element->StartBit + k, 1, &v); if (rc != HIDP_STATUS_SUCCESS) return rc; if (v) { if (uCount < *UsageLength) { - ButtonList[uCount].Usage = element->caps.Range.UsageMin + k; - ButtonList[uCount].UsagePage = element->caps.UsagePage; + ButtonList[uCount].Usage = element->Range.UsageMin + k; + ButtonList[uCount].UsagePage = element->UsagePage; } uCount++; } @@ -921,7 +921,7 @@ NTSTATUS WINAPI HidP_GetData(HIDP_REPORT_TYPE ReportType, HIDP_DATA *DataList, U PHIDP_PREPARSED_DATA PreparsedData,CHAR *Report, ULONG ReportLength) { WINE_HIDP_PREPARSED_DATA *data = (WINE_HIDP_PREPARSED_DATA*)PreparsedData; - WINE_HID_ELEMENT *elems = HID_ELEMS(data); + HIDP_VALUE_CAPS *elems = HID_ELEMS(data); WINE_HID_REPORT *report = NULL; USHORT r_count = 0; int i,uCount = 0; @@ -944,22 +944,22 @@ 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->caps.BitSize == 1) + HIDP_VALUE_CAPS *element = &elems[report->elementIdx + i]; + if (element->BitSize == 1) { int k; - for (k=0; k < element->caps.BitCount; k++) + for (k=0; k < element->BitCount; k++) { UINT v = 0; NTSTATUS rc = get_report_data((BYTE*)Report, ReportLength, - element->caps.StartBit + k, 1, &v); + element->StartBit + k, 1, &v); if (rc != HIDP_STATUS_SUCCESS) return rc; if (v) { if (uCount < *DataLength) { - DataList[uCount].DataIndex = element->caps.Range.DataIndexMin + k; + DataList[uCount].DataIndex = element->Range.DataIndexMin + k; DataList[uCount].On = v; } uCount++; @@ -972,10 +972,10 @@ 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->caps.BitCount, &v); + element->StartBit, element->BitCount, &v); if (rc != HIDP_STATUS_SUCCESS) return rc; - DataList[uCount].DataIndex = element->caps.NotRange.DataIndex; + DataList[uCount].DataIndex = element->NotRange.DataIndex; DataList[uCount].RawValue = v; } uCount++; diff --git a/dlls/hidclass.sys/descriptor.c b/dlls/hidclass.sys/descriptor.c index dfb612550ee..35a24bae882 100644 --- a/dlls/hidclass.sys/descriptor.c +++ b/dlls/hidclass.sys/descriptor.c @@ -186,7 +186,7 @@ static void debug_collection(struct collection *collection) static void debug_print_report(const char* type, WINE_HIDP_PREPARSED_DATA *data, WINE_HID_REPORT *report) { - WINE_HID_ELEMENT *elems = HID_ELEMS(data); + HIDP_VALUE_CAPS *elems = HID_ELEMS(data); unsigned int i; TRACE("START Report %i <<< %s report : bitSize: %i elementCount: %i\n", report->reportID, @@ -195,8 +195,8 @@ static void debug_print_report(const char* type, WINE_HIDP_PREPARSED_DATA *data, report->elementCount); for (i = 0; i < report->elementCount; i++) { - WINE_HID_ELEMENT *elem = elems + report->elementIdx + i; - TRACE("%s: %s\n", type, debugstr_hidp_value_caps(&elem->caps)); + HIDP_VALUE_CAPS *elem = elems + report->elementIdx + i; + TRACE("%s: %s\n", type, debugstr_hidp_value_caps(elem)); } TRACE(">>> END Report %i\n",report->reportID); } @@ -577,10 +577,10 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l return i; }
-static void build_elements(WINE_HID_REPORT *wine_report, WINE_HID_ELEMENT *elems, +static void build_elements(WINE_HID_REPORT *wine_report, HIDP_VALUE_CAPS *elems, struct feature* feature, USHORT *data_index) { - WINE_HID_ELEMENT *wine_element = elems + wine_report->elementIdx + wine_report->elementCount; + HIDP_VALUE_CAPS *wine_element = elems + wine_report->elementIdx + wine_report->elementCount; ULONG index_count;
if (!feature->isData) @@ -589,29 +589,29 @@ static void build_elements(WINE_HID_REPORT *wine_report, WINE_HID_ELEMENT *elems return; }
- 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; - wine_element->caps.StartBit = wine_report->bitSize; - wine_element->caps.BitCount = (wine_element->caps.BitSize * wine_element->caps.ReportCount); - wine_report->bitSize += wine_element->caps.BitCount; - - if (wine_element->caps.IsRange) + *wine_element = feature->caps; + wine_element->BitField = feature->BitField; + wine_element->LinkCollection = feature->collection->index; + wine_element->LinkUsage = feature->collection->caps.NotRange.Usage; + wine_element->LinkUsagePage = feature->collection->caps.UsagePage; + wine_element->IsAbsolute = feature->IsAbsolute; + wine_element->HasNull = feature->HasNull; + wine_element->StartBit = wine_report->bitSize; + wine_element->BitCount = (wine_element->BitSize * wine_element->ReportCount); + wine_report->bitSize += wine_element->BitCount; + + if (wine_element->IsRange) { - 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; + if (wine_element->BitSize == 1) index_count = wine_element->BitCount - 1; + else index_count = wine_element->Range.UsageMax - wine_element->Range.UsageMin; + wine_element->Range.DataIndexMin = *data_index; + wine_element->Range.DataIndexMax = *data_index + index_count; *data_index = *data_index + index_count + 1; } else { - wine_element->caps.NotRange.DataIndex = *data_index; - wine_element->caps.NotRange.Reserved4 = *data_index; + wine_element->NotRange.DataIndex = *data_index; + wine_element->NotRange.Reserved4 = *data_index; *data_index = *data_index + 1; }
@@ -660,7 +660,7 @@ static void create_preparse_ctx(const struct collection *base, struct preparse_c static void preparse_collection(const struct collection *root, const struct collection *base, WINE_HIDP_PREPARSED_DATA *data, struct preparse_ctx *ctx) { - WINE_HID_ELEMENT *elem = HID_ELEMS(data); + HIDP_VALUE_CAPS *elem = HID_ELEMS(data); WINE_HID_LINK_COLLECTION_NODE *nodes = HID_NODES(data); struct feature *f; struct collection *c; @@ -747,7 +747,7 @@ static WINE_HIDP_PREPARSED_DATA* build_PreparseData(struct collection *base_coll report_count = ctx.report_count[HidP_Input] + ctx.report_count[HidP_Output] + ctx.report_count[HidP_Feature]; element_off = FIELD_OFFSET(WINE_HIDP_PREPARSED_DATA, reports[report_count]); - size = element_off + (ctx.elem_count * sizeof(WINE_HID_ELEMENT)); + size = element_off + (ctx.elem_count * sizeof(HIDP_VALUE_CAPS));
nodes_offset = size; size += node_count * sizeof(WINE_HID_LINK_COLLECTION_NODE); diff --git a/include/wine/hid.h b/include/wine/hid.h index 9528e598022..15dd2cf2c0d 100644 --- a/include/wine/hid.h +++ b/include/wine/hid.h @@ -31,11 +31,6 @@
#define HID_MAGIC 0x8491759
-typedef struct __WINE_ELEMENT -{ - HIDP_VALUE_CAPS caps; -} WINE_HID_ELEMENT; - /* make sure HIDP_BUTTON_CAPS is a subset of HIDP_VALUE_CAPS */ C_ASSERT( sizeof(HIDP_BUTTON_CAPS) == sizeof(HIDP_VALUE_CAPS) );
@@ -102,7 +97,7 @@ typedef struct __WINE_HIDP_PREPARSED_DATA #define HID_INPUT_REPORTS(d) ((d)->reports) #define HID_OUTPUT_REPORTS(d) ((d)->reports + (d)->reportCount[0]) #define HID_FEATURE_REPORTS(d) ((d)->reports + (d)->reportCount[0] + (d)->reportCount[1]) -#define HID_ELEMS(d) ((WINE_HID_ELEMENT*)((BYTE*)(d) + (d)->elementOffset)) +#define HID_ELEMS(d) ((HIDP_VALUE_CAPS*)((BYTE*)(d) + (d)->elementOffset)) #define HID_NODES(d) ((WINE_HID_LINK_COLLECTION_NODE*)((BYTE*)(d) + (d)->nodesOffset))
#endif /* __WINE_PARSE_H */
As I understand using reserved fields for internal wine usage is not appreciated, I'll do this in some other way, with a fully custom struct, which, although it will need transform to the public structs, will let us avoid struct aliasing and undefined behavior when aliasing union members.