Linux Input/HID development
 help / color / mirror / Atom feed
From: Julius Lehmann <lehmanju@devpi.de>
To: Jiri Kosina <jikos@kernel.org>, Benjamin Tissoires <bentiss@kernel.org>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Julius Lehmann <lehmanju@devpi.de>
Subject: [PATCH] HID: magicmouse: fix battery reporting for Apple Magic Trackpad 2
Date: Sat, 14 Feb 2026 20:34:21 +0100	[thread overview]
Message-ID: <20260214-magic-trackpad-usb-battery-v1-1-353bc63b56c0@devpi.de> (raw)

Battery reporting does not work for the Apple Magic Trackpad 2 if it is
connected via USB. The current hid descriptor fixup code checks for a
hid descriptor length of exactly 83 bytes. If the hid descriptor is
larger, which is the case for newer apple mice, the fixup is not
applied.

This fix checks for hid descriptor sizes greater/equal 83 bytes which
applies the fixup for newer devices as well.

---
Signed-off-by: Julius Lehmann <lehmanju@devpi.de>
---
 drivers/hid/hid-magicmouse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index 7d4a25c6de0eb7d36ad26a867004d58a1b6eae71..3fe191615a6d39fbe823e9e1a80fc65a7a12b9c4 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -985,7 +985,7 @@ static const __u8 *magicmouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 	 */
 	if ((is_usb_magicmouse2(hdev->vendor, hdev->product) ||
 	     is_usb_magictrackpad2(hdev->vendor, hdev->product)) &&
-	    *rsize == 83 && rdesc[46] == 0x84 && rdesc[58] == 0x85) {
+	    *rsize >= 83 && rdesc[46] == 0x84 && rdesc[58] == 0x85) {
 		hid_info(hdev,
 			 "fixing up magicmouse battery report descriptor\n");
 		*rsize = *rsize - 1;

---
base-commit: d3eeb99bbc99cc5eb94a4a75ed4415a0272254ef
change-id: 20260214-magic-trackpad-usb-battery-5a31b8c62d4f

Best regards,
-- 
Julius Lehmann <lehmanju@devpi.de>


             reply	other threads:[~2026-02-14 19:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-14 19:34 Julius Lehmann [this message]
2026-02-21  9:50 ` [PATCH] HID: magicmouse: fix battery reporting for Apple Magic Trackpad 2 Jiri Kosina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260214-magic-trackpad-usb-battery-v1-1-353bc63b56c0@devpi.de \
    --to=lehmanju@devpi.de \
    --cc=bentiss@kernel.org \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox