Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/hid/hidp.c | 9 +++++---- dlls/hidparse.sys/main.c | 7 ++++--- include/wine/hid.h | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/dlls/hid/hidp.c b/dlls/hid/hidp.c index 662d3da9d58..a1cdb951fd4 100644 --- a/dlls/hid/hidp.c +++ b/dlls/hid/hidp.c @@ -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++) { diff --git a/dlls/hidparse.sys/main.c b/dlls/hidparse.sys/main.c index ea4d84a6e81..3170abc50b5 100644 --- a/dlls/hidparse.sys/main.c +++ b/dlls/hidparse.sys/main.c @@ -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; diff --git a/include/wine/hid.h b/include/wine/hid.h index 7661850efc6..43f881bcc52 100644 --- a/include/wine/hid.h +++ b/include/wine/hid.h @@ -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 {