Skip to content

fix(usbdevice): use printf with octal escapes for HID report descriptor#7

Open
frankurcrazy wants to merge 1 commit intoLubanCat:ubuntu20.04from
frankurcrazy:fix/hid-report-descriptor
Open

fix(usbdevice): use printf with octal escapes for HID report descriptor#7
frankurcrazy wants to merge 1 commit intoLubanCat:ubuntu20.04from
frankurcrazy:fix/hid-report-descriptor

Conversation

@frankurcrazy
Copy link

Summary

  • Fix hid_prepare() in usbdevice to write binary HID report descriptor correctly under dash

Problem

echo -ne "\x05\x01..." does not work in dash (the default /bin/sh). It writes literal text -ne \x05\x01... instead of binary bytes, breaking HID keyboard emulation entirely.

Fix

Replace echo -ne with printf using octal escapes, which work correctly across all POSIX shells.

Testing

Verified on RK3588 (LubanCat) with:

  • Android phone (normal mode + recovery mode)
  • iPhone

All devices successfully enumerate and receive HID keystrokes with the fix.

Fixes #6

🤖 Generated with Claude Code

The hid_prepare() function uses echo -ne to write the HID report
descriptor binary data. On systems where /bin/sh is dash (not bash),
echo does not support -ne flags, causing the descriptor to be written
as literal ASCII text (e.g., "-ne \x05\x01\x09\x06...") instead of
binary bytes.

This breaks HID keyboard emulation entirely — the USB host cannot
parse the descriptor, sends infinite bus resets, and writes to
/dev/hidg0 block indefinitely.

Replace echo -ne with printf using octal escapes, which work
correctly across all POSIX shells (bash, dash, sh).

Fixes: LubanCat#6
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.

usbdevice: hid_prepare() writes text instead of binary HID report descriptor

1 participant