You've already forked linux-t2-patches
mirror of
https://github.com/t2linux/linux-t2-patches.git
synced 2026-04-30 13:52:11 -07:00
517 lines
18 KiB
Diff
517 lines
18 KiB
Diff
From c2e1c104044b02b21e8db083fb4401fd30e9f5a8 Mon Sep 17 00:00:00 2001
|
|
From: Aditya Garg <gargaditya08@live.com>
|
|
Date: Tue, 11 Mar 2025 18:44:06 +0530
|
|
Subject: [PATCH 3/3] HID: magicmouse: Add support for trackpads found on T2
|
|
Macs
|
|
|
|
This patch adds support for trackpads found on Macs with the T2
|
|
Security Chip. The touch report format differs from other trackpads.
|
|
It is the same format as type 4 in bcm5974.c
|
|
|
|
Signed-off-by: Aditya Garg <gargaditya08@live.com>
|
|
---
|
|
drivers/hid/hid-magicmouse.c | 408 ++++++++++++++++++++++++++++++-----
|
|
1 file changed, 360 insertions(+), 48 deletions(-)
|
|
|
|
diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
|
|
index d5ab547b1..70934a221 100644
|
|
--- a/drivers/hid/hid-magicmouse.c
|
|
+++ b/drivers/hid/hid-magicmouse.c
|
|
@@ -117,6 +117,94 @@ MODULE_PARM_DESC(report_undeciphered, "Report undeciphered multi-touch state fie
|
|
#define TRACKPAD2_RES_Y \
|
|
((TRACKPAD2_MAX_Y - TRACKPAD2_MIN_Y) / (TRACKPAD2_DIMENSION_Y / 100))
|
|
|
|
+#define J140K_TP_DIMENSION_X (float)12100
|
|
+#define J140K_TP_MIN_X -5318
|
|
+#define J140K_TP_MAX_X 5787
|
|
+#define J140K_TP_RES_X \
|
|
+ ((J140K_TP_MAX_X - J140K_TP_MIN_X) / (J140K_TP_DIMENSION_X / 100))
|
|
+#define J140K_TP_DIMENSION_Y (float)8200
|
|
+#define J140K_TP_MIN_Y -157
|
|
+#define J140K_TP_MAX_Y 7102
|
|
+#define J140K_TP_RES_Y \
|
|
+ ((J140K_TP_MAX_Y - J140K_TP_MIN_Y) / (J140K_TP_DIMENSION_Y / 100))
|
|
+
|
|
+#define J132_TP_DIMENSION_X (float)13500
|
|
+#define J132_TP_MIN_X -6243
|
|
+#define J132_TP_MAX_X 6749
|
|
+#define J132_TP_RES_X \
|
|
+ ((J132_TP_MAX_X - J132_TP_MIN_X) / (J132_TP_DIMENSION_X / 100))
|
|
+#define J132_TP_DIMENSION_Y (float)8400
|
|
+#define J132_TP_MIN_Y -170
|
|
+#define J132_TP_MAX_Y 7685
|
|
+#define J132_TP_RES_Y \
|
|
+ ((J132_TP_MAX_Y - J132_TP_MIN_Y) / (J132_TP_DIMENSION_Y / 100))
|
|
+
|
|
+#define J680_TP_DIMENSION_X (float)16000
|
|
+#define J680_TP_MIN_X -7456
|
|
+#define J680_TP_MAX_X 7976
|
|
+#define J680_TP_RES_X \
|
|
+ ((J680_TP_MAX_X - J680_TP_MIN_X) / (J680_TP_DIMENSION_X / 100))
|
|
+#define J680_TP_DIMENSION_Y (float)10000
|
|
+#define J680_TP_MIN_Y -163
|
|
+#define J680_TP_MAX_Y 9283
|
|
+#define J680_TP_RES_Y \
|
|
+ ((J680_TP_MAX_Y - J680_TP_MIN_Y) / (J680_TP_DIMENSION_Y / 100))
|
|
+
|
|
+#define J213_TP_DIMENSION_X (float)13500
|
|
+#define J213_TP_MIN_X -6243
|
|
+#define J213_TP_MAX_X 6749
|
|
+#define J213_TP_RES_X \
|
|
+ ((J213_TP_MAX_X - J213_TP_MIN_X) / (J213_TP_DIMENSION_X / 100))
|
|
+#define J213_TP_DIMENSION_Y (float)8400
|
|
+#define J213_TP_MIN_Y -170
|
|
+#define J213_TP_MAX_Y 7685
|
|
+#define J213_TP_RES_Y \
|
|
+ ((J213_TP_MAX_Y - J213_TP_MIN_Y) / (J213_TP_DIMENSION_Y / 100))
|
|
+
|
|
+#define J214K_TP_DIMENSION_X (float)13200
|
|
+#define J214K_TP_MIN_X -6046
|
|
+#define J214K_TP_MAX_X 6536
|
|
+#define J214K_TP_RES_X \
|
|
+ ((J214K_TP_MAX_X - J214K_TP_MIN_X) / (J214K_TP_DIMENSION_X / 100))
|
|
+#define J214K_TP_DIMENSION_Y (float)8200
|
|
+#define J214K_TP_MIN_Y -164
|
|
+#define J214K_TP_MAX_Y 7439
|
|
+#define J214K_TP_RES_Y \
|
|
+ ((J214K_TP_MAX_Y - J214K_TP_MIN_Y) / (J214K_TP_DIMENSION_Y / 100))
|
|
+
|
|
+#define J223_TP_DIMENSION_X (float)13200
|
|
+#define J223_TP_MIN_X -6046
|
|
+#define J223_TP_MAX_X 6536
|
|
+#define J223_TP_RES_X \
|
|
+ ((J223_TP_MAX_X - J223_TP_MIN_X) / (J223_TP_DIMENSION_X / 100))
|
|
+#define J223_TP_DIMENSION_Y (float)8200
|
|
+#define J223_TP_MIN_Y -164
|
|
+#define J223_TP_MAX_Y 7439
|
|
+#define J223_TP_RES_Y \
|
|
+ ((J223_TP_MAX_Y - J223_TP_MIN_Y) / (J223_TP_DIMENSION_Y / 100))
|
|
+
|
|
+#define J230K_TP_DIMENSION_X (float)12100
|
|
+#define J230K_TP_MIN_X -5318
|
|
+#define J230K_TP_MAX_X 5787
|
|
+#define J230K_TP_RES_X \
|
|
+ ((J230K_TP_MAX_X - J230K_TP_MIN_X) / (J230K_TP_DIMENSION_X / 100))
|
|
+#define J230K_TP_DIMENSION_Y (float)8200
|
|
+#define J230K_TP_MIN_Y -157
|
|
+#define J230K_TP_MAX_Y 7102
|
|
+#define J230K_TP_RES_Y \
|
|
+ ((J230K_TP_MAX_Y - J230K_TP_MIN_Y) / (J230K_TP_DIMENSION_Y / 100))
|
|
+
|
|
+#define J152F_TP_DIMENSION_X (float)16000
|
|
+#define J152F_TP_MIN_X -7456
|
|
+#define J152F_TP_MAX_X 7976
|
|
+#define J152F_TP_RES_X \
|
|
+ ((J152F_TP_MAX_X - J152F_TP_MIN_X) / (J152F_TP_DIMENSION_X / 100))
|
|
+#define J152F_TP_DIMENSION_Y (float)10000
|
|
+#define J152F_TP_MIN_Y -163
|
|
+#define J152F_TP_MAX_Y 9283
|
|
+#define J152F_TP_RES_Y \
|
|
+ ((J152F_TP_MAX_Y - J152F_TP_MIN_Y) / (J152F_TP_DIMENSION_Y / 100))
|
|
+
|
|
/* These are fallback values, since the real values will be queried from the device. */
|
|
#define J314_TP_DIMENSION_X (float)13000
|
|
#define J314_TP_MIN_X -5900
|
|
@@ -129,7 +217,11 @@ MODULE_PARM_DESC(report_undeciphered, "Report undeciphered multi-touch state fie
|
|
#define J314_TP_RES_Y \
|
|
((J314_TP_MAX_Y - J314_TP_MIN_Y) / (J314_TP_DIMENSION_Y / 100))
|
|
|
|
-#define J314_TP_MAX_FINGER_ORIENTATION 16384
|
|
+#define T2_TOUCHPAD_ENTRY(model) \
|
|
+ { USB_DEVICE_ID_APPLE_WELLSPRINGT2_##model, model##_TP_MIN_X, model##_TP_MIN_Y, \
|
|
+model##_TP_MAX_X, model##_TP_MAX_Y, model##_TP_RES_X, model##_TP_RES_Y }
|
|
+
|
|
+#define INTERNAL_TP_MAX_FINGER_ORIENTATION 16384
|
|
|
|
struct magicmouse_input_ops {
|
|
int (*raw_event)(struct hid_device *hdev,
|
|
@@ -196,24 +288,45 @@ 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) {
|
|
- feature_size = sizeof(feature_mt_trackpad2_bt);
|
|
- feature = feature_mt_trackpad2_bt;
|
|
- } else { /* USB_VENDOR_ID_APPLE */
|
|
+ switch (hdev->bus) {
|
|
+ case BUS_SPI:
|
|
+ case BUS_HOST:
|
|
+ feature_size = sizeof(feature_mt_trackpad2_usb);
|
|
+ feature = feature_mt_trackpad2_usb;
|
|
+ break;
|
|
+ default:
|
|
+ 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;
|
|
+ break;
|
|
+ default: /* USB_VENDOR_ID_APPLE */
|
|
+ feature_size = sizeof(feature_mt_trackpad2_usb);
|
|
+ feature = feature_mt_trackpad2_usb;
|
|
+ }
|
|
+ break;
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F:
|
|
feature_size = sizeof(feature_mt_trackpad2_usb);
|
|
feature = feature_mt_trackpad2_usb;
|
|
+ break;
|
|
+ case USB_DEVICE_ID_APPLE_MAGICMOUSE2:
|
|
+ feature_size = sizeof(feature_mt_mouse2);
|
|
+ feature = feature_mt_mouse2;
|
|
+ break;
|
|
+ default:
|
|
+ feature_size = sizeof(feature_mt);
|
|
+ feature = feature_mt;
|
|
}
|
|
- } else if (hdev->vendor == SPI_VENDOR_ID_APPLE) {
|
|
- feature_size = sizeof(feature_mt_trackpad2_usb);
|
|
- feature = feature_mt_trackpad2_usb;
|
|
- } else if (hdev->product == USB_DEVICE_ID_APPLE_MAGICMOUSE2) {
|
|
- feature_size = sizeof(feature_mt_mouse2);
|
|
- feature = feature_mt_mouse2;
|
|
- } else {
|
|
- feature_size = sizeof(feature_mt);
|
|
- feature = feature_mt;
|
|
}
|
|
|
|
buf = kmemdup(feature, feature_size, GFP_KERNEL);
|
|
@@ -784,7 +897,7 @@ static void report_finger_data(struct input_dev *input, int slot,
|
|
input_report_abs(input, ABS_MT_WIDTH_MINOR,
|
|
le16_to_int(f->tool_minor) << 1);
|
|
input_report_abs(input, ABS_MT_ORIENTATION,
|
|
- J314_TP_MAX_FINGER_ORIENTATION - le16_to_int(f->orientation));
|
|
+ INTERNAL_TP_MAX_FINGER_ORIENTATION - le16_to_int(f->orientation));
|
|
input_report_abs(input, ABS_MT_PRESSURE, le16_to_int(f->pressure));
|
|
input_report_abs(input, ABS_MT_POSITION_X, pos->x);
|
|
input_report_abs(input, ABS_MT_POSITION_Y, pos->y);
|
|
@@ -872,6 +985,20 @@ static int magicmouse_raw_event_spi(struct hid_device *hdev,
|
|
return magicmouse_raw_event_mtp(hdev, report, data + hdr_sz, size - hdr_sz);
|
|
}
|
|
|
|
+static int magicmouse_raw_event_t2(struct hid_device *hdev,
|
|
+ struct hid_report *report, u8 *data, int size)
|
|
+{
|
|
+ const size_t hdr_sz = sizeof(struct tp_mouse_report);
|
|
+
|
|
+ if (!size)
|
|
+ return 0;
|
|
+
|
|
+ if (data[0] != TRACKPAD2_USB_REPORT_ID || size < hdr_sz)
|
|
+ return 0;
|
|
+
|
|
+ return magicmouse_raw_event_mtp(hdev, report, data + hdr_sz, size - hdr_sz);
|
|
+}
|
|
+
|
|
static int magicmouse_event(struct hid_device *hdev, struct hid_field *field,
|
|
struct hid_usage *usage, __s32 value)
|
|
{
|
|
@@ -1063,6 +1190,124 @@ static int magicmouse_setup_input_usb(struct input_dev *input,
|
|
return 0;
|
|
}
|
|
|
|
+struct magicmouse_t2_properties {
|
|
+ u32 id;
|
|
+ int min_x;
|
|
+ int min_y;
|
|
+ int max_x;
|
|
+ int max_y;
|
|
+ int res_x;
|
|
+ int res_y;
|
|
+};
|
|
+
|
|
+static const struct magicmouse_t2_properties magicmouse_t2_configs[] = {
|
|
+ T2_TOUCHPAD_ENTRY(J140K),
|
|
+ T2_TOUCHPAD_ENTRY(J132),
|
|
+ T2_TOUCHPAD_ENTRY(J680),
|
|
+ T2_TOUCHPAD_ENTRY(J213),
|
|
+ T2_TOUCHPAD_ENTRY(J214K),
|
|
+ T2_TOUCHPAD_ENTRY(J223),
|
|
+ T2_TOUCHPAD_ENTRY(J230K),
|
|
+ T2_TOUCHPAD_ENTRY(J152F),
|
|
+};
|
|
+
|
|
+static int magicmouse_setup_input_t2(struct input_dev *input,
|
|
+ struct hid_device *hdev)
|
|
+{
|
|
+ int min_x, min_y, max_x, max_y, res_x, res_y, error;
|
|
+ int mt_flags = 0;
|
|
+ struct magicmouse_sc *msc = hid_get_drvdata(hdev);
|
|
+
|
|
+ for (size_t i = 0; i < ARRAY_SIZE(magicmouse_t2_configs); i++) {
|
|
+ if (magicmouse_t2_configs[i].id == hdev->product) {
|
|
+ min_x = magicmouse_t2_configs[i].min_x;
|
|
+ min_y = magicmouse_t2_configs[i].min_y;
|
|
+ max_x = magicmouse_t2_configs[i].max_x;
|
|
+ max_y = magicmouse_t2_configs[i].max_y;
|
|
+ res_x = magicmouse_t2_configs[i].res_x;
|
|
+ res_y = magicmouse_t2_configs[i].res_y;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ __set_bit(INPUT_PROP_BUTTONPAD, input->propbit);
|
|
+ __clear_bit(BTN_0, input->keybit);
|
|
+ __clear_bit(BTN_RIGHT, input->keybit);
|
|
+ __clear_bit(BTN_MIDDLE, input->keybit);
|
|
+ __clear_bit(EV_REL, input->evbit);
|
|
+ __clear_bit(REL_X, input->relbit);
|
|
+ __clear_bit(REL_Y, input->relbit);
|
|
+
|
|
+ mt_flags = INPUT_MT_POINTER | INPUT_MT_DROP_UNUSED | INPUT_MT_TRACK;
|
|
+
|
|
+ /* finger touch area */
|
|
+ input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, 5000, 0, 0);
|
|
+ input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0, 5000, 0, 0);
|
|
+
|
|
+ /* finger approach area */
|
|
+ input_set_abs_params(input, ABS_MT_WIDTH_MAJOR, 0, 5000, 0, 0);
|
|
+ input_set_abs_params(input, ABS_MT_WIDTH_MINOR, 0, 5000, 0, 0);
|
|
+
|
|
+ /* Note: Touch Y position from the device is inverted relative
|
|
+ * to how pointer motion is reported (and relative to how USB
|
|
+ * HID recommends the coordinates work). This driver keeps
|
|
+ * the origin at the same position, and just uses the additive
|
|
+ * inverse of the reported Y.
|
|
+ */
|
|
+
|
|
+ input_set_abs_params(input, ABS_MT_PRESSURE, 0, 6000, 0, 0);
|
|
+
|
|
+ /*
|
|
+ * This makes libinput recognize this as a PressurePad and
|
|
+ * stop trying to use pressure for touch size. Pressure unit
|
|
+ * seems to be ~grams on these touchpads.
|
|
+ */
|
|
+ input_abs_set_res(input, ABS_MT_PRESSURE, 1);
|
|
+
|
|
+ /* finger orientation */
|
|
+ input_set_abs_params(input, ABS_MT_ORIENTATION, -INTERNAL_TP_MAX_FINGER_ORIENTATION,
|
|
+ INTERNAL_TP_MAX_FINGER_ORIENTATION, 0, 0);
|
|
+
|
|
+ /* finger position */
|
|
+ input_set_abs_params(input, ABS_MT_POSITION_X, min_x, max_x,
|
|
+ 0, 0);
|
|
+ /* Y axis is inverted */
|
|
+ input_set_abs_params(input, ABS_MT_POSITION_Y, -max_y, -min_y,
|
|
+ 0, 0);
|
|
+
|
|
+ /* X/Y resolution */
|
|
+ input_abs_set_res(input, ABS_MT_POSITION_X, res_x);
|
|
+ input_abs_set_res(input, ABS_MT_POSITION_Y, res_y);
|
|
+
|
|
+ input_set_events_per_packet(input, 60);
|
|
+
|
|
+ /* touchpad button */
|
|
+ input_set_capability(input, EV_KEY, BTN_MOUSE);
|
|
+
|
|
+ /*
|
|
+ * hid-input may mark device as using autorepeat, but the trackpad does
|
|
+ * not actually want it.
|
|
+ */
|
|
+ __clear_bit(EV_REP, input->evbit);
|
|
+
|
|
+ error = input_mt_init_slots(input, MAX_CONTACTS, mt_flags);
|
|
+ if (error)
|
|
+ return error;
|
|
+
|
|
+ /*
|
|
+ * Override the default input->open function to send the MT
|
|
+ * enable every time the device is opened. This ensures it works
|
|
+ * even if we missed a reset event due to the device being closed.
|
|
+ * input->close is overridden for symmetry.
|
|
+ *
|
|
+ * This also takes care of the dimensions query.
|
|
+ */
|
|
+ input->open = magicmouse_open;
|
|
+ input->close = magicmouse_close;
|
|
+ msc->query_dimensions = false;
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
static int magicmouse_setup_input_mtp(struct input_dev *input,
|
|
struct hid_device *hdev)
|
|
{
|
|
@@ -1105,8 +1350,8 @@ static int magicmouse_setup_input_mtp(struct input_dev *input,
|
|
input_abs_set_res(input, ABS_MT_PRESSURE, 1);
|
|
|
|
/* finger orientation */
|
|
- input_set_abs_params(input, ABS_MT_ORIENTATION, -J314_TP_MAX_FINGER_ORIENTATION,
|
|
- J314_TP_MAX_FINGER_ORIENTATION, 0, 0);
|
|
+ input_set_abs_params(input, ABS_MT_ORIENTATION, -INTERNAL_TP_MAX_FINGER_ORIENTATION,
|
|
+ INTERNAL_TP_MAX_FINGER_ORIENTATION, 0, 0);
|
|
|
|
/* finger position */
|
|
input_set_abs_params(input, ABS_MT_POSITION_X, J314_TP_MIN_X, J314_TP_MAX_X,
|
|
@@ -1244,8 +1489,22 @@ static int magicmouse_probe(struct hid_device *hdev,
|
|
int ret;
|
|
|
|
if ((id->bus == BUS_SPI || id->bus == BUS_HOST) && id->vendor == SPI_VENDOR_ID_APPLE &&
|
|
- hdev->type != HID_TYPE_SPI_MOUSE)
|
|
- return -ENODEV;
|
|
+ hdev->type != HID_TYPE_SPI_MOUSE)
|
|
+ return -ENODEV;
|
|
+
|
|
+ switch (id->product) {
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F:
|
|
+ if (hdev->type != HID_TYPE_USBMOUSE)
|
|
+ return -ENODEV;
|
|
+ break;
|
|
+ }
|
|
|
|
msc = devm_kzalloc(&hdev->dev, sizeof(*msc), GFP_KERNEL);
|
|
if (msc == NULL) {
|
|
@@ -1255,16 +1514,32 @@ static int magicmouse_probe(struct hid_device *hdev,
|
|
|
|
// internal trackpad use a data format use input ops to avoid
|
|
// conflicts with the report ID.
|
|
- if (id->bus == BUS_HOST) {
|
|
+ switch (id->bus) {
|
|
+ case BUS_HOST:
|
|
msc->input_ops.raw_event = magicmouse_raw_event_mtp;
|
|
msc->input_ops.setup_input = magicmouse_setup_input_mtp;
|
|
- } else if (id->bus == BUS_SPI) {
|
|
+ break;
|
|
+ case BUS_SPI:
|
|
msc->input_ops.raw_event = magicmouse_raw_event_spi;
|
|
msc->input_ops.setup_input = magicmouse_setup_input_spi;
|
|
-
|
|
- } else {
|
|
- msc->input_ops.raw_event = magicmouse_raw_event_usb;
|
|
- msc->input_ops.setup_input = magicmouse_setup_input_usb;
|
|
+ break;
|
|
+ default:
|
|
+ switch (id->product) {
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F:
|
|
+ msc->input_ops.raw_event = magicmouse_raw_event_t2;
|
|
+ msc->input_ops.setup_input = magicmouse_setup_input_t2;
|
|
+ break;
|
|
+ default:
|
|
+ msc->input_ops.raw_event = magicmouse_raw_event_usb;
|
|
+ msc->input_ops.setup_input = magicmouse_setup_input_usb;
|
|
+ }
|
|
}
|
|
|
|
msc->scroll_accel = SCROLL_ACCEL_DEFAULT;
|
|
@@ -1304,29 +1579,50 @@ 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)
|
|
- report = hid_register_report(hdev, HID_INPUT_REPORT,
|
|
- TRACKPAD2_BT_REPORT_ID, 0);
|
|
- else /* USB_VENDOR_ID_APPLE */
|
|
- report = hid_register_report(hdev, HID_INPUT_REPORT,
|
|
- TRACKPAD2_USB_REPORT_ID, 0);
|
|
- } else if (id->bus == BUS_SPI) {
|
|
+ switch (id->bus) {
|
|
+ case BUS_SPI:
|
|
report = hid_register_report(hdev, HID_INPUT_REPORT, SPI_REPORT_ID, 0);
|
|
- } else if (id->bus == BUS_HOST) {
|
|
+ break;
|
|
+ case BUS_HOST:
|
|
report = hid_register_report(hdev, HID_INPUT_REPORT, MTP_REPORT_ID, 0);
|
|
- } else { /* 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,
|
|
- DOUBLE_REPORT_ID, 0);
|
|
+ break;
|
|
+ default:
|
|
+ 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:
|
|
+ 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);
|
|
+ break;
|
|
+ default:
|
|
+ report = hid_register_report(hdev, HID_INPUT_REPORT,
|
|
+ TRACKPAD2_USB_REPORT_ID, 0);
|
|
+ }
|
|
+ break;
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K:
|
|
+ case USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F:
|
|
+ report = hid_register_report(hdev, HID_INPUT_REPORT,
|
|
+ TRACKPAD2_USB_REPORT_ID, 0);
|
|
+ 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,
|
|
+ DOUBLE_REPORT_ID, 0);
|
|
+ }
|
|
}
|
|
|
|
if (!report) {
|
|
@@ -1414,6 +1710,22 @@ static const struct hid_device_id magic_mice[] = {
|
|
USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC), .driver_data = 0 },
|
|
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE,
|
|
USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC), .driver_data = 0 },
|
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE,
|
|
+ USB_DEVICE_ID_APPLE_WELLSPRINGT2_J140K), .driver_data = 0 },
|
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE,
|
|
+ USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132), .driver_data = 0 },
|
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE,
|
|
+ USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680), .driver_data = 0 },
|
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE,
|
|
+ USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213), .driver_data = 0 },
|
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE,
|
|
+ USB_DEVICE_ID_APPLE_WELLSPRINGT2_J214K), .driver_data = 0 },
|
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE,
|
|
+ USB_DEVICE_ID_APPLE_WELLSPRINGT2_J223), .driver_data = 0 },
|
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE,
|
|
+ USB_DEVICE_ID_APPLE_WELLSPRINGT2_J230K), .driver_data = 0 },
|
|
+ { HID_USB_DEVICE(USB_VENDOR_ID_APPLE,
|
|
+ USB_DEVICE_ID_APPLE_WELLSPRINGT2_J152F), .driver_data = 0 },
|
|
{ HID_SPI_DEVICE(SPI_VENDOR_ID_APPLE, HID_ANY_ID),
|
|
.driver_data = 0 },
|
|
{ HID_DEVICE(BUS_HOST, HID_GROUP_ANY, HOST_VENDOR_ID_APPLE,
|
|
--
|
|
2.43.0
|
|
|