Skip to content

HID: Apple Magic Keyboard/Trackpad battery over Bluetooth

Alec Hall linux-input lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3HID: apple: report Magic Keyboard battery over Bluetoothdrivers/hid/hid-apple.c+19 -170 replies
2/3HID: magicmouse: report battery over Bluetoothdrivers/hid/hid-magicmouse.c+36 -260 replies
3/3HID: magicmouse: report charge status over Bluetoothdrivers/hid/hid-magicmouse.c+37 -05 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH 0/3] HID: Apple Magic Keyboard/Trackpad battery over Bluetooth

Apple's Magic Keyboard and Magic Trackpad 2 / Magic Mouse 2 report their battery to the host, but the kernel only surfaces it over USB; over Bluetooth the power_supply is stuck at 0%, even though these devices are used over Bluetooth nearly all the time.

Both drivers already fetch the battery (a GET_REPORT for input report 0x90) but only over USB. Enabling it over Bluetooth naively hard-locks the
machine: the fetch runs from a timer callback (atomic context) and the uhid transport sleeps inside hid_hw_request(). Each driver's patch therefore moves the fetch to a workqueue before enabling it over Bluetooth. The last patch teaches hid-magicmouse to report charge status from the device's status byte.

Patch 3 interprets a vendor status byte whose bit meanings were determined empirically; I can rework it as a report-descriptor fixup exposing HID_BAT_CHARGING instead if reviewers prefer.

Tested on a Magic Keyboard 2021 and a Magic Trackpad 2 over BlueZ (uhid).

Alec Hall (3):
HID: apple: report Magic Keyboard battery over Bluetooth
HID: magicmouse: report battery over Bluetooth
HID: magicmouse: report charge status over Bluetooth

 drivers/hid/hid-apple.c      | 36 ++++++-------
 drivers/hid/hid-magicmouse.c | 99 ++++++++++++++++++++++++++----------
 2 files changed, 92 insertions(+), 43 deletions(-)

base-commit: b7556c8e713c88596046a906c7c4385218d44736

Signature · 1 line
2.55.0