Commit 7efa63ee authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

hidparse.sys: Add HID_VALUE_CAPS_IS_BUTTON flag instead of checking bit_size / bit_field.

parent 9ade4305
......@@ -80,8 +80,8 @@ struct caps_filter
static BOOL match_value_caps( const struct hid_value_caps *caps, const struct caps_filter *filter )
{
if (!caps->usage_min && !caps->usage_max) return FALSE;
if (filter->buttons && !HID_VALUE_CAPS_IS_BUTTON( caps )) return FALSE;
if (filter->values && HID_VALUE_CAPS_IS_BUTTON( caps )) return FALSE;
if (filter->buttons && !(caps->flags & HID_VALUE_CAPS_IS_BUTTON)) return FALSE;
if (filter->values && (caps->flags & HID_VALUE_CAPS_IS_BUTTON)) return FALSE;
if (filter->usage_page && filter->usage_page != caps->usage_page) return FALSE;
if (filter->collection && filter->collection != caps->link_collection) return FALSE;
if (!filter->usage) return TRUE;
......@@ -836,8 +836,9 @@ NTSTATUS WINAPI HidP_GetUsagesEx( HIDP_REPORT_TYPE report_type, USHORT collectio
static NTSTATUS count_data( const struct hid_value_caps *caps, void *user )
{
BOOL is_button = caps->flags & HID_VALUE_CAPS_IS_BUTTON;
BOOL is_range = caps->flags & HID_VALUE_CAPS_IS_RANGE;
if (is_range || HID_VALUE_CAPS_IS_BUTTON( caps )) *(ULONG *)user += caps->report_count;
if (is_range || is_button) *(ULONG *)user += caps->report_count;
else *(ULONG *)user += 1;
return HIDP_STATUS_SUCCESS;
}
......@@ -892,7 +893,7 @@ static NTSTATUS find_all_data( const struct hid_value_caps *caps, void *user )
data++;
}
}
else if (HID_VALUE_CAPS_IS_BUTTON( caps ))
else if (caps->flags & HID_VALUE_CAPS_IS_BUTTON)
{
for (bit = caps->start_bit, last = bit + caps->usage_max - caps->usage_min; bit <= last; bit++)
{
......
......@@ -359,6 +359,7 @@ static BOOL parse_new_value_caps( struct hid_parser_state *state, HIDP_REPORT_TY
if (!(state->items.bit_field & INPUT_ABS_REL)) state->items.flags |= HID_VALUE_CAPS_IS_ABSOLUTE;
if (state->items.bit_field & INPUT_DATA_CONST) state->items.flags |= HID_VALUE_CAPS_IS_CONSTANT;
if (state->items.bit_size == 1 || is_array) state->items.flags |= HID_VALUE_CAPS_IS_BUTTON;
while (usages_size--)
{
......@@ -437,7 +438,7 @@ static struct hid_preparsed_data *build_preparsed_data( struct hid_parser_state
for (i = 0, button = 0, filler = 0; i < data->caps.NumberInputValueCaps; ++i)
{
if (!caps[i].usage_min && !caps[i].usage_max) filler++;
else if (HID_VALUE_CAPS_IS_BUTTON( caps + i )) button++;
else if (caps[i].flags & HID_VALUE_CAPS_IS_BUTTON) button++;
}
data->caps.NumberInputButtonCaps = button;
data->caps.NumberInputValueCaps -= filler + button;
......@@ -447,7 +448,7 @@ static struct hid_preparsed_data *build_preparsed_data( struct hid_parser_state
for (i = 0, button = 0, filler = 0; i < data->caps.NumberOutputValueCaps; ++i)
{
if (!caps[i].usage_min && !caps[i].usage_max) filler++;
else if (HID_VALUE_CAPS_IS_BUTTON( caps + i )) button++;
else if (caps[i].flags & HID_VALUE_CAPS_IS_BUTTON) button++;
}
caps += data->caps.NumberOutputValueCaps;
data->caps.NumberOutputButtonCaps = button;
......@@ -458,7 +459,7 @@ static struct hid_preparsed_data *build_preparsed_data( struct hid_parser_state
for (i = 0, button = 0, filler = 0; i < data->caps.NumberFeatureValueCaps; ++i)
{
if (!caps[i].usage_min && !caps[i].usage_max) filler++;
else if (HID_VALUE_CAPS_IS_BUTTON( caps + i )) button++;
else if (caps[i].flags & HID_VALUE_CAPS_IS_BUTTON) button++;
}
caps += data->caps.NumberFeatureValueCaps;
data->caps.NumberFeatureButtonCaps = button;
......
......@@ -63,6 +63,7 @@ struct hid_value_caps
/* named array continues on next caps */
#define HID_VALUE_CAPS_ARRAY_HAS_MORE 0x01
#define HID_VALUE_CAPS_IS_CONSTANT 0x02
#define HID_VALUE_CAPS_IS_BUTTON 0x04
#define HID_VALUE_CAPS_IS_ABSOLUTE 0x08
#define HID_VALUE_CAPS_IS_RANGE 0x10
#define HID_VALUE_CAPS_IS_STRING_RANGE 0x40
......@@ -70,7 +71,6 @@ struct hid_value_caps
#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_BUTTON(c) ((c)->bit_size == 1 || HID_VALUE_CAPS_IS_ARRAY(c))
struct hid_preparsed_data
{
......
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