From 619253e6ffa9babe7f672c74d5206896ffc2f465 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Tue, 13 Aug 2024 17:34:15 +0200 Subject: [PATCH] btstack_hid_parser: ignore Report ID in Descriptor Usage iterator bit position --- src/btstack_hid_parser.c | 6 +++++- src/btstack_hid_parser.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/btstack_hid_parser.c b/src/btstack_hid_parser.c index 06c396219..fa8d5f7f2 100644 --- a/src/btstack_hid_parser.c +++ b/src/btstack_hid_parser.c @@ -326,7 +326,7 @@ static void btstack_parser_usage_iterator_process_item(btstack_hid_usage_iterato btstack_hid_usage_iterator_handle_global_item(iterator, item); // track record id for report handling, reset report position if (report_id_before != iterator->global_report_id){ - iterator->report_pos_in_bit = 8u; + iterator->report_pos_in_bit = 0u; } break; case Local: @@ -491,6 +491,10 @@ void btstack_hid_parser_get_field(btstack_hid_parser_t * parser, uint16_t * usag *usage_page = parser->descriptor_usage_item.usage_page; *usage = parser->descriptor_usage_item.usage; + // skip optional Report ID + if (parser->descriptor_usage_item.report_id != HID_REPORT_ID_UNDEFINED){ + bit_pos += 8; + } // read field (up to 32 bit unsigned, up to 31 bit signed - 32 bit signed behaviour is undefined) - check report len bool is_variable = (parser->descriptor_usage_item.descriptor_item.item_value & 2) != 0; diff --git a/src/btstack_hid_parser.h b/src/btstack_hid_parser.h index bdc05f7ba..c5746c031 100644 --- a/src/btstack_hid_parser.h +++ b/src/btstack_hid_parser.h @@ -134,6 +134,8 @@ typedef struct { hid_descriptor_item_t descriptor_item; hid_report_type_t report_type; + + // report bit pos does not include the optional Report ID uint16_t report_pos_in_bit; // usage pos and usage_page after last main item, used to find next usage