From 0a4fc5fb4cf07734e5d08b1a4aff4ac61888d491 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Mon, 12 Aug 2024 17:21:36 +0200 Subject: [PATCH] btstack_hid_parser: extract btstack_hid_main_item_tag_for_report_type --- src/btstack_hid_parser.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/btstack_hid_parser.c b/src/btstack_hid_parser.c index 523edc6d9..d2eae1e6a 100644 --- a/src/btstack_hid_parser.c +++ b/src/btstack_hid_parser.c @@ -188,6 +188,19 @@ bool btstack_hid_parse_descriptor_item(hid_descriptor_item_t * item, const uint8 return true; } +static bool btstack_hid_main_item_tag_matches_report_type(MainItemTag tag, hid_report_type_t report_type){ + switch (tag){ + case Input: + return report_type == HID_REPORT_TYPE_INPUT; + case Output: + return report_type == HID_REPORT_TYPE_OUTPUT; + case Feature: + return report_type == HID_REPORT_TYPE_FEATURE; + default: + return false; + } +} + static void btstack_hid_handle_global_item(btstack_hid_parser_t * parser, hid_descriptor_item_t * item){ switch((GlobalItemTag)item->item_tag){ case UsagePage: @@ -274,19 +287,8 @@ static void hid_process_item(btstack_hid_parser_t * parser, hid_descriptor_item_ uint16_t report_id_before; switch ((TagType)item->item_type){ case Main: - switch ((MainItemTag)item->item_tag){ - case Input: - valid_field = parser->report_type == HID_REPORT_TYPE_INPUT; - break; - case Output: - valid_field = parser->report_type == HID_REPORT_TYPE_OUTPUT; - break; - case Feature: - valid_field = parser->report_type == HID_REPORT_TYPE_FEATURE; - break; - default: - break; - } + valid_field = btstack_hid_main_item_tag_matches_report_type((MainItemTag) item->item_tag, + parser->report_type); break; case Global: report_id_before = parser->global_report_id;