Skip to content

hid: fix report_id extraction for interrupt OUT transfers#3683

Open
moxybaba wants to merge 1 commit into
hathach:masterfrom
moxybaba:fix/hid-interrupt-out-report-id
Open

hid: fix report_id extraction for interrupt OUT transfers#3683
moxybaba wants to merge 1 commit into
hathach:masterfrom
moxybaba:fix/hid-interrupt-out-report-id

Conversation

@moxybaba

@moxybaba moxybaba commented Jun 7, 2026

Copy link
Copy Markdown

Problem

In hidd_xfer_cb(), when an output report is received via interrupt
OUT endpoint, tud_hid_set_report_cb() is always called with
report_id=0.

Per HID spec section 8.2, when a device uses report IDs, the first
byte of an interrupt OUT transfer is the report ID followed by the
report data. This is already handled correctly in the SET_REPORT
control path but was missing for interrupt OUT transfers.

Fix

Extract report_id from the first byte of the output buffer when
non-zero and buffer length > 1, consistent with how the control
path handles report IDs.

Testing

Built hid_composite example for stm32f411blackpill successfully.

Fixes #2929

When receiving output reports via interrupt OUT endpoint, the report_id
was hardcoded to 0. Per HID spec section 8.2, when report IDs are used,
the first byte of an interrupt OUT transfer is the report ID.

Extract report_id from the first byte of the output buffer when non-zero
and buffer length > 1, consistent with how SET_REPORT control transfers
handle report IDs in hidd_control_xfer_cb().

Fixes hathach#2929
@HiFiPhile

Copy link
Copy Markdown
Collaborator

Hi, I think you pushed a wrong commit.

@hathach

hathach commented Jun 8, 2026

Copy link
Copy Markdown
Owner

how you know if the report has report-id in it, some does not use report-id at all (single report).

@moxybaba

moxybaba commented Jun 8, 2026

Copy link
Copy Markdown
Author

@hathach You're right, there's no reliable way to detect this from the transfer alone without knowing the descriptor.
Looking at mjrgh's suggestion in the original issue, a v2 callback with int report_id (passing -1 when unknown) would be the correct approach since it lets the application decide rather than the stack guessing.
Should I rework this to implement the v2 callback approach instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tud_hid_set_report_cb() is invoked with inconsistent arguments

3 participants