From: "José Expósito" <jose.exposito89@gmail.com>
To: jikos@kernel.org
Cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org,
"José Expósito" <jose.exposito89@gmail.com>
Subject: [PATCH 4/5] HID: magicmouse: Magic Mouse 2 USB battery capacity
Date: Tue, 11 May 2021 20:20:22 +0200 [thread overview]
Message-ID: <20210511182023.730524-4-jose.exposito89@gmail.com> (raw)
In-Reply-To: <20210511182023.730524-1-jose.exposito89@gmail.com>
Report the battery capacity percentage for the Apple Magic Mouse 2
when it is connected over USB.
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
drivers/hid/hid-magicmouse.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index ea8a85767c39..53e8a10f0551 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -911,8 +911,17 @@ static int magicmouse_enable_multitouch(struct hid_device *hdev)
feature = feature_mt_trackpad2_usb;
}
} else if (hdev->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) {
- feature_size = sizeof(feature_mt_mouse2);
- feature = feature_mt_mouse2;
+ if (hdev->vendor == BT_VENDOR_ID_APPLE) {
+ feature_size = sizeof(feature_mt_mouse2);
+ feature = feature_mt_mouse2;
+ } else { /* USB_VENDOR_ID_APPLE */
+ /*
+ * The Magic Mouse 2 has the lightning connector on the
+ * bottom, making impossible to use it when it is
+ * charging.
+ */
+ return 0;
+ }
} else {
feature_size = sizeof(feature_mt);
feature = feature_mt;
@@ -947,7 +956,8 @@ static int magicmouse_probe(struct hid_device *hdev,
int ret;
if (id->vendor == USB_VENDOR_ID_APPLE &&
- id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 &&
+ (id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
+ id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) &&
hdev->type != HID_TYPE_USBMOUSE)
return 0;
@@ -1068,6 +1078,8 @@ static const struct hid_device_id magic_mice[] = {
USB_DEVICE_ID_APPLE_MAGICMOUSE), .driver_data = 0 },
{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE,
USB_DEVICE_ID_APPLE_MAGICMOUSE2), .driver_data = 0 },
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE,
+ USB_DEVICE_ID_APPLE_MAGICMOUSE2), .driver_data = 0 },
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
USB_DEVICE_ID_APPLE_MAGICTRACKPAD), .driver_data = 0 },
{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE,
--
2.25.1
next prev parent reply other threads:[~2021-05-11 18:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-11 18:20 [PATCH 1/5] HID: magicmouse: register power supply José Expósito
2021-05-11 18:20 ` [PATCH 2/5] HID: magicmouse: report battery capacity over bluetooth José Expósito
2021-05-11 18:20 ` [PATCH 3/5] HID: magicmouse: Magic Trackpad 2 USB battery capacity José Expósito
2021-05-12 9:39 ` kernel test robot
2021-05-15 18:50 ` José Expósito
2021-05-20 9:18 ` [kbuild-all] " Rong Chen
2021-05-22 17:41 ` José Expósito
2021-05-12 11:28 ` kernel test robot
2021-05-11 18:20 ` José Expósito [this message]
2021-05-11 18:20 ` [PATCH 5/5] HID: magicmouse: report battery status José Expósito
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=20210511182023.730524-4-jose.exposito89@gmail.com \
--to=jose.exposito89@gmail.com \
--cc=benjamin.tissoires@redhat.com \
--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
all inboxes | Powered by JetHome®