From patchwork Mon Mar 31 07:52:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aditya Garg X-Patchwork-Id: 14033214 X-Patchwork-Delegate: jikos@jikos.cz Received: from MA0PR01CU009.outbound.protection.outlook.com (mail-southindiaazolkn19010007.outbound.protection.outlook.com [52.103.67.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FE331D5147; Mon, 31 Mar 2025 07:53:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.103.67.7 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743407585; cv=fail; b=Hzx4tEPowmeLznVDuBsIdJVDAPVx/HL6sX5BvF6LHlJEYIvTThjBQ0Q9KTrBdMnhOzvK0SuA4jAuZcp1Pb9cTCF6v1Z5FyxSHlZAoMPVeuBiPkngmLBBEuxXyq0b0F547VihemURso/WYv36H2qMv6MFMdLt6DIKdKVFOgp73aE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743407585; c=relaxed/simple; bh=LCk9i/j/BhvloRvlrwVcZXldErQNzEJy0uNCdgACbtc=; h=Message-ID:Date:To:Cc:From:Subject:Content-Type:MIME-Version; b=agduN9tk7AgL9opM8nBy0sF/mOE0Yme7mVkKHDSjco7KL4zM+3pmnZUP2qUtpu1KJky/HEWHz9bDFPeVjkBizgXBnHN9BCigambey0eQBBd8Xd+7GUck8kZSl3hGaECKFP6RSGvu4qtjscj2GWicv7NUxehIMJQsjLiYtuoWvUM= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com; spf=pass smtp.mailfrom=live.com; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b=uieJzZvk; arc=fail smtp.client-ip=52.103.67.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=live.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=live.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=live.com header.i=@live.com header.b="uieJzZvk" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x/LG0vcLCUneSqNrb4EbzcKrD+NiC3XMnN+CPfNuOug8G4sthavSmPNi+1P8r4Ak3TuaNfdZWeMr2UebYSU1BOYGLV0CRqobJWnUAG6MtCwVP2Wd5KjfxvQG1hQePqIDiuW+kamXiZwdlNiZ5Wd+6FJng0Uz7rrusyhTJbMitVJDi6sTFipY1ivnyPOeQpeTz0SwXsBfEaCpZP1/iY1IPXKAOKay4S73bi7hDAF2Rde0hIQczdxTf727z7uCkr6Kc6IhthQD3fAtk1jtrR7HPk0FlLDJtBDYGKCUUBci01fkFp6KNQi2FKuSE0PVnAOapDQx0jdhYdSG0iXVSZXH7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AfhgnReNOkT4JdoJm3g9gNI4Uz3uOoqKYEDdE0SAEG8=; b=HSHrhrCBH+wONAAg5QAQ8z18Wthq/Li5O7OarFfj5r2nudoSqOvlkOvbF+2uC9j/2apMeDHSrv1JD2f3HwIlmnGZzo8Jls+nQH7NnYQ5SY9rqmOeG0tL9L5c7xy3ebMi0pUsA+QyNVHiB+lj/El7hh92bEUQKdOutykK9Z8buwazgBB/Qrmv5DbnfgVfUj1yiilwsDWBxl0w3Lx9EVfsmdFapZLLbY4t52o60yStDmYObmN7oww9AwGX5AvrZY2cw76+FQYdKMeYjPR65EpKqgvmQmZnjC75WMZ+O4SYxhqYB1S8RjiJp3ZA/BvKgBJndoJwO/XQBm9lPFNBR3tnOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AfhgnReNOkT4JdoJm3g9gNI4Uz3uOoqKYEDdE0SAEG8=; b=uieJzZvkK40hgSxjnfGihaXKpCRdDKSP2ZB4cJn5D8CXhricKauPDc77G6fl1IcQjaBsSaQI95DHeGdhr9Z9+ZJL5eOksBHZuP0bgX43HSWp52V78FTt23Yh0nI8mlW7iHBaqni7gyuzR3mEJuBrkVXlPtzCdIIdaF25HtYGVnYcLc6+fSBiqJJrnc24HriII1mRBokR0fBkzUmDrnXBC2+hm5F+rxQYjtlQ6vuVv1IDNx2/vjXe/xYCCW1RP0tco/c594IdKL3TXW3oiezK3ajHzXBCzhHApFMVyBvWye0gJjTXPrCXdCvZCQh+F5LtvqZhjQDbUjK8YuFvgNd05w== Received: from PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:f7::14) by MAZPR01MB8860.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:ce::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8583.38; Mon, 31 Mar 2025 07:52:58 +0000 Received: from PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM ([fe80::324:c085:10c8:4e77]) by PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM ([fe80::324:c085:10c8:4e77%7]) with mapi id 15.20.8583.033; Mon, 31 Mar 2025 07:52:58 +0000 Message-ID: Date: Mon, 31 Mar 2025 13:22:56 +0530 User-Agent: Mozilla Thunderbird Content-Language: en-US To: jikos@kernel.org, jkosina@suse.com, bentiss@kernel.org Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org From: Aditya Garg Subject: [PATCH v2] HID: magicmouse: Apple Magic Mouse 2 USB-C support X-ClientProxiedBy: PN3PR01CA0171.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:de::14) To PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:f7::14) X-Microsoft-Original-Message-ID: <9f98dfe8-006b-4cb4-9ed3-a1c57b491f5e@live.com> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PN3PR01MB9597:EE_|MAZPR01MB8860:EE_ X-MS-Office365-Filtering-Correlation-Id: cf5e232a-5453-4389-66fa-08dd70290d96 X-Microsoft-Antispam: BCL:0;ARA:14566002|15080799006|8060799006|7092599003|6090799003|19110799003|5072599009|461199028|5062599005|440099028|3412199025|41001999003; X-Microsoft-Antispam-Message-Info: =?utf-8?q?vvV2GVwlMtJshO4x4ExyLENlNouwMcY?= =?utf-8?q?f7Rco0osvhXCzNaxgC9vDGv82jJgSuXvm+3BoyGIpLYjmHWnPScO1tam4WHvESDXm?= =?utf-8?q?Fd5Ut24fQbPXsUjZvQeC40+4ffriEPmPknNpwxaDUwlNjnOVEZOTnosjFSuo6+SpN?= =?utf-8?q?xBtcyOTP2ANMR8fuh9Qfc10FhfW0Kw9DgpIffNUuBCqzhFf53S0IQzJzB3wJMzV/1?= =?utf-8?q?7PhS4znbpFKTk2Z1SQXlutzKYv9aHF1ja1h8NZ/yWDdaHVLlGNhOA3xFmLt9VNMTD?= =?utf-8?q?8woBZuMmQKIFL6gll+gJFCxjFMcdCa17UVkMqmJ1wyvCz3sfntF/XqyOrw+iytPDR?= =?utf-8?q?DOUENVSGcpX7q8HNOcn9FllUcWehzBMFw5tlfTDeCs7kXQYrvCHs0bJ5RbWOv2NG3?= =?utf-8?q?zmpMhLiKikJT6HovEnd4R3mHxjX/Q9xxG0H1/VsD/VbBpJxT76c76TxycfI5+zkjB?= =?utf-8?q?8aLCh0le6UO++s4Nb9GlNMO9k8JrPUKdRzoLFIh4+7DJOtDe5yOo9iiAS4IBSnSyd?= =?utf-8?q?to4u6RslaF6UXwAQ2X/O++3yuia49m2K4V4jHBWpLetcIfGfkIbJAhKLpnPQo7V86?= =?utf-8?q?GIwWi7Z2F9riIF/xQOumeJO4ZH4amOeJnDcCEiJoQpeVRLWBLNMx2M8DTJ+cgAViB?= =?utf-8?q?hGGDbj+n9nnK+GZo9OyLSnZQTz/uvxeHohE72+EQo78wZRNE4pLKrQiz39MAlXKXv?= =?utf-8?q?uRiN8tEhdz+1JnYpk10lN60LfHiGCzniNTqSDBRsRx6uJBYZXAt0Uw+Uk/v4MY/o8?= =?utf-8?q?pB2Ly7CYQ5nyOhxE67/W7rkdYlBVKL5XxgnjEIh5C6bDq/giH70TA85gNVVUd9wgv?= =?utf-8?q?90XSxzn4juyKXvPMgLVapu0TDKUir+G+2DfsN076Or0Pc7N9oYZCb6WjuB3lSYWEG?= =?utf-8?q?fm7+GpcU7rBzhP4WciohViOg1stoedVZADkxE4crloizF/GiuZCia3cLK3t7aL3Sm?= =?utf-8?q?lY7+BNZ/iLi3I/Y9MIdF9Qj46UNs7+68adjouSVYXqtoIWKX2Hs94JNJ3ZyEEeme1?= =?utf-8?q?M9Q58XxZojzrtVyxE+3WDqOJTFW4h6/q/XN2Bi2AEv4665AQJU3Oi2C7mr36UTnn6?= =?utf-8?q?G0MpFmn/bkiBDsMdxbbiCrhpVaL7GZ2sfTnM4+zl3f/qNQDekkvwM7hbMTnaylaho?= =?utf-8?q?UpiNoet0gKsScAkK7+1jn0Je7XcHFZ/p9/05A=3D=3D?= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?/dTqXlugMZFf4McGwcr9azrO5g/x?= =?utf-8?q?T/ukOI+/NFBGLym+EtEgheU2kA43NgMbQdhmHPdGYFKaU5UzO9w0zEzQggynQ8g+j?= =?utf-8?q?ZpfMoSW4ST+JHaVKylMmat+oZpklzRIu++f7OL06Rnr/JBYhBCEJ3+ll4WtXL/v5z?= =?utf-8?q?/F/KbwcKu9X2pIbPYgyLa/ZCR+lnd67xEmt2xf0foCBD2fTyVD1cUmYQFsOfVS9Qr?= =?utf-8?q?wmj4j+GKtJ0wkBsmBJMAixtEHm0P3bUxhIN7Q+6JMz8BWXbgkoVaHt4G6iqEK6KiZ?= =?utf-8?q?4FlmHdLmIrklQQ+PYOGbPZsob8d1GCmb0Wi/M5uzQA4H35kTJbrrws65RR73j8d/f?= =?utf-8?q?sMTaY0gCEcItr9rxxSTuRTtJMhXvseveVA2K9uKyu+QKYPDPafeReXBiw9jzeymIe?= =?utf-8?q?zm29Iio7MNOzGdlSrcUqgMzkXH5Os3EJ3aF7T7LAj1j8B+KeqHVnpB9LnYcT5rfym?= =?utf-8?q?Ujz0ply75YW3uKPIOCL+POAhXlw414Ir9TMZ19ZB1iF8V8kBk2Nx2UtP/8g/lMxo0?= =?utf-8?q?jbZ/cDONGob9Z9BkzJpqstVV5SbJv4SwYMyaNng13HXaycI4i3VEHIxWQKc7v1zag?= =?utf-8?q?fV6Jrmrzjj6gSyM51O6fA9yox4irwGltxqQNSNmdGMVisoQgdtQ9O+9CZGGDHI8I7?= =?utf-8?q?xetlg4rM8Xkyk+Za1CySSWK2SXaUMXFM8WtNuOPOMRwG9YMufUrvt/rjco0W/oL5I?= =?utf-8?q?tI1tPIgKXON0mdy1bpVUgXHMO7i41QA/YAl1wnEQpAw+9251ePOygaRrrjKj9iBMm?= =?utf-8?q?r6PHjuNdq6QRf5gQNpR2Vz8A2PK2ZH+sycT0Er/X9W0+XuQCZzi7NxXwuG/MnF59Z?= =?utf-8?q?whBPd+EwGaDMzpkWVCDfydGvg4OJsejAo2QBTi1yTBLK5lx7U5ikbr8qXDeYLekVT?= =?utf-8?q?xs4QeGKBvkf7df8KtWBjmK6lToXJqlm2HyKJ6Hm3p4ep0s3ATIZYIn8TnhRqT3nqe?= =?utf-8?q?tnhyNKGH9JNv1HZRAd4+4tXW9Rk5TWjXiLlQf4BdUWthb/nZMJn+dnmctDMUhz/Gm?= =?utf-8?q?ZhCjrYHPQtkDffXyfaU5nQKd5b25GFbz9XqJYTd/GLDjRm9Vi+MsX0US14slV7Pvw?= =?utf-8?q?PdHTb/qp+YEbGIehwvqzgNEsjIMz8FNEXs8gDuwKxkdSiS+tfqnx4FdlPG5wAjHuL?= =?utf-8?q?BoUxZyclwBkpbyGvbuxA0CLoApFDJ6++IPOWKQG2jfNRDWyo1ra2iUNphRZweOcZs?= =?utf-8?q?6+3/rrWe7vi+OA1qwGTO6SCBpuEme1zNZYRYSWQbnPIKAfj74bPXcQgUINyMBB7mN?= =?utf-8?q?zwa7PAH1ZUtxDviW?= X-OriginatorOrg: sct-15-20-7719-20-msonline-outlook-ae5c4.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: cf5e232a-5453-4389-66fa-08dd70290d96 X-MS-Exchange-CrossTenant-AuthSource: PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Mar 2025 07:52:58.2514 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MAZPR01MB8860 From: Aditya Garg This patch adds support for USB-C model of Apple Magic Mouse 2. Except for the hardware ID, it should resemble the existing configuration for the older Magic Mouse 2. Signed-off-by: Aditya Garg --- v2: Fix broken patch drivers/hid/hid-ids.h | 1 + drivers/hid/hid-magicmouse.c | 74 ++++++++++++++++++++++++------------ 2 files changed, 51 insertions(+), 24 deletions(-) diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 288a2b864..2d3f96af6 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -92,6 +92,7 @@ #define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304 #define USB_DEVICE_ID_APPLE_MAGICMOUSE 0x030d #define USB_DEVICE_ID_APPLE_MAGICMOUSE2 0x0269 +#define USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC 0x0323 #define USB_DEVICE_ID_APPLE_MAGICTRACKPAD 0x030e #define USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 0x0265 #define USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC 0x0324 diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c index a76f17158..423d50702 100644 --- a/drivers/hid/hid-magicmouse.c +++ b/drivers/hid/hid-magicmouse.c @@ -218,7 +218,8 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda int pressure = 0; if (input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE || - input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) { + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 || + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC) { id = (tdata[6] << 2 | tdata[5] >> 6) & 0xf; x = (tdata[1] << 28 | tdata[0] << 20) >> 20; y = -((tdata[2] << 24 | tdata[1] << 16) >> 20); @@ -370,7 +371,8 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda if (report_undeciphered) { if (input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE || - input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 || + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC) input_event(input, EV_MSC, MSC_RAW, tdata[7]); else if (input->id.product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 && @@ -497,7 +499,8 @@ static int magicmouse_raw_event(struct hid_device *hdev, } if (input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE || - input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) { + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 || + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC) { magicmouse_emit_buttons(msc, clicks & 3); input_report_rel(input, REL_X, x); input_report_rel(input, REL_Y, y); @@ -519,7 +522,8 @@ static int magicmouse_event(struct hid_device *hdev, struct hid_field *field, struct hid_usage *usage, __s32 value) { struct magicmouse_sc *msc = hid_get_drvdata(hdev); - if (msc->input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 && + if ((msc->input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 || + msc->input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC) && field->report->id == MOUSE2_REPORT_ID) { /* * magic_mouse_raw_event has done all the work. Skip hidinput. @@ -540,7 +544,8 @@ static int magicmouse_setup_input(struct input_dev *input, struct hid_device *hd __set_bit(EV_KEY, input->evbit); if (input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE || - input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) { + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 || + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC) { __set_bit(BTN_LEFT, input->keybit); __set_bit(BTN_RIGHT, input->keybit); if (emulate_3button) @@ -625,7 +630,8 @@ static int magicmouse_setup_input(struct input_dev *input, struct hid_device *hd * inverse of the reported Y. */ if (input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE || - input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) { + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 || + input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC) { input_set_abs_params(input, ABS_MT_ORIENTATION, -31, 32, 1, 0); input_set_abs_params(input, ABS_MT_POSITION_X, MOUSE_MIN_X, MOUSE_MAX_X, 4, 0); @@ -741,19 +747,25 @@ static int magicmouse_enable_multitouch(struct hid_device *hdev) int ret; int feature_size; - if (hdev->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 || - hdev->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC) { - if (hdev->vendor == BT_VENDOR_ID_APPLE) { + switch (hdev->product) { + case USB_DEVICE_ID_APPLE_MAGICTRACKPAD2: + case USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC: + switch (hdev->vendor) { + case BT_VENDOR_ID_APPLE: feature_size = sizeof(feature_mt_trackpad2_bt); feature = feature_mt_trackpad2_bt; - } else { /* USB_VENDOR_ID_APPLE */ + break; + default: /* USB_VENDOR_ID_APPLE */ feature_size = sizeof(feature_mt_trackpad2_usb); feature = feature_mt_trackpad2_usb; } - } else if (hdev->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) { + break; + case USB_DEVICE_ID_APPLE_MAGICMOUSE2: + case USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC: feature_size = sizeof(feature_mt_mouse2); feature = feature_mt_mouse2; - } else { + break; + default: feature_size = sizeof(feature_mt); feature = feature_mt; } @@ -787,6 +799,7 @@ static int magicmouse_fetch_battery(struct hid_device *hdev) if (!hdev->battery || hdev->vendor != USB_VENDOR_ID_APPLE || (hdev->product != USB_DEVICE_ID_APPLE_MAGICMOUSE2 && + hdev->product != USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC && hdev->product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 && hdev->product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC)) return -1; @@ -857,6 +870,7 @@ static int magicmouse_probe(struct hid_device *hdev, if (id->vendor == USB_VENDOR_ID_APPLE && (id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 || + id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC || ((id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 || id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC) && hdev->type != HID_TYPE_USBMOUSE))) @@ -868,21 +882,27 @@ static int magicmouse_probe(struct hid_device *hdev, goto err_stop_hw; } - if (id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE) - report = hid_register_report(hdev, HID_INPUT_REPORT, - MOUSE_REPORT_ID, 0); - else if (id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) - report = hid_register_report(hdev, HID_INPUT_REPORT, - MOUSE2_REPORT_ID, 0); - else if (id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 || - id->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC) { - if (id->vendor == BT_VENDOR_ID_APPLE) + switch (id->product) { + case USB_DEVICE_ID_APPLE_MAGICMOUSE: + report = hid_register_report(hdev, HID_INPUT_REPORT, MOUSE_REPORT_ID, 0); + break; + case USB_DEVICE_ID_APPLE_MAGICMOUSE2: + case USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC: + report = hid_register_report(hdev, HID_INPUT_REPORT, MOUSE2_REPORT_ID, 0); + break; + case USB_DEVICE_ID_APPLE_MAGICTRACKPAD2: + case USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC: + switch (id->vendor) { + case BT_VENDOR_ID_APPLE: report = hid_register_report(hdev, HID_INPUT_REPORT, TRACKPAD2_BT_REPORT_ID, 0); - else /* USB_VENDOR_ID_APPLE */ + break; + default: report = hid_register_report(hdev, HID_INPUT_REPORT, TRACKPAD2_USB_REPORT_ID, 0); - } else { /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */ + } + break; + default: /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */ report = hid_register_report(hdev, HID_INPUT_REPORT, TRACKPAD_REPORT_ID, 0); report = hid_register_report(hdev, HID_INPUT_REPORT, @@ -909,7 +929,8 @@ static int magicmouse_probe(struct hid_device *hdev, hid_err(hdev, "unable to request touch data (%d)\n", ret); goto err_stop_hw; } - if (ret == -EIO && id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) { + if (ret == -EIO && (id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 || + id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC)) { schedule_delayed_work(&msc->work, msecs_to_jiffies(500)); } @@ -945,6 +966,7 @@ static const __u8 *magicmouse_report_fixup(struct hid_device *hdev, __u8 *rdesc, */ if (hdev->vendor == USB_VENDOR_ID_APPLE && (hdev->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 || + hdev->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC || hdev->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 || hdev->product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC) && *rsize == 83 && rdesc[46] == 0x84 && rdesc[58] == 0x85) { @@ -971,6 +993,10 @@ static const struct hid_device_id magic_mice[] = { 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(BT_VENDOR_ID_APPLE, + USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC), .driver_data = 0 }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, + USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC), .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,