News: 0001646520

  ARM Give a man a fire and he's warm for a day, but set fire to him and he's warm for the rest of his life (Terry Pratchett, Jingo)

Linux Patches Finally Allow Apple Magic Keyboard/Mouse Battery Monitoring Via Bluetooth

([Apple] 3 Hours Ago Apple Magic Keyboard + Mouse)


Besides the ongoing challenges of [1]enabling newer Apple Silicon SoC support on Linux , Apple peripheral support on Linux remains a mixed bag depending on the product as well. The latest functionality now being addressed is for having battery reporting work for the Apple Magic Mouse and Magic Keyboard when connected via Bluetooth.

Linux has already supported the [2]Magic Mouse and [3]Magic Keyboard for input devices, but one of the limitations has been that battery reporting only works if connected via USB... Not entirely useful as it's when connected wirelessly via Bluetooth that the battery levels are all the more important. Current Linux kernel versions will report 0% battery for the Apple devices via Bluetooth, which obviously isn't helpful at all.

Open-source developer Alec Hall published a set of patches to get the battery reporting over Bluetooth working for the Apple Magic Keyboard and the Magic Mouse 2 and Magic Trackpad 2. Alec explained with [4]the patch series addressing the notable defect:

"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)."

The patches are now under review for hopefully making these hid-magicmouse and hid-apple driver improvements reach the mainline Linux kernel.



[1] https://www.phoronix.com/news/Linux-DT-Apple-M3-Pro-Max-Ultra

[2] https://www.phoronix.com/search/Magic+Mouse

[3] https://www.phoronix.com/search/Magic+Keyboard

[4] https://lore.kernel.org/lkml/20260714101235.99447-1-signshop.alec@gmail.com/



I never pray before meals -- my mom's a good cook.