Skip to content

Add HID gamepad quirk fallback for broken SDP records

Pakrohk linux-bluetooth 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest3 patches 2 repliesIn review

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3src: add HMAC-SHA256 to bt_crypto using kernel AF_ALGsrc/shared/crypto.c src/shared/crypto.h+71 -01 reply
2/3input: add HID gamepad quirk fallback for broken SDP recordsprofiles/input/device.c profiles/input/quirk-profile.c profiles/input/quirk.c +2 more+46 -1271 reply
3/3tools: add bluez-quirkctl for managing quirk profilesMakefile.tools tools/quirkctl.c+183 -500 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH BlueZ v2 0/3] Add HID gamepad quirk fallback for broken SDP records

From: Pakrohk <[email protected]>

This patch series adds a modular quirk system that provides HID report descriptor fallbacks for third-party Bluetooth gamepads with incomplete or malformed SDP records.

Problem:
Third-party Bluetooth HID gamepads (notably TG170W / DualShock 4 v2 clones, VID:PID 054c:09cc) expose incomplete HID SDP records. BlueZ's extract_hid_record() fails with -ENOENT, preventing HIDP registration. The Bluetooth link is active but no /dev/input/event* device is created. Windows and Android handle this gracefully by falling back to known HID descriptors. BlueZ does not.

Solution:
A two-tier quirk system that activates only when SDP parsing fails for a specifically matched device. Does not globally weaken HID parsing.

hidp_add_connection()

    -> extract_hid_record()           // normal SDP path
      -> FAILS (-ENOENT)
    -> gamepad_quirk_apply()          // check built-in + external quirks
      -> inject fallback HID descriptor
    -> continue HIDP setup normally

Patch [1] adds HMAC-SHA256 to the internal bt_crypto library using the kernel AF_ALG interface, following the existing cmac(aes) pattern. This replaces the previous openssl CLI dependency.

Patch [2] adds the core quirk system: built-in quirk for TG170W/DS4 v2, external quirk profile loader with HMAC signature verification, and the device.c integration point.

Patch [3] adds bluez-quirkctl, a CLI tool for managing external quirk profiles (validate, install, list, remove).

External quirk profiles are JSON files installed to /var/lib/bluez/quirks/ with HMAC-SHA256 signatures, loaded at bluetoothd startup. This enables community-maintained gamepad support without BlueZ source modifications.

Testing:
- TG170W / DualShock 4 v2 (054c:09cc): buttons, sticks, touchpad verified via evtest
- Kernel creates three input devices: Wireless Controller, Wireless Controller Motion Sensors, Wireless Controller Touchpad
- External profile validation, installation, loading tested end-to-end
- Tampered profiles rejected by signature verification

---
Patch 1: src: add HMAC-SHA256 to bt_crypto using kernel AF_ALG Patch 2: input: add HID gamepad quirk fallback for broken SDP records Patch 3: tools: add bluez-quirkctl for managing quirk profiles

Signature · 1 line
2.49.0