@@ -227,7 +227,9 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda
227
227
touch_minor = tdata [4 ];
228
228
state = tdata [7 ] & TOUCH_STATE_MASK ;
229
229
down = state != TOUCH_STATE_NONE ;
230
- } else if (input -> id .product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ) {
230
+ } else if (input -> id .product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
231
+ input -> id .product ==
232
+ USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC ) {
231
233
id = tdata [8 ] & 0xf ;
232
234
x = (tdata [1 ] << 27 | tdata [0 ] << 19 ) >> 19 ;
233
235
y = - ((tdata [3 ] << 30 | tdata [2 ] << 22 | tdata [1 ] << 14 ) >> 19 );
@@ -259,8 +261,9 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda
259
261
/* If requested, emulate a scroll wheel by detecting small
260
262
* vertical touch motions.
261
263
*/
262
- if (emulate_scroll_wheel && (input -> id .product !=
263
- USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 )) {
264
+ if (emulate_scroll_wheel &&
265
+ input -> id .product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 &&
266
+ input -> id .product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC ) {
264
267
unsigned long now = jiffies ;
265
268
int step_x = msc -> touches [id ].scroll_x - x ;
266
269
int step_y = msc -> touches [id ].scroll_y - y ;
@@ -359,15 +362,19 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda
359
362
input_report_abs (input , ABS_MT_POSITION_X , x );
360
363
input_report_abs (input , ABS_MT_POSITION_Y , y );
361
364
362
- if (input -> id .product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 )
365
+ if (input -> id .product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
366
+ input -> id .product ==
367
+ USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC )
363
368
input_report_abs (input , ABS_MT_PRESSURE , pressure );
364
369
365
370
if (report_undeciphered ) {
366
371
if (input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE ||
367
372
input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 )
368
373
input_event (input , EV_MSC , MSC_RAW , tdata [7 ]);
369
374
else if (input -> id .product !=
370
- USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 )
375
+ USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 &&
376
+ input -> id .product !=
377
+ USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC )
371
378
input_event (input , EV_MSC , MSC_RAW , tdata [8 ]);
372
379
}
373
380
}
@@ -493,7 +500,9 @@ static int magicmouse_raw_event(struct hid_device *hdev,
493
500
magicmouse_emit_buttons (msc , clicks & 3 );
494
501
input_report_rel (input , REL_X , x );
495
502
input_report_rel (input , REL_Y , y );
496
- } else if (input -> id .product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ) {
503
+ } else if (input -> id .product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
504
+ input -> id .product ==
505
+ USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC ) {
497
506
input_mt_sync_frame (input );
498
507
input_report_key (input , BTN_MOUSE , clicks & 1 );
499
508
} else { /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */
@@ -545,7 +554,9 @@ static int magicmouse_setup_input(struct input_dev *input, struct hid_device *hd
545
554
__set_bit (REL_WHEEL_HI_RES , input -> relbit );
546
555
__set_bit (REL_HWHEEL_HI_RES , input -> relbit );
547
556
}
548
- } else if (input -> id .product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ) {
557
+ } else if (input -> id .product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
558
+ input -> id .product ==
559
+ USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC ) {
549
560
/* If the trackpad has been connected to a Mac, the name is
550
561
* automatically personalized, e.g., "José Expósito's Trackpad".
551
562
* When connected through Bluetooth, the personalized name is
@@ -621,7 +632,9 @@ static int magicmouse_setup_input(struct input_dev *input, struct hid_device *hd
621
632
MOUSE_RES_X );
622
633
input_abs_set_res (input , ABS_MT_POSITION_Y ,
623
634
MOUSE_RES_Y );
624
- } else if (input -> id .product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ) {
635
+ } else if (input -> id .product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
636
+ input -> id .product ==
637
+ USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC ) {
625
638
input_set_abs_params (input , ABS_MT_PRESSURE , 0 , 253 , 0 , 0 );
626
639
input_set_abs_params (input , ABS_PRESSURE , 0 , 253 , 0 , 0 );
627
640
input_set_abs_params (input , ABS_MT_ORIENTATION , -3 , 4 , 0 , 0 );
@@ -660,7 +673,8 @@ static int magicmouse_setup_input(struct input_dev *input, struct hid_device *hd
660
673
input_set_events_per_packet (input , 60 );
661
674
662
675
if (report_undeciphered &&
663
- input -> id .product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ) {
676
+ input -> id .product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 &&
677
+ input -> id .product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC ) {
664
678
__set_bit (EV_MSC , input -> evbit );
665
679
__set_bit (MSC_RAW , input -> mscbit );
666
680
}
@@ -685,7 +699,9 @@ static int magicmouse_input_mapping(struct hid_device *hdev,
685
699
686
700
/* Magic Trackpad does not give relative data after switching to MT */
687
701
if ((hi -> input -> id .product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD ||
688
- hi -> input -> id .product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ) &&
702
+ hi -> input -> id .product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
703
+ hi -> input -> id .product ==
704
+ USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC ) &&
689
705
field -> flags & HID_MAIN_ITEM_RELATIVE )
690
706
return -1 ;
691
707
@@ -721,7 +737,8 @@ static int magicmouse_enable_multitouch(struct hid_device *hdev)
721
737
int ret ;
722
738
int feature_size ;
723
739
724
- if (hdev -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ) {
740
+ if (hdev -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
741
+ hdev -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC ) {
725
742
if (hdev -> vendor == BT_VENDOR_ID_APPLE ) {
726
743
feature_size = sizeof (feature_mt_trackpad2_bt );
727
744
feature = feature_mt_trackpad2_bt ;
@@ -766,7 +783,8 @@ static int magicmouse_fetch_battery(struct hid_device *hdev)
766
783
767
784
if (!hdev -> battery || hdev -> vendor != USB_VENDOR_ID_APPLE ||
768
785
(hdev -> product != USB_DEVICE_ID_APPLE_MAGICMOUSE2 &&
769
- hdev -> product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ))
786
+ hdev -> product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 &&
787
+ hdev -> product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC ))
770
788
return -1 ;
771
789
772
790
report_enum = & hdev -> report_enum [hdev -> battery_report_type ];
@@ -835,7 +853,9 @@ static int magicmouse_probe(struct hid_device *hdev,
835
853
836
854
if (id -> vendor == USB_VENDOR_ID_APPLE &&
837
855
(id -> product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 ||
838
- (id -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 && hdev -> type != HID_TYPE_USBMOUSE )))
856
+ ((id -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
857
+ id -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC ) &&
858
+ hdev -> type != HID_TYPE_USBMOUSE )))
839
859
return 0 ;
840
860
841
861
if (!msc -> input ) {
@@ -850,7 +870,8 @@ static int magicmouse_probe(struct hid_device *hdev,
850
870
else if (id -> product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 )
851
871
report = hid_register_report (hdev , HID_INPUT_REPORT ,
852
872
MOUSE2_REPORT_ID , 0 );
853
- else if (id -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ) {
873
+ else if (id -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
874
+ id -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC ) {
854
875
if (id -> vendor == BT_VENDOR_ID_APPLE )
855
876
report = hid_register_report (hdev , HID_INPUT_REPORT ,
856
877
TRACKPAD2_BT_REPORT_ID , 0 );
@@ -920,7 +941,8 @@ static const __u8 *magicmouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,
920
941
*/
921
942
if (hdev -> vendor == USB_VENDOR_ID_APPLE &&
922
943
(hdev -> product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 ||
923
- hdev -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ) &&
944
+ hdev -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
945
+ hdev -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC ) &&
924
946
* rsize == 83 && rdesc [46 ] == 0x84 && rdesc [58 ] == 0x85 ) {
925
947
hid_info (hdev ,
926
948
"fixing up magicmouse battery report descriptor\n" );
@@ -951,6 +973,10 @@ static const struct hid_device_id magic_mice[] = {
951
973
USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ), .driver_data = 0 },
952
974
{ HID_USB_DEVICE (USB_VENDOR_ID_APPLE ,
953
975
USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ), .driver_data = 0 },
976
+ { HID_BLUETOOTH_DEVICE (BT_VENDOR_ID_APPLE ,
977
+ USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC ), .driver_data = 0 },
978
+ { HID_USB_DEVICE (USB_VENDOR_ID_APPLE ,
979
+ USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC ), .driver_data = 0 },
954
980
{ }
955
981
};
956
982
MODULE_DEVICE_TABLE (hid , magic_mice );
0 commit comments