linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Add Apple Magic Trackpad 2021 support
@ 2021-12-12 18:20 José Expósito
  2021-12-12 18:20 ` [PATCH 1/2] HID: magicmouse: set device name when it has been personalized José Expósito
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: José Expósito @ 2021-12-12 18:20 UTC (permalink / raw)
  To: jikos
  Cc: benjamin.tissoires, rydberg, linux-input, linux-kernel,
	José Expósito

The Apple Magic Trackpad 2021 (3rd generation) is almost identical
to the 2nd generation devices.

The only meaningful change from the driver point of view is that
its name has changed.

This small series adds support for the device and solves a bug
caused when the default name of the device has been personalized.


José Expósito (2):
  HID: magicmouse: set device name when it has been personalized
  HID: magicmouse: set Magic Trackpad 2021 name

 drivers/hid/hid-magicmouse.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] HID: magicmouse: set device name when it has been personalized
  2021-12-12 18:20 [PATCH 0/2] Add Apple Magic Trackpad 2021 support José Expósito
@ 2021-12-12 18:20 ` José Expósito
  2021-12-12 18:21 ` [PATCH 2/2] HID: magicmouse: set Magic Trackpad 2021 name José Expósito
  2022-01-06 12:58 ` [PATCH 0/2] Add Apple Magic Trackpad 2021 support Jiri Kosina
  2 siblings, 0 replies; 4+ messages in thread
From: José Expósito @ 2021-12-12 18:20 UTC (permalink / raw)
  To: jikos
  Cc: benjamin.tissoires, rydberg, linux-input, linux-kernel,
	José Expósito

If the Apple Magic Trackpad 2 has been connected to a Mac, the name
is automatically personalized showing its owner name. For example:
"José Expósito's Trackpad".

When connected through Bluetooth, the personalized name is reported,
however, when connected through USB the generic name is reported.

Set the device name correctly to ensure the same driver settings are
loaded, whether connected via Bluetooth or USB.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
 drivers/hid/hid-magicmouse.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index d7687ce70614..e650ade15a7f 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -538,10 +538,18 @@ static int magicmouse_setup_input(struct input_dev *input, struct hid_device *hd
 			__set_bit(REL_HWHEEL_HI_RES, input->relbit);
 		}
 	} else if (input->id.product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2) {
-		/* setting the device name to ensure the same driver settings
-		 * get loaded, whether connected through bluetooth or USB
+		/* If the trackpad has been connected to a Mac, the name is
+		 * automatically personalized, e.g., "José Expósito's Trackpad".
+		 * When connected through Bluetooth, the personalized name is
+		 * reported, however, when connected through USB the generic
+		 * name is reported.
+		 * Set the device name to ensure the same driver settings get
+		 * loaded, whether connected through bluetooth or USB.
 		 */
-		input->name = "Apple Inc. Magic Trackpad 2";
+		if (hdev->vendor == BT_VENDOR_ID_APPLE)
+			input->name = "Apple Inc. Magic Trackpad 2";
+		else /* USB_VENDOR_ID_APPLE */
+			input->name = hdev->name;
 
 		__clear_bit(EV_MSC, input->evbit);
 		__clear_bit(BTN_0, input->keybit);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] HID: magicmouse: set Magic Trackpad 2021 name
  2021-12-12 18:20 [PATCH 0/2] Add Apple Magic Trackpad 2021 support José Expósito
  2021-12-12 18:20 ` [PATCH 1/2] HID: magicmouse: set device name when it has been personalized José Expósito
@ 2021-12-12 18:21 ` José Expósito
  2022-01-06 12:58 ` [PATCH 0/2] Add Apple Magic Trackpad 2021 support Jiri Kosina
  2 siblings, 0 replies; 4+ messages in thread
From: José Expósito @ 2021-12-12 18:21 UTC (permalink / raw)
  To: jikos
  Cc: benjamin.tissoires, rydberg, linux-input, linux-kernel,
	José Expósito

The Apple Magic Trackpad 2021 (3rd generation) has the same product ID
as the 2nd generation. However, when connected through Bluetooth, the
version has changed from 0x107 to 0x110.

The other meaningful change is that the name has dropped the generation
number and now it is just "Apple Inc. Magic Trackpad", like the first
generation model.

Set the device name correctly to ensure the same driver settings are
loaded, whether connected via Bluetooth or USB.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
---
 drivers/hid/hid-magicmouse.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
index e650ade15a7f..2ccded36dafd 100644
--- a/drivers/hid/hid-magicmouse.c
+++ b/drivers/hid/hid-magicmouse.c
@@ -51,6 +51,8 @@ static bool report_undeciphered;
 module_param(report_undeciphered, bool, 0644);
 MODULE_PARM_DESC(report_undeciphered, "Report undeciphered multi-touch state field using a MSC_RAW event");
 
+#define TRACKPAD2_2021_BT_VERSION 0x110
+
 #define TRACKPAD_REPORT_ID 0x28
 #define TRACKPAD2_USB_REPORT_ID 0x02
 #define TRACKPAD2_BT_REPORT_ID 0x31
@@ -546,10 +548,14 @@ static int magicmouse_setup_input(struct input_dev *input, struct hid_device *hd
 		 * Set the device name to ensure the same driver settings get
 		 * loaded, whether connected through bluetooth or USB.
 		 */
-		if (hdev->vendor == BT_VENDOR_ID_APPLE)
-			input->name = "Apple Inc. Magic Trackpad 2";
-		else /* USB_VENDOR_ID_APPLE */
+		if (hdev->vendor == BT_VENDOR_ID_APPLE) {
+			if (input->id.version == TRACKPAD2_2021_BT_VERSION)
+				input->name = "Apple Inc. Magic Trackpad";
+			else
+				input->name = "Apple Inc. Magic Trackpad 2";
+		} else { /* USB_VENDOR_ID_APPLE */
 			input->name = hdev->name;
+		}
 
 		__clear_bit(EV_MSC, input->evbit);
 		__clear_bit(BTN_0, input->keybit);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] Add Apple Magic Trackpad 2021 support
  2021-12-12 18:20 [PATCH 0/2] Add Apple Magic Trackpad 2021 support José Expósito
  2021-12-12 18:20 ` [PATCH 1/2] HID: magicmouse: set device name when it has been personalized José Expósito
  2021-12-12 18:21 ` [PATCH 2/2] HID: magicmouse: set Magic Trackpad 2021 name José Expósito
@ 2022-01-06 12:58 ` Jiri Kosina
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Kosina @ 2022-01-06 12:58 UTC (permalink / raw)
  To: José Expósito
  Cc: benjamin.tissoires, rydberg, linux-input, linux-kernel

On Sun, 12 Dec 2021, José Expósito wrote:

> The Apple Magic Trackpad 2021 (3rd generation) is almost identical
> to the 2nd generation devices.
> 
> The only meaningful change from the driver point of view is that
> its name has changed.
> 
> This small series adds support for the device and solves a bug
> caused when the default name of the device has been personalized.

Applied, thanks José.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-06 12:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-12 18:20 [PATCH 0/2] Add Apple Magic Trackpad 2021 support José Expósito
2021-12-12 18:20 ` [PATCH 1/2] HID: magicmouse: set device name when it has been personalized José Expósito
2021-12-12 18:21 ` [PATCH 2/2] HID: magicmouse: set Magic Trackpad 2021 name José Expósito
2022-01-06 12:58 ` [PATCH 0/2] Add Apple Magic Trackpad 2021 support Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).