Skip to content
This repository was archived by the owner on Dec 14, 2025. It is now read-only.

Commit da596be

Browse files
committed
[ADAPTER] Fix parsing multiple identical HID usage
1 parent e09745e commit da596be

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

main/adapter/hid_parser.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,8 @@ void hid_parser(struct bt_data *bt_data, uint8_t *data, uint32_t len) {
502502
bool bitfield_merge = (usage_idx == 1 && hid_stack[hid_stack_idx].report_size == 1 && hid_stack[hid_stack_idx].report_cnt > 1);
503503
uint32_t usage_cnt = (bitfield_merge) ? 1 : hid_stack[hid_stack_idx].report_cnt;
504504
for (uint32_t i = 0; i < usage_cnt; i++) {
505-
if (hid_usage_is_used(hid_stack[hid_stack_idx].usage_page, usage_list[i])) {
505+
uint16_t usage = (usage_idx == 1) ? usage_list[0] : usage_list[i];
506+
if (hid_usage_is_used(hid_stack[hid_stack_idx].usage_page, usage)) {
506507
uint32_t frag_cnt = 1;
507508
if (bitfield_merge) {
508509
frag_cnt = hid_stack[hid_stack_idx].report_cnt / 32;
@@ -513,7 +514,7 @@ void hid_parser(struct bt_data *bt_data, uint8_t *data, uint32_t len) {
513514
for (uint32_t j = 0; j < frag_cnt; j++) {
514515
uint32_t usage_offset = j * 32;
515516
wip_report[tag_idx]->usages[report_usage_idx[tag_idx]].usage_page = hid_stack[hid_stack_idx].usage_page;
516-
wip_report[tag_idx]->usages[report_usage_idx[tag_idx]].usage = (usage_idx == 1) ? usage_list[0] : usage_list[i];
517+
wip_report[tag_idx]->usages[report_usage_idx[tag_idx]].usage = usage;
517518
wip_report[tag_idx]->usages[report_usage_idx[tag_idx]].usage += usage_offset;
518519
wip_report[tag_idx]->usages[report_usage_idx[tag_idx]].flags = *desc;
519520
wip_report[tag_idx]->usages[report_usage_idx[tag_idx]].bit_offset = report_bit_offset[tag_idx];

0 commit comments

Comments
 (0)