Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hidclass.sys/descriptor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/hidclass.sys/descriptor.c b/dlls/hidclass.sys/descriptor.c index 9364400275a..1c988d89719 100644 --- a/dlls/hidclass.sys/descriptor.c +++ b/dlls/hidclass.sys/descriptor.c @@ -248,7 +248,7 @@ static void debug_print_preparsed(WINE_HIDP_PREPARSED_DATA *data) debug_print_report("OUTPUT", data, &data->reports[i]); } end += data->reportCount[HidP_Feature]; - for (i = 0; i < end; i++) + for (; i < end; i++) { debug_print_report("FEATURE", data, &data->reports[i]); }
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hidclass.sys/descriptor.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/dlls/hidclass.sys/descriptor.c b/dlls/hidclass.sys/descriptor.c index 1c988d89719..65c2f9aadae 100644 --- a/dlls/hidclass.sys/descriptor.c +++ b/dlls/hidclass.sys/descriptor.c @@ -789,6 +789,7 @@ WINE_HIDP_PREPARSED_DATA* ParseDescriptor(BYTE *descriptor, unsigned int length) WINE_HIDP_PREPARSED_DATA *data = NULL; struct collection *base; HIDP_VALUE_CAPS caps; + int i;
struct list caps_stack;
@@ -797,14 +798,13 @@ WINE_HIDP_PREPARSED_DATA* ParseDescriptor(BYTE *descriptor, unsigned int length)
if (TRACE_ON(hid)) { - TRACE("Descriptor[%i]: ", length); - for (cidx = 0; cidx < length; cidx++) + TRACE("descriptor %p, length %u:\n", descriptor, length); + for (i = 0; i < length;) { - TRACE("%x ",descriptor[cidx]); - if ((cidx+1) % 80 == 0) - TRACE("\n"); + TRACE("%08x ", i); + do { TRACE(" %02x", descriptor[i]); } while (++i % 16 && i < length); + TRACE("\n"); } - TRACE("\n"); }
list_init(&caps_stack);
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 --- dlls/hid/hidp.c | 20 ++++++++++---------- dlls/hidclass.sys/descriptor.c | 11 +++++------ include/ddk/hidpi.h | 5 +++++ include/wine/hid.h | 1 - 4 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index a7003717a21..4389fc0ca65 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..8832ffc97f4 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,8 +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;
@@ -601,6 +599,7 @@ 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;
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;
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=92064
Your paranoid android.
=== debiant2 (32 bit report) ===
hid: device: Timeout
=== debiant2 (32 bit Chinese:China report) ===
hid: device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100 device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100
=== debiant2 (32 bit WoW report) ===
hid: device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100 device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100
=== debiant2 (64 bit WoW report) ===
hid: device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100 device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100
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 4389fc0ca65..06be7b8d0d4 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 8832ffc97f4..9f5aa2ab982 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) { @@ -589,8 +589,8 @@ static void build_elements(WINE_HID_REPORT *wine_report, WINE_HID_ELEMENT *elems return; }
- wine_element->bitCount = (feature->caps.BitSize * feature->caps.ReportCount); - wine_report->bitSize += wine_element->bitCount; + bit_count = (feature->caps.BitSize * feature->caps.ReportCount); + wine_report->bitSize += bit_count;
wine_element->caps = feature->caps; wine_element->caps.BitField = feature->BitField; @@ -603,7 +603,7 @@ static void build_elements(WINE_HID_REPORT *wine_report, WINE_HID_ELEMENT *elems
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;
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=92065
Your paranoid android.
=== debiant2 (32 bit report) ===
hid: device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100 device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100
=== debiant2 (32 bit Chinese:China report) ===
hid: device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100 device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100
=== debiant2 (32 bit WoW report) ===
hid: device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100 device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100
=== debiant2 (64 bit WoW report) ===
hid: device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100 device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hid/hidp.c | 154 ++++++++++++++++----------------- dlls/hidclass.sys/descriptor.c | 44 +++++----- include/wine/hid.h | 7 +- 3 files changed, 100 insertions(+), 105 deletions(-)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index 06be7b8d0d4..a2032db7db2 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,16 +268,16 @@ 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->StartBit += value->BitSize * (Usage - value->Range.UsageMin); return HIDP_STATUS_SUCCESS; } else if (value->NotRange.Usage == Usage) @@ -290,27 +290,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.BitSize * element->caps.ReportCount); + UINT bit_count = (element->BitSize * element->ReportCount);
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; } @@ -320,7 +320,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);
@@ -330,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.caps.BitSize * element.caps.ReportCount, &rawValue); + element.StartBit, element.BitSize * element.ReportCount, &rawValue); if (rc != HIDP_STATUS_SUCCESS) return rc; *UsageValue = logical_to_physical(sign_extend(rawValue, &element), &element); @@ -344,7 +344,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, @@ -355,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.caps.BitSize * element.caps.ReportCount, UsageValue); + element.StartBit, element.BitSize * element.ReportCount, UsageValue); }
return rc; @@ -366,7 +366,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, @@ -376,11 +376,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.BitSize || !element.caps.ReportCount) + if (element.IsRange || element.ReportCount <= 1 || !element.BitSize || !element.ReportCount) return HIDP_STATUS_NOT_VALUE_ARRAY;
- return get_report_data_array((BYTE*)Report, ReportLength, element.caps.StartBit, element.caps.BitSize * element.caps.ReportCount, - element.caps.ReportCount, UsageValue, UsageValueByteLength); + return get_report_data_array((BYTE*)Report, ReportLength, element.StartBit, element.BitSize * element.ReportCount, + element.ReportCount, UsageValue, UsageValueByteLength); }
return rc; @@ -392,7 +392,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; @@ -433,16 +433,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.BitSize * element->caps.ReportCount; k++) + HIDP_VALUE_CAPS *element = &elems[report->elementIdx + i]; + for (k=0; k < element->BitSize * element->ReportCount; 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; @@ -450,7 +450,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++; } } @@ -470,7 +470,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; @@ -512,8 +512,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]; } }
@@ -569,7 +569,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; @@ -605,12 +605,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++; } @@ -623,7 +623,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, @@ -634,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.caps.BitSize * element.caps.ReportCount, UsageValue); + element.StartBit, element.BitSize * element.ReportCount, UsageValue); }
return rc; @@ -645,7 +645,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;
@@ -659,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.caps.BitSize * element.caps.ReportCount, -1); + element.StartBit, element.BitSize * element.ReportCount, -1); }
if (rc != HIDP_STATUS_SUCCESS) @@ -689,7 +689,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; @@ -732,17 +732,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]; } } } @@ -759,7 +759,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; @@ -802,12 +802,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]; } } } @@ -822,7 +822,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; @@ -859,23 +859,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.BitSize * element->caps.ReportCount; k++) + HIDP_VALUE_CAPS *element = &elems[report->elementIdx + i]; + for (k=0; k < element->BitSize * element->ReportCount; 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++; } @@ -919,7 +919,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; @@ -942,22 +942,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.BitSize * element->caps.ReportCount; k++) + for (k=0; k < element->BitSize * element->ReportCount; 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++; @@ -970,10 +970,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.BitSize * element->caps.ReportCount, &v); + element->StartBit, element->BitSize * element->ReportCount, &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 9f5aa2ab982..736317ca7bf 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, bit_count;
if (!feature->isData) @@ -592,27 +592,27 @@ static void build_elements(WINE_HID_REPORT *wine_report, WINE_HID_ELEMENT *elems bit_count = (feature->caps.BitSize * feature->caps.ReportCount); wine_report->bitSize += bit_count;
- 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 = 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;
- if (wine_element->caps.IsRange) + if (wine_element->IsRange) { - 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; + if (wine_element->BitSize == 1) index_count = bit_count - 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; }
@@ -661,7 +661,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; @@ -748,7 +748,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 */
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=92066
Your paranoid android.
=== debiant2 (32 bit report) ===
hid: device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100 device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100
=== debiant2 (32 bit Chinese:China report) ===
hid: device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100 device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100
=== debiant2 (32 bit WoW report) ===
hid: device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100 device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100
=== debiant2 (64 bit WoW report) ===
hid: device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100 device.c:216: Test failed: HidP_GetUsages failed (c0110003) but usage length still 100
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hidclass.sys/descriptor.c | 109 ++++++++++++++------------------- 1 file changed, 46 insertions(+), 63 deletions(-)
diff --git a/dlls/hidclass.sys/descriptor.c b/dlls/hidclass.sys/descriptor.c index 736317ca7bf..4a0ee007841 100644 --- a/dlls/hidclass.sys/descriptor.c +++ b/dlls/hidclass.sys/descriptor.c @@ -256,29 +256,6 @@ static void debug_print_preparsed(WINE_HIDP_PREPARSED_DATA *data) } }
-static int getValue(int bsize, int source, BOOL allow_negative) -{ - int mask = 0xff; - int negative = 0x80; - int outofrange = 0x100; - int value; - unsigned int i; - - if (bsize == 4) - return source; - - for (i = 1; i < bsize; i++) - { - mask = (mask<<8) + 0xff; - negative = (negative<<8); - outofrange = (outofrange<<8); - } - value = (source&mask); - if (allow_negative && value&negative) - value = -1 * (outofrange - value); - return value; -} - static void parse_io_feature(unsigned int bSize, int itemVal, int bTag, unsigned int *feature_index, struct feature *feature) @@ -342,17 +319,35 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l int usages_top = 0; USAGE usages[256]; int i; + UINT32 value; + INT32 signed_value;
for (i = index; i < length;) { BYTE b0 = descriptor[i++]; - int bSize = b0 & 0x03; + int size = b0 & 0x03; int bType = (b0 >> 2) & 0x03; int bTag = (b0 >> 4) & 0x0F;
- bSize = (bSize == 3) ? 4 : bSize; - if (bType == TAG_TYPE_RESERVED && bTag == 0x0F && bSize == 2 && - i + 2 < length) + if (size == 3) size = 4; + if (length - i < size) + { + ERR("Need %d bytes to read item value\n", size); + return -1; + } + + if (size == 0) signed_value = value = 0; + else if (size == 1) signed_value = (INT8)(value = *(UINT8 *)(descriptor + i)); + else if (size == 2) signed_value = (INT16)(value = *(UINT16 *)(descriptor + i)); + else if (size == 4) signed_value = (INT32)(value = *(UINT32 *)(descriptor + i)); + else + { + ERR("Unexpected item value size %d.\n", size); + return -1; + } + i += size; + + if (bType == TAG_TYPE_RESERVED && bTag == 0x0F && size == 2) { /* Long data items: Should be unused */ ERR("Long Data Item, should be unused\n"); @@ -360,19 +355,9 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l } else { - int bSizeActual = 0; - int itemVal = 0; unsigned int j;
- for (j = 0; j < bSize; j++) - { - if (i + j < length) - { - itemVal += descriptor[i + j] << (8 * j); - bSizeActual++; - } - } - TRACE(" 0x%x[%i], type %i , tag %i, size %i, val %i\n",b0,i-1,bType, bTag, bSize, itemVal ); + TRACE(" 0x%x[%i], type %i , tag %i, size %i, val %i\n",b0,i-size-1,bType, bTag, size, value );
if (bType == TAG_TYPE_MAIN) { @@ -392,7 +377,7 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l feature->type = HidP_Output; else feature->type = HidP_Feature; - parse_io_feature(bSize, itemVal, bTag, feature_index, feature); + parse_io_feature(size, value, bTag, feature_index, feature); if (j < usages_top) caps->NotRange.Usage = usages[j]; feature->caps = *caps; @@ -429,9 +414,9 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l list_init(&subcollection->collections); new_caps(caps);
- parse_collection(bSize, itemVal, subcollection); + parse_collection(size, value, subcollection);
- if ((i = parse_descriptor(descriptor, i+1, length, feature_index, collection_index, subcollection, caps, stack)) < 0) return i; + if ((i = parse_descriptor(descriptor, i, length, feature_index, collection_index, subcollection, caps, stack)) < 0) return i; continue; } case TAG_MAIN_END_COLLECTION: @@ -446,34 +431,34 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l switch(bTag) { case TAG_GLOBAL_USAGE_PAGE: - caps->UsagePage = getValue(bSize, itemVal, FALSE); + caps->UsagePage = value; break; case TAG_GLOBAL_LOGICAL_MINIMUM: - caps->LogicalMin = getValue(bSize, itemVal, TRUE); + caps->LogicalMin = signed_value; break; case TAG_GLOBAL_LOGICAL_MAXIMUM: - caps->LogicalMax = getValue(bSize, itemVal, TRUE); + caps->LogicalMax = signed_value; break; case TAG_GLOBAL_PHYSICAL_MINIMUM: - caps->PhysicalMin = getValue(bSize, itemVal, TRUE); + caps->PhysicalMin = signed_value; break; case TAG_GLOBAL_PHYSICAL_MAXIMUM: - caps->PhysicalMax = getValue(bSize, itemVal, TRUE); + caps->PhysicalMax = signed_value; break; case TAG_GLOBAL_UNIT_EXPONENT: - caps->UnitsExp = getValue(bSize, itemVal, TRUE); + caps->UnitsExp = signed_value; break; case TAG_GLOBAL_UNIT: - caps->Units = getValue(bSize, itemVal, TRUE); + caps->Units = signed_value; break; case TAG_GLOBAL_REPORT_SIZE: - caps->BitSize = getValue(bSize, itemVal, FALSE); + caps->BitSize = value; break; case TAG_GLOBAL_REPORT_ID: - caps->ReportID = getValue(bSize, itemVal, FALSE); + caps->ReportID = value; break; case TAG_GLOBAL_REPORT_COUNT: - caps->ReportCount = getValue(bSize, itemVal, FALSE); + caps->ReportCount = value; break; case TAG_GLOBAL_PUSH: { @@ -521,44 +506,44 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l } else { - usages[usages_top++] = getValue(bSize, itemVal, FALSE); + usages[usages_top++] = value; caps->IsRange = FALSE; } break; case TAG_LOCAL_USAGE_MINIMUM: - caps->Range.UsageMin = getValue(bSize, itemVal, FALSE); + caps->Range.UsageMin = value; caps->IsRange = TRUE; break; case TAG_LOCAL_USAGE_MAXIMUM: - caps->Range.UsageMax = getValue(bSize, itemVal, FALSE); + caps->Range.UsageMax = value; caps->IsRange = TRUE; break; case TAG_LOCAL_DESIGNATOR_INDEX: - caps->NotRange.DesignatorIndex = getValue(bSize, itemVal, FALSE); + caps->NotRange.DesignatorIndex = value; caps->IsDesignatorRange = FALSE; break; case TAG_LOCAL_DESIGNATOR_MINIMUM: - caps->Range.DesignatorMin = getValue(bSize, itemVal, FALSE); + caps->Range.DesignatorMin = value; caps->IsDesignatorRange = TRUE; break; case TAG_LOCAL_DESIGNATOR_MAXIMUM: - caps->Range.DesignatorMax = getValue(bSize, itemVal, FALSE); + caps->Range.DesignatorMax = value; caps->IsDesignatorRange = TRUE; break; case TAG_LOCAL_STRING_INDEX: - caps->NotRange.StringIndex = getValue(bSize, itemVal, FALSE); + caps->NotRange.StringIndex = value; caps->IsStringRange = FALSE; break; case TAG_LOCAL_STRING_MINIMUM: - caps->Range.StringMin = getValue(bSize, itemVal, FALSE); + caps->Range.StringMin = value; caps->IsStringRange = TRUE; break; case TAG_LOCAL_STRING_MAXIMUM: - caps->Range.StringMax = getValue(bSize, itemVal, FALSE); + caps->Range.StringMax = value; caps->IsStringRange = TRUE; break; case TAG_LOCAL_DELIMITER: - FIXME("delimiter %d not implemented!\n", itemVal); + FIXME("delimiter %d not implemented!\n", value); return -1; default: ERR("Unknown (bTag: 0x%x, bType: 0x%x)\n", bTag, bType); @@ -570,8 +555,6 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l ERR("Unknown (bTag: 0x%x, bType: 0x%x)\n", bTag, bType); return -1; } - - i += bSize; } } return i;
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hidclass.sys/descriptor.c | 365 +++++++++++++++------------------ 1 file changed, 165 insertions(+), 200 deletions(-)
diff --git a/dlls/hidclass.sys/descriptor.c b/dlls/hidclass.sys/descriptor.c index 4a0ee007841..1b0156ed8d7 100644 --- a/dlls/hidclass.sys/descriptor.c +++ b/dlls/hidclass.sys/descriptor.c @@ -318,16 +318,16 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l { int usages_top = 0; USAGE usages[256]; - int i; + int i, j; UINT32 value; INT32 signed_value; + struct feature *feature;
for (i = index; i < length;) { - BYTE b0 = descriptor[i++]; - int size = b0 & 0x03; - int bType = (b0 >> 2) & 0x03; - int bTag = (b0 >> 4) & 0x0F; + BYTE item = descriptor[i++]; + BYTE tag = item >> 4; + int size = item & 0x03;
if (size == 3) size = 4; if (length - i < size) @@ -347,215 +347,180 @@ static int parse_descriptor(BYTE *descriptor, unsigned int index, unsigned int l } i += size;
- if (bType == TAG_TYPE_RESERVED && bTag == 0x0F && size == 2) +#define SHORT_ITEM(tag,type) (((tag)<<4)|((type)<<2)) + switch (item & SHORT_ITEM(0xf,0x3)) { - /* Long data items: Should be unused */ - ERR("Long Data Item, should be unused\n"); - return -1; - } - else - { - unsigned int j; - - TRACE(" 0x%x[%i], type %i , tag %i, size %i, val %i\n",b0,i-size-1,bType, bTag, size, value ); - - if (bType == TAG_TYPE_MAIN) + case SHORT_ITEM(TAG_MAIN_INPUT, TAG_TYPE_MAIN): + case SHORT_ITEM(TAG_MAIN_OUTPUT, TAG_TYPE_MAIN): + case SHORT_ITEM(TAG_MAIN_FEATURE, TAG_TYPE_MAIN): + for (j = 0; j < caps->ReportCount; j++) { - struct feature *feature; - switch(bTag) + if (!(feature = calloc(1, sizeof(*feature)))) return -1; + list_add_tail(&collection->features, &feature->entry); + if (tag == TAG_MAIN_INPUT) + feature->type = HidP_Input; + else if (tag == TAG_MAIN_OUTPUT) + feature->type = HidP_Output; + else + feature->type = HidP_Feature; + parse_io_feature(size, value, tag, feature_index, feature); + if (j < usages_top) + caps->NotRange.Usage = usages[j]; + feature->caps = *caps; + feature->caps.ReportCount = 1; + feature->collection = collection; + if (j+1 >= usages_top) { - case TAG_MAIN_INPUT: - case TAG_MAIN_OUTPUT: - case TAG_MAIN_FEATURE: - for (j = 0; j < caps->ReportCount; j++) - { - if (!(feature = calloc(1, sizeof(*feature)))) return -1; - list_add_tail(&collection->features, &feature->entry); - if (bTag == TAG_MAIN_INPUT) - feature->type = HidP_Input; - else if (bTag == TAG_MAIN_OUTPUT) - feature->type = HidP_Output; - else - feature->type = HidP_Feature; - parse_io_feature(size, value, bTag, feature_index, feature); - if (j < usages_top) - caps->NotRange.Usage = usages[j]; - feature->caps = *caps; - feature->caps.ReportCount = 1; - feature->collection = collection; - if (j+1 >= usages_top) - { - feature->caps.ReportCount += caps->ReportCount - (j + 1); - break; - } - } - usages_top = 0; - new_caps(caps); - break; - case TAG_MAIN_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... - We do not properly handle composite devices yet. */ - if (usages_top) - { - caps->NotRange.Usage = usages[usages_top-1]; - usages_top = 0; - } - if (*collection_index == 0) - collection->caps = *caps; - subcollection->caps = *caps; - subcollection->index = *collection_index; - *collection_index = *collection_index + 1; - list_init(&subcollection->features); - list_init(&subcollection->collections); - new_caps(caps); - - parse_collection(size, value, subcollection); - - if ((i = parse_descriptor(descriptor, i, 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; + feature->caps.ReportCount += caps->ReportCount - (j + 1); + break; } } - else if (bType == TAG_TYPE_GLOBAL) + usages_top = 0; + new_caps(caps); + break; + case SHORT_ITEM(TAG_MAIN_COLLECTION, TAG_TYPE_MAIN): + { + 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... + We do not properly handle composite devices yet. */ + if (usages_top) { - switch(bTag) - { - case TAG_GLOBAL_USAGE_PAGE: - caps->UsagePage = value; - break; - case TAG_GLOBAL_LOGICAL_MINIMUM: - caps->LogicalMin = signed_value; - break; - case TAG_GLOBAL_LOGICAL_MAXIMUM: - caps->LogicalMax = signed_value; - break; - case TAG_GLOBAL_PHYSICAL_MINIMUM: - caps->PhysicalMin = signed_value; - break; - case TAG_GLOBAL_PHYSICAL_MAXIMUM: - caps->PhysicalMax = signed_value; - break; - case TAG_GLOBAL_UNIT_EXPONENT: - caps->UnitsExp = signed_value; - break; - case TAG_GLOBAL_UNIT: - caps->Units = signed_value; - break; - case TAG_GLOBAL_REPORT_SIZE: - caps->BitSize = value; - break; - case TAG_GLOBAL_REPORT_ID: - caps->ReportID = value; - break; - case TAG_GLOBAL_REPORT_COUNT: - caps->ReportCount = value; - break; - case TAG_GLOBAL_PUSH: - { - struct caps_stack *saved; - if (!(saved = malloc(sizeof(*saved)))) return -1; - saved->caps = *caps; - TRACE("Push\n"); - list_add_tail(stack, &saved->entry); - break; - } - case TAG_GLOBAL_POP: - { - struct list *tail; - struct caps_stack *saved; - TRACE("Pop\n"); - tail = list_tail(stack); - if (tail) - { - saved = LIST_ENTRY(tail, struct caps_stack, entry); - *caps = saved->caps; - list_remove(tail); - 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; - } + caps->NotRange.Usage = usages[usages_top-1]; + usages_top = 0; } - else if (bType == TAG_TYPE_LOCAL) + if (*collection_index == 0) + collection->caps = *caps; + subcollection->caps = *caps; + subcollection->index = *collection_index; + *collection_index = *collection_index + 1; + list_init(&subcollection->features); + list_init(&subcollection->collections); + new_caps(caps); + + parse_collection(size, value, subcollection); + + if ((i = parse_descriptor(descriptor, i, length, feature_index, collection_index, subcollection, caps, stack)) < 0) return i; + continue; + } + case SHORT_ITEM(TAG_MAIN_END_COLLECTION, TAG_TYPE_MAIN): + return i; + + case SHORT_ITEM(TAG_GLOBAL_USAGE_PAGE, TAG_TYPE_GLOBAL): + caps->UsagePage = value; + break; + case SHORT_ITEM(TAG_GLOBAL_LOGICAL_MINIMUM, TAG_TYPE_GLOBAL): + caps->LogicalMin = signed_value; + break; + case SHORT_ITEM(TAG_GLOBAL_LOGICAL_MAXIMUM, TAG_TYPE_GLOBAL): + caps->LogicalMax = signed_value; + break; + case SHORT_ITEM(TAG_GLOBAL_PHYSICAL_MINIMUM, TAG_TYPE_GLOBAL): + caps->PhysicalMin = signed_value; + break; + case SHORT_ITEM(TAG_GLOBAL_PHYSICAL_MAXIMUM, TAG_TYPE_GLOBAL): + caps->PhysicalMax = signed_value; + break; + case SHORT_ITEM(TAG_GLOBAL_UNIT_EXPONENT, TAG_TYPE_GLOBAL): + caps->UnitsExp = signed_value; + break; + case SHORT_ITEM(TAG_GLOBAL_UNIT, TAG_TYPE_GLOBAL): + caps->Units = signed_value; + break; + case SHORT_ITEM(TAG_GLOBAL_REPORT_SIZE, TAG_TYPE_GLOBAL): + caps->BitSize = value; + break; + case SHORT_ITEM(TAG_GLOBAL_REPORT_ID, TAG_TYPE_GLOBAL): + caps->ReportID = value; + break; + case SHORT_ITEM(TAG_GLOBAL_REPORT_COUNT, TAG_TYPE_GLOBAL): + caps->ReportCount = value; + break; + case SHORT_ITEM(TAG_GLOBAL_PUSH, TAG_TYPE_GLOBAL): + { + struct caps_stack *saved; + if (!(saved = malloc(sizeof(*saved)))) return -1; + saved->caps = *caps; + TRACE("Push\n"); + list_add_tail(stack, &saved->entry); + break; + } + case SHORT_ITEM(TAG_GLOBAL_POP, TAG_TYPE_GLOBAL): + { + struct list *tail; + struct caps_stack *saved; + TRACE("Pop\n"); + tail = list_tail(stack); + if (tail) { - switch(bTag) - { - case TAG_LOCAL_USAGE: - if (usages_top == sizeof(usages)) - { - ERR("More than 256 individual usages defined\n"); - return -1; - } - else - { - usages[usages_top++] = value; - caps->IsRange = FALSE; - } - break; - case TAG_LOCAL_USAGE_MINIMUM: - caps->Range.UsageMin = value; - caps->IsRange = TRUE; - break; - case TAG_LOCAL_USAGE_MAXIMUM: - caps->Range.UsageMax = value; - caps->IsRange = TRUE; - break; - case TAG_LOCAL_DESIGNATOR_INDEX: - caps->NotRange.DesignatorIndex = value; - caps->IsDesignatorRange = FALSE; - break; - case TAG_LOCAL_DESIGNATOR_MINIMUM: - caps->Range.DesignatorMin = value; - caps->IsDesignatorRange = TRUE; - break; - case TAG_LOCAL_DESIGNATOR_MAXIMUM: - caps->Range.DesignatorMax = value; - caps->IsDesignatorRange = TRUE; - break; - case TAG_LOCAL_STRING_INDEX: - caps->NotRange.StringIndex = value; - caps->IsStringRange = FALSE; - break; - case TAG_LOCAL_STRING_MINIMUM: - caps->Range.StringMin = value; - caps->IsStringRange = TRUE; - break; - case TAG_LOCAL_STRING_MAXIMUM: - caps->Range.StringMax = value; - caps->IsStringRange = TRUE; - break; - case TAG_LOCAL_DELIMITER: - FIXME("delimiter %d not implemented!\n", value); - return -1; - default: - ERR("Unknown (bTag: 0x%x, bType: 0x%x)\n", bTag, bType); - return -1; - } + saved = LIST_ENTRY(tail, struct caps_stack, entry); + *caps = saved->caps; + list_remove(tail); + free(saved); } else { - ERR("Unknown (bTag: 0x%x, bType: 0x%x)\n", bTag, bType); + ERR("Pop but no stack!\n"); + return -1; + } + break; + } + + case SHORT_ITEM(TAG_LOCAL_USAGE, TAG_TYPE_LOCAL): + if (usages_top == sizeof(usages)) + { + ERR("More than 256 individual usages defined\n"); return -1; } + else + { + usages[usages_top++] = value; + caps->IsRange = FALSE; + } + break; + case SHORT_ITEM(TAG_LOCAL_USAGE_MINIMUM, TAG_TYPE_LOCAL): + caps->Range.UsageMin = value; + caps->IsRange = TRUE; + break; + case SHORT_ITEM(TAG_LOCAL_USAGE_MAXIMUM, TAG_TYPE_LOCAL): + caps->Range.UsageMax = value; + caps->IsRange = TRUE; + break; + case SHORT_ITEM(TAG_LOCAL_DESIGNATOR_INDEX, TAG_TYPE_LOCAL): + caps->NotRange.DesignatorIndex = value; + caps->IsDesignatorRange = FALSE; + break; + case SHORT_ITEM(TAG_LOCAL_DESIGNATOR_MINIMUM, TAG_TYPE_LOCAL): + caps->Range.DesignatorMin = value; + caps->IsDesignatorRange = TRUE; + break; + case SHORT_ITEM(TAG_LOCAL_DESIGNATOR_MAXIMUM, TAG_TYPE_LOCAL): + caps->Range.DesignatorMax = value; + caps->IsDesignatorRange = TRUE; + break; + case SHORT_ITEM(TAG_LOCAL_STRING_INDEX, TAG_TYPE_LOCAL): + caps->NotRange.StringIndex = value; + caps->IsStringRange = FALSE; + break; + case SHORT_ITEM(TAG_LOCAL_STRING_MINIMUM, TAG_TYPE_LOCAL): + caps->Range.StringMin = value; + caps->IsStringRange = TRUE; + break; + case SHORT_ITEM(TAG_LOCAL_STRING_MAXIMUM, TAG_TYPE_LOCAL): + caps->Range.StringMax = value; + caps->IsStringRange = TRUE; + break; + case SHORT_ITEM(TAG_LOCAL_DELIMITER, TAG_TYPE_LOCAL): + FIXME("delimiter %d not implemented!\n", value); + return -1; + + default: + FIXME("item type %x not implemented!\n", item); + return -1; } +#undef SHORT_ITEM } return i; }