Skip to content

fix(hid-rp): gamepad and Xbox rumble reports no longer send uninitialized padding bits - #921

Merged
finger563 merged 1 commit into
mainfrom
fix/hid-rp-gamepad-test
Nov 22, 2026
Merged

finger563 merged 1 commit into
mainfrom
fix/hid-rp-gamepad-test

Conversation

@finger563

Copy link
Copy Markdown
Contributor

Description

hid_rp_gamepad_host_test failed one check, bytes[9] == 0, depending on what the stack held. It isn't a test bug: two reports really do send uninitialized bits.

  • GamepadInputReport's consumer byte was struct { uint8_t consumer_record : 1; uint8_t : 7; }.
  • XboxRumbleOutputReport's first byte was struct { uint8_t enabled : 4; uint8_t : 4; }.

Unnamed bit-fields cannot be assigned, so reset() cleared only the named bits, and the padding bits went out with whatever was in memory. That covers every gamepad input report, including espp's BLE / USB gamepads and the Xbox report, plus the rumble output report.

The fix:

  • Both bytes are now plain, zero-initialized uint8_ts with bit accessors. get_/set_consumer_record() and get_/set_enabled() mask to their bits, so the padding stays 0.
  • The formatters use the getters.
  • Layout and sizes are unchanged.

How has this been tested?

  • New deterministic regression checks build both reports in 0xFF-filled storage (placement new) and check that the padding comes out 0. Both checks fail on the old headers and pass now.
  • All four hid-rp host tests pass with g++ 16 (-std=c++23 -Wall -Wextra -Werror), including the previously failing one.
  • A new hid_rp_tests.yml workflow runs every hid-rp host test in CI. Only the report-map test ran before, from gamepad_map_tests.yml.
  • components/hid-rp/example builds for esp32s3.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation Update
  • Hardware (schematic, board, system design) change
  • Software change

Checklist:

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • I have updated the documentation accordingly.
  • I have updated the .github/workflows/build.yml file to add my new test to the automated cloud build github action.
  • All new and existing tests passed.
  • My code follows the code style of this project.

🤖 Generated with Claude Code

https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU

…ized padding bits

GamepadInputReport kept its consumer byte as
`struct { uint8_t consumer_record : 1; uint8_t : 7; }` and
XboxRumbleOutputReport its first byte as
`struct { uint8_t enabled : 4; uint8_t : 4; }`. Unnamed bit-fields cannot be
assigned, so reset() only cleared the named bits and the padding bits carried
whatever was in memory into every report (hid_rp_gamepad_host_test's
`bytes[9] == 0` caught it, depending on the stack's contents).

Both are now plain zero-initialized bytes with bit accessors
(get_/set_consumer_record(), get_/set_enabled() masking to their bits); the
formatters use the getters. Layout and sizes are unchanged.

Tests construct the reports in 0xFF-filled storage, so the regression check is
deterministic; both fail on the old headers. A new hid_rp_tests.yml workflow
runs every hid-rp host test in CI (only the report-map test ran before).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
@github-actions

Copy link
Copy Markdown

✅Static analysis result - no issues found! ✅

@finger563
finger563 merged commit 698045a into main Nov 22, 2026
187 checks passed
@finger563
finger563 deleted the fix/hid-rp-gamepad-test branch November 22, 2026 19:08
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.

1 participant