test/hid_parser: add tests for Descriptor Usage iterator

This commit is contained in:
Matthias Ringwald 2024-08-13 15:22:26 +02:00
parent 0ba748f214
commit 8f9863439f

View File

@ -576,6 +576,31 @@ TEST(HID, GetReportSize){
CHECK_EQUAL(8, report_size);
}
TEST(HID, UsageIteratorBootKeyboard){
const uint8_t * hid_descriptor = hid_descriptor_keyboard_boot_mode;
uint16_t hid_descriptor_len = sizeof(hid_descriptor_keyboard_boot_mode);
btstack_hid_parser_t parser;
btstack_hid_usage_iterator_init(&parser, hid_descriptor, hid_descriptor_len, HID_REPORT_TYPE_INPUT);
while (btstack_hid_usage_iterator_has_more(&parser)){
btstack_hid_usage_item_t item;
btstack_hid_usage_iterator_get_item(&parser, &item);
// printf("Report ID 0x%04x, bitpos %3u, usage page 0x%04x, usage 0x%04x, size %u\n", item.report_id, item.bit_pos, item.usage_page, item.usage, item.size);
}
}
TEST(HID, UsageIteratorCombo1){
const uint8_t * hid_descriptor = combo_descriptor_with_report_ids;
uint16_t hid_descriptor_len = sizeof(combo_descriptor_with_report_ids);
btstack_hid_parser_t parser;
btstack_hid_usage_iterator_init(&parser, hid_descriptor, hid_descriptor_len, HID_REPORT_TYPE_INPUT);
while (btstack_hid_usage_iterator_has_more(&parser)){
btstack_hid_usage_item_t item;
btstack_hid_usage_iterator_get_item(&parser, &item);
// printf("Report ID 0x%04x, bitpos %3u, usage page 0x%04x, usage 0x%04x, size %u\n", item.report_id, item.bit_pos, item.usage_page, item.usage, item.size);
}
}
#include "btstack_debug.h"
int main (int argc, const char * argv[]){
#if 1