Commit 3fa5d9eb authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

hidparse.sys: Replace all is_*range members with a single flags member.

parent 6fa0d127
...@@ -95,16 +95,17 @@ static NTSTATUS enum_value_caps( struct hid_preparsed_data *preparsed, HIDP_REPO ...@@ -95,16 +95,17 @@ static NTSTATUS enum_value_caps( struct hid_preparsed_data *preparsed, HIDP_REPO
enum_value_caps_callback callback, void *user, USHORT *count ) enum_value_caps_callback callback, void *user, USHORT *count )
{ {
const struct hid_value_caps *caps, *caps_end; const struct hid_value_caps *caps, *caps_end;
NTSTATUS status; BOOL is_range, incompatible = FALSE;
BOOL incompatible = FALSE;
LONG remaining = *count; LONG remaining = *count;
NTSTATUS status;
for (status = get_value_caps_range( preparsed, report_type, report_len, &caps, &caps_end ); for (status = get_value_caps_range( preparsed, report_type, report_len, &caps, &caps_end );
status == HIDP_STATUS_SUCCESS && caps != caps_end; caps++) status == HIDP_STATUS_SUCCESS && caps != caps_end; caps++)
{ {
is_range = caps->flags & HID_VALUE_CAPS_IS_RANGE;
if (!match_value_caps( caps, filter )) continue; if (!match_value_caps( caps, filter )) continue;
if (filter->report_id && caps->report_id != filter->report_id) incompatible = TRUE; if (filter->report_id && caps->report_id != filter->report_id) incompatible = TRUE;
else if (filter->array && (caps->is_range || caps->report_count <= 1)) return HIDP_STATUS_NOT_VALUE_ARRAY; else if (filter->array && (is_range || caps->report_count <= 1)) return HIDP_STATUS_NOT_VALUE_ARRAY;
else if (remaining-- > 0) status = callback( caps, user ); else if (remaining-- > 0) status = callback( caps, user );
} }
...@@ -634,7 +635,8 @@ static NTSTATUS get_button_caps( const struct hid_value_caps *caps, void *user ) ...@@ -634,7 +635,8 @@ static NTSTATUS get_button_caps( const struct hid_value_caps *caps, void *user )
dst->BitField = caps->bit_field; dst->BitField = caps->bit_field;
dst->IsAlias = FALSE; dst->IsAlias = FALSE;
dst->IsAbsolute = HID_VALUE_CAPS_IS_ABSOLUTE( caps ); dst->IsAbsolute = HID_VALUE_CAPS_IS_ABSOLUTE( caps );
if (!(dst->IsRange = caps->is_range)) dst->IsRange = (caps->flags & HID_VALUE_CAPS_IS_RANGE) ? 1 : 0;
if (!dst->IsRange)
{ {
dst->NotRange.Usage = caps->usage_min; dst->NotRange.Usage = caps->usage_min;
dst->NotRange.DataIndex = caps->data_index_min; dst->NotRange.DataIndex = caps->data_index_min;
...@@ -646,14 +648,16 @@ static NTSTATUS get_button_caps( const struct hid_value_caps *caps, void *user ) ...@@ -646,14 +648,16 @@ static NTSTATUS get_button_caps( const struct hid_value_caps *caps, void *user )
dst->Range.DataIndexMin = caps->data_index_min; dst->Range.DataIndexMin = caps->data_index_min;
dst->Range.DataIndexMax = caps->data_index_max; dst->Range.DataIndexMax = caps->data_index_max;
} }
if (!(dst->IsStringRange = caps->is_string_range)) dst->IsStringRange = (caps->flags & HID_VALUE_CAPS_IS_STRING_RANGE) ? 1 : 0;
if (!dst->IsStringRange)
dst->NotRange.StringIndex = caps->string_min; dst->NotRange.StringIndex = caps->string_min;
else else
{ {
dst->Range.StringMin = caps->string_min; dst->Range.StringMin = caps->string_min;
dst->Range.StringMax = caps->string_max; dst->Range.StringMax = caps->string_max;
} }
if ((dst->IsDesignatorRange = caps->is_designator_range)) dst->IsDesignatorRange = (caps->flags & HID_VALUE_CAPS_IS_DESIGNATOR_RANGE) ? 1 : 0;
if (!dst->IsDesignatorRange)
dst->NotRange.DesignatorIndex = caps->designator_min; dst->NotRange.DesignatorIndex = caps->designator_min;
else else
{ {
...@@ -690,33 +694,37 @@ static NTSTATUS get_value_caps( const struct hid_value_caps *caps, void *user ) ...@@ -690,33 +694,37 @@ static NTSTATUS get_value_caps( const struct hid_value_caps *caps, void *user )
dst->IsAbsolute = HID_VALUE_CAPS_IS_ABSOLUTE( caps ); dst->IsAbsolute = HID_VALUE_CAPS_IS_ABSOLUTE( caps );
dst->HasNull = HID_VALUE_CAPS_HAS_NULL( caps ); dst->HasNull = HID_VALUE_CAPS_HAS_NULL( caps );
dst->BitSize = caps->bit_size; dst->BitSize = caps->bit_size;
dst->ReportCount = caps->is_range ? 1 : caps->report_count;
dst->UnitsExp = caps->units_exp; dst->UnitsExp = caps->units_exp;
dst->Units = caps->units; dst->Units = caps->units;
dst->LogicalMin = caps->logical_min; dst->LogicalMin = caps->logical_min;
dst->LogicalMax = caps->logical_max; dst->LogicalMax = caps->logical_max;
dst->PhysicalMin = caps->physical_min; dst->PhysicalMin = caps->physical_min;
dst->PhysicalMax = caps->physical_max; dst->PhysicalMax = caps->physical_max;
if (!(dst->IsRange = caps->is_range)) dst->IsRange = (caps->flags & HID_VALUE_CAPS_IS_RANGE) ? 1 : 0;
if (!dst->IsRange)
{ {
dst->ReportCount = caps->report_count;
dst->NotRange.Usage = caps->usage_min; dst->NotRange.Usage = caps->usage_min;
dst->NotRange.DataIndex = caps->data_index_min; dst->NotRange.DataIndex = caps->data_index_min;
} }
else else
{ {
dst->ReportCount = 1;
dst->Range.UsageMin = caps->usage_min; dst->Range.UsageMin = caps->usage_min;
dst->Range.UsageMax = caps->usage_max; dst->Range.UsageMax = caps->usage_max;
dst->Range.DataIndexMin = caps->data_index_min; dst->Range.DataIndexMin = caps->data_index_min;
dst->Range.DataIndexMax = caps->data_index_max; dst->Range.DataIndexMax = caps->data_index_max;
} }
if (!(dst->IsStringRange = caps->is_string_range)) dst->IsStringRange = (caps->flags & HID_VALUE_CAPS_IS_STRING_RANGE) ? 1 : 0;
if (!dst->IsStringRange)
dst->NotRange.StringIndex = caps->string_min; dst->NotRange.StringIndex = caps->string_min;
else else
{ {
dst->Range.StringMin = caps->string_min; dst->Range.StringMin = caps->string_min;
dst->Range.StringMax = caps->string_max; dst->Range.StringMax = caps->string_max;
} }
if ((dst->IsDesignatorRange = caps->is_designator_range)) dst->IsDesignatorRange = (caps->flags & HID_VALUE_CAPS_IS_DESIGNATOR_RANGE) ? 1 : 0;
if (!dst->IsDesignatorRange)
dst->NotRange.DesignatorIndex = caps->designator_min; dst->NotRange.DesignatorIndex = caps->designator_min;
else else
{ {
...@@ -810,7 +818,8 @@ NTSTATUS WINAPI HidP_GetUsagesEx( HIDP_REPORT_TYPE report_type, USHORT collectio ...@@ -810,7 +818,8 @@ NTSTATUS WINAPI HidP_GetUsagesEx( HIDP_REPORT_TYPE report_type, USHORT collectio
static NTSTATUS count_data( const struct hid_value_caps *caps, void *user ) static NTSTATUS count_data( const struct hid_value_caps *caps, void *user )
{ {
if (caps->is_range || HID_VALUE_CAPS_IS_BUTTON( caps )) *(ULONG *)user += caps->report_count; BOOL is_range = caps->flags & HID_VALUE_CAPS_IS_RANGE;
if (is_range || HID_VALUE_CAPS_IS_BUTTON( caps )) *(ULONG *)user += caps->report_count;
else *(ULONG *)user += 1; else *(ULONG *)user += 1;
return HIDP_STATUS_SUCCESS; return HIDP_STATUS_SUCCESS;
} }
......
...@@ -102,11 +102,11 @@ enum ...@@ -102,11 +102,11 @@ enum
static inline const char *debugstr_hid_value_caps( struct hid_value_caps *caps ) static inline const char *debugstr_hid_value_caps( struct hid_value_caps *caps )
{ {
if (!caps) return "(null)"; 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), " return wine_dbg_sprintf( "RId %d, Usg %02x:%02x-%02x Dat %02x-%02x, Str %d-%d, Des %d-%d, "
"Bits %02x, LCol %d LUsg %02x:%02x, BitSz %d, RCnt %d, Unit %x E%+d, Log %+d-%+d, Phy %+d-%+d", "Bits %02x Flags %#x, LCol %d LUsg %02x:%02x, BitSz %d, RCnt %d, Unit %x E%+d, Log %+d-%+d, Phy %+d-%+d",
caps->report_id, caps->usage_page, caps->usage_min, caps->usage_max, caps->data_index_min, caps->data_index_max, caps->is_range, caps->report_id, caps->usage_page, caps->usage_min, caps->usage_max, caps->data_index_min, caps->data_index_max,
caps->string_min, caps->string_max, caps->is_string_range, caps->designator_min, caps->designator_max, caps->is_designator_range, caps->string_min, caps->string_max, caps->designator_min, caps->designator_max, caps->bit_field, caps->flags,
caps->bit_field, caps->link_collection, caps->link_usage_page, caps->link_usage, caps->bit_size, caps->report_count, caps->link_collection, caps->link_usage_page, caps->link_usage, caps->bit_size, caps->report_count,
caps->units, caps->units_exp, caps->logical_min, caps->logical_max, caps->physical_min, caps->physical_max ); caps->units, caps->units_exp, caps->logical_min, caps->logical_max, caps->physical_min, caps->physical_max );
} }
...@@ -243,13 +243,13 @@ static BOOL parse_global_pop( struct hid_parser_state *state ) ...@@ -243,13 +243,13 @@ static BOOL parse_global_pop( struct hid_parser_state *state )
static BOOL parse_local_usage( struct hid_parser_state *state, USAGE usage_page, USAGE usage ) static BOOL parse_local_usage( struct hid_parser_state *state, USAGE usage_page, USAGE usage )
{ {
if (!usage_page) usage_page = state->items.usage_page; if (!usage_page) usage_page = state->items.usage_page;
if (state->items.is_range) state->usages_size = 0; if (state->items.flags & HID_VALUE_CAPS_IS_RANGE) state->usages_size = 0;
state->usages_page[state->usages_size] = usage_page; state->usages_page[state->usages_size] = usage_page;
state->usages_min[state->usages_size] = usage; state->usages_min[state->usages_size] = usage;
state->usages_max[state->usages_size] = usage; state->usages_max[state->usages_size] = usage;
state->items.usage_min = usage; state->items.usage_min = usage;
state->items.usage_max = usage; state->items.usage_max = usage;
state->items.is_range = FALSE; state->items.flags &= ~HID_VALUE_CAPS_IS_RANGE;
if (state->usages_size++ == 255) ERR( "HID parser usages stack overflow!\n" ); if (state->usages_size++ == 255) ERR( "HID parser usages stack overflow!\n" );
return state->usages_size <= 255; return state->usages_size <= 255;
} }
...@@ -257,22 +257,22 @@ static BOOL parse_local_usage( struct hid_parser_state *state, USAGE usage_page, ...@@ -257,22 +257,22 @@ static BOOL parse_local_usage( struct hid_parser_state *state, USAGE usage_page,
static void parse_local_usage_min( struct hid_parser_state *state, USAGE usage_page, USAGE usage ) static void parse_local_usage_min( struct hid_parser_state *state, USAGE usage_page, USAGE usage )
{ {
if (!usage_page) usage_page = state->items.usage_page; if (!usage_page) usage_page = state->items.usage_page;
if (!state->items.is_range) state->usages_max[0] = 0; if (!(state->items.flags & HID_VALUE_CAPS_IS_RANGE)) state->usages_max[0] = 0;
state->usages_page[0] = usage_page; state->usages_page[0] = usage_page;
state->usages_min[0] = usage; state->usages_min[0] = usage;
state->items.usage_min = usage; state->items.usage_min = usage;
state->items.is_range = TRUE; state->items.flags |= HID_VALUE_CAPS_IS_RANGE;
state->usages_size = 1; state->usages_size = 1;
} }
static void parse_local_usage_max( struct hid_parser_state *state, USAGE usage_page, USAGE usage ) static void parse_local_usage_max( struct hid_parser_state *state, USAGE usage_page, USAGE usage )
{ {
if (!usage_page) usage_page = state->items.usage_page; if (!usage_page) usage_page = state->items.usage_page;
if (!state->items.is_range) state->usages_min[0] = 0; if (!(state->items.flags & HID_VALUE_CAPS_IS_RANGE)) state->usages_min[0] = 0;
state->usages_page[0] = usage_page; state->usages_page[0] = usage_page;
state->usages_max[0] = usage; state->usages_max[0] = usage;
state->items.usage_max = usage; state->items.usage_max = usage;
state->items.is_range = TRUE; state->items.flags |= HID_VALUE_CAPS_IS_RANGE;
state->usages_size = 1; state->usages_size = 1;
} }
...@@ -579,27 +579,27 @@ struct hid_preparsed_data *parse_descriptor( BYTE *descriptor, unsigned int leng ...@@ -579,27 +579,27 @@ struct hid_preparsed_data *parse_descriptor( BYTE *descriptor, unsigned int leng
break; break;
case SHORT_ITEM( TAG_LOCAL_DESIGNATOR_INDEX, TAG_TYPE_LOCAL ): case SHORT_ITEM( TAG_LOCAL_DESIGNATOR_INDEX, TAG_TYPE_LOCAL ):
state->items.designator_min = state->items.designator_max = value; state->items.designator_min = state->items.designator_max = value;
state->items.is_designator_range = FALSE; state->items.flags &= ~HID_VALUE_CAPS_IS_DESIGNATOR_RANGE;
break; break;
case SHORT_ITEM( TAG_LOCAL_DESIGNATOR_MINIMUM, TAG_TYPE_LOCAL ): case SHORT_ITEM( TAG_LOCAL_DESIGNATOR_MINIMUM, TAG_TYPE_LOCAL ):
state->items.designator_min = value; state->items.designator_min = value;
state->items.is_designator_range = TRUE; state->items.flags |= HID_VALUE_CAPS_IS_DESIGNATOR_RANGE;
break; break;
case SHORT_ITEM( TAG_LOCAL_DESIGNATOR_MAXIMUM, TAG_TYPE_LOCAL ): case SHORT_ITEM( TAG_LOCAL_DESIGNATOR_MAXIMUM, TAG_TYPE_LOCAL ):
state->items.designator_max = value; state->items.designator_max = value;
state->items.is_designator_range = TRUE; state->items.flags |= HID_VALUE_CAPS_IS_DESIGNATOR_RANGE;
break; break;
case SHORT_ITEM( TAG_LOCAL_STRING_INDEX, TAG_TYPE_LOCAL ): case SHORT_ITEM( TAG_LOCAL_STRING_INDEX, TAG_TYPE_LOCAL ):
state->items.string_min = state->items.string_max = value; state->items.string_min = state->items.string_max = value;
state->items.is_string_range = FALSE; state->items.flags &= ~HID_VALUE_CAPS_IS_STRING_RANGE;
break; break;
case SHORT_ITEM( TAG_LOCAL_STRING_MINIMUM, TAG_TYPE_LOCAL ): case SHORT_ITEM( TAG_LOCAL_STRING_MINIMUM, TAG_TYPE_LOCAL ):
state->items.string_min = value; state->items.string_min = value;
state->items.is_string_range = TRUE; state->items.flags |= HID_VALUE_CAPS_IS_STRING_RANGE;
break; break;
case SHORT_ITEM( TAG_LOCAL_STRING_MAXIMUM, TAG_TYPE_LOCAL ): case SHORT_ITEM( TAG_LOCAL_STRING_MAXIMUM, TAG_TYPE_LOCAL ):
state->items.string_max = value; state->items.string_max = value;
state->items.is_string_range = TRUE; state->items.flags |= HID_VALUE_CAPS_IS_STRING_RANGE;
break; break;
case SHORT_ITEM( TAG_LOCAL_DELIMITER, TAG_TYPE_LOCAL ): case SHORT_ITEM( TAG_LOCAL_DELIMITER, TAG_TYPE_LOCAL ):
FIXME( "delimiter %d not implemented!\n", value ); FIXME( "delimiter %d not implemented!\n", value );
......
...@@ -42,9 +42,7 @@ struct hid_value_caps ...@@ -42,9 +42,7 @@ struct hid_value_caps
USHORT string_max; USHORT string_max;
USHORT designator_min; USHORT designator_min;
USHORT designator_max; USHORT designator_max;
BOOLEAN is_range; ULONG flags;
BOOLEAN is_string_range;
BOOLEAN is_designator_range;
UCHAR report_id; UCHAR report_id;
USHORT link_collection; USHORT link_collection;
USAGE link_usage_page; USAGE link_usage_page;
...@@ -63,6 +61,10 @@ struct hid_value_caps ...@@ -63,6 +61,10 @@ struct hid_value_caps
ULONG units_exp; ULONG units_exp;
}; };
#define HID_VALUE_CAPS_IS_RANGE 0x10
#define HID_VALUE_CAPS_IS_STRING_RANGE 0x40
#define HID_VALUE_CAPS_IS_DESIGNATOR_RANGE 0x80
#define HID_VALUE_CAPS_IS_ABSOLUTE(x) (((x)->bit_field & 0x04) == 0) #define HID_VALUE_CAPS_IS_ABSOLUTE(x) (((x)->bit_field & 0x04) == 0)
#define HID_VALUE_CAPS_HAS_NULL(x) (((x)->bit_field & 0x40) != 0) #define HID_VALUE_CAPS_HAS_NULL(x) (((x)->bit_field & 0x40) != 0)
#define HID_VALUE_CAPS_IS_ARRAY(c) (((c)->bit_field & 2) == 0) #define HID_VALUE_CAPS_IS_ARRAY(c) (((c)->bit_field & 2) == 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment