Repository navigation
Conversation
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
📌 Code Review Assignment🏷️ Tag: componentsReviewers: @Maihuanyi Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-11-03 23:16 CST)
📝 Review Instructions
|
|
Hi, A gentle ping on this PR — it has been open for two weeks without activity.
Two things I would like to close out:
Happy to adjust anything. Thanks for your time. (For context: I have also claimed #7748, so the |
dbe8b2a to
7f3c0e0
Compare
|
7f3c0e0 to
ccf5abd
Compare
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
Fixes #7748.
In
components/legacy/usb/usbdevice/class/hid.cthe HID interface protocol is selected atcompile time with:
A || B || Cis already true when any one of the features is not defined, so the conditionholds in almost every configuration and the field is always
USB_HID_PROTOCOL_NONE(0):The
#elif !defined(RT_USB_DEVICE_HID_MOUSE)branch is unreachable (reaching it alreadyimplies
MOUSEis defined), while the interface is declared withbInterfaceSubClass = BOOT— a BOOT subclass reporting protocol
NONEis self-contradictory. Hosts that rely on the bootprotocol (BIOS/UEFI setup, KVMs) cannot treat this interface as a boot keyboard/mouse.
你的解决方案是什么 (what is your solution)
Judge keyboard and mouse separately, and stop letting the media-key feature influence this
field (media is not a boot-protocol device):
When keyboard and mouse are enabled together, a single interface cannot declare itself as
both, so the protocol stays
NONE(the combination is described by the IAD). The same blockappears twice (IAD
bFunctionProtocoland interfacebInterfaceProtocol); both are fixedidentically.
请提供验证的bsp和config (provide the config and bsp)
Verification, stated honestly:
scons -j4onbsp/qemu-vexpress-a9passes, but this BSP has no USB device controller, soclass/hid.cis not compiled there (if GetDepend('RT_USB_DEVICE_HID')incomponents/legacy/usb/usbdevice/SConscript). The build only shows that the change does notbreak the existing build.
combinations (table above). A full USB enumeration test would need a board with a USB device
controller (e.g. an STM32 BSP); I could not run that here. Please let me know if you want
that covered, or if a different verification is preferred.
About the "Check File Format and License" (clang-format) check: it may report violations for
this file, but the file already fails the same check without my change. Reproduced locally with
tools/ci/clang_format_check.pyand the same clang-format package used by CI:The cause is that
rt_align(4)has no trailing semicolon, so clang-format treats the followingdeclaration as a continuation and wants to re-indent the whole
_hid_comm_descinitializer(the
--linesrange is expanded to that construct). I did not reformat the file, because thatwould add a few hundred unrelated line changes. Happy to follow whatever you prefer here.
Also: this file lives under
components/legacy/. If fixes to the legacy USB device stack are nolonger accepted (and the same issue should instead be addressed in the CherryUSB stack), please
tell me and I will re-target the change.
Note on the diff size:
components/legacy/usb/usbdevice/class/hid.cis not clang-format clean onmaster (605 violations when checked with the pinned clang-format 22.1.8 from
tools/ci/requirements-format.txt). Because this change lives inside the HID report descriptorinitializer, the "Scan code format and license" job checks the whole enclosing initializer, so the
descriptor region is formatted with the pinned clang-format in this PR. That is where the extra
lines come from - there is no behaviour change.
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up