@@ -218,7 +218,8 @@ static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tda
218
218
int pressure = 0 ;
219
219
220
220
if (input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE ||
221
- input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 ) {
221
+ input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 ||
222
+ input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC ) {
222
223
id = (tdata [6 ] << 2 | tdata [5 ] >> 6 ) & 0xf ;
223
224
x = (tdata [1 ] << 28 | tdata [0 ] << 20 ) >> 20 ;
224
225
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
370
371
371
372
if (report_undeciphered ) {
372
373
if (input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE ||
373
- input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 )
374
+ input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 ||
375
+ input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC )
374
376
input_event (input , EV_MSC , MSC_RAW , tdata [7 ]);
375
377
else if (input -> id .product !=
376
378
USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 &&
@@ -497,7 +499,8 @@ static int magicmouse_raw_event(struct hid_device *hdev,
497
499
}
498
500
499
501
if (input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE ||
500
- input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 ) {
502
+ input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 ||
503
+ input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC ) {
501
504
magicmouse_emit_buttons (msc , clicks & 3 );
502
505
input_report_rel (input , REL_X , x );
503
506
input_report_rel (input , REL_Y , y );
@@ -519,7 +522,8 @@ static int magicmouse_event(struct hid_device *hdev, struct hid_field *field,
519
522
struct hid_usage * usage , __s32 value )
520
523
{
521
524
struct magicmouse_sc * msc = hid_get_drvdata (hdev );
522
- if (msc -> input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 &&
525
+ if ((msc -> input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 ||
526
+ msc -> input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC ) &&
523
527
field -> report -> id == MOUSE2_REPORT_ID ) {
524
528
/*
525
529
* 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
540
544
__set_bit (EV_KEY , input -> evbit );
541
545
542
546
if (input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE ||
543
- input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 ) {
547
+ input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 ||
548
+ input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC ) {
544
549
__set_bit (BTN_LEFT , input -> keybit );
545
550
__set_bit (BTN_RIGHT , input -> keybit );
546
551
if (emulate_3button )
@@ -625,7 +630,8 @@ static int magicmouse_setup_input(struct input_dev *input, struct hid_device *hd
625
630
* inverse of the reported Y.
626
631
*/
627
632
if (input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE ||
628
- input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 ) {
633
+ input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 ||
634
+ input -> id .product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC ) {
629
635
input_set_abs_params (input , ABS_MT_ORIENTATION , -31 , 32 , 1 , 0 );
630
636
input_set_abs_params (input , ABS_MT_POSITION_X ,
631
637
MOUSE_MIN_X , MOUSE_MAX_X , 4 , 0 );
@@ -741,19 +747,25 @@ static int magicmouse_enable_multitouch(struct hid_device *hdev)
741
747
int ret ;
742
748
int feature_size ;
743
749
744
- if (hdev -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
745
- hdev -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC ) {
746
- if (hdev -> vendor == BT_VENDOR_ID_APPLE ) {
750
+ switch (hdev -> product ) {
751
+ case USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 :
752
+ case USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC :
753
+ switch (hdev -> vendor ) {
754
+ case BT_VENDOR_ID_APPLE :
747
755
feature_size = sizeof (feature_mt_trackpad2_bt );
748
756
feature = feature_mt_trackpad2_bt ;
749
- } else { /* USB_VENDOR_ID_APPLE */
757
+ break ;
758
+ default : /* USB_VENDOR_ID_APPLE */
750
759
feature_size = sizeof (feature_mt_trackpad2_usb );
751
760
feature = feature_mt_trackpad2_usb ;
752
761
}
753
- } else if (hdev -> product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 ) {
762
+ break ;
763
+ case USB_DEVICE_ID_APPLE_MAGICMOUSE2 :
764
+ case USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC :
754
765
feature_size = sizeof (feature_mt_mouse2 );
755
766
feature = feature_mt_mouse2 ;
756
- } else {
767
+ break ;
768
+ default :
757
769
feature_size = sizeof (feature_mt );
758
770
feature = feature_mt ;
759
771
}
@@ -787,6 +799,7 @@ static int magicmouse_fetch_battery(struct hid_device *hdev)
787
799
788
800
if (!hdev -> battery || hdev -> vendor != USB_VENDOR_ID_APPLE ||
789
801
(hdev -> product != USB_DEVICE_ID_APPLE_MAGICMOUSE2 &&
802
+ hdev -> product != USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC &&
790
803
hdev -> product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 &&
791
804
hdev -> product != USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC ))
792
805
return -1 ;
@@ -857,6 +870,7 @@ static int magicmouse_probe(struct hid_device *hdev,
857
870
858
871
if (id -> vendor == USB_VENDOR_ID_APPLE &&
859
872
(id -> product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 ||
873
+ id -> product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC ||
860
874
((id -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
861
875
id -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC ) &&
862
876
hdev -> type != HID_TYPE_USBMOUSE )))
@@ -868,21 +882,27 @@ static int magicmouse_probe(struct hid_device *hdev,
868
882
goto err_stop_hw ;
869
883
}
870
884
871
- if (id -> product == USB_DEVICE_ID_APPLE_MAGICMOUSE )
872
- report = hid_register_report (hdev , HID_INPUT_REPORT ,
873
- MOUSE_REPORT_ID , 0 );
874
- else if (id -> product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 )
875
- report = hid_register_report (hdev , HID_INPUT_REPORT ,
876
- MOUSE2_REPORT_ID , 0 );
877
- else if (id -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
878
- id -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC ) {
879
- if (id -> vendor == BT_VENDOR_ID_APPLE )
885
+ switch (id -> product ) {
886
+ case USB_DEVICE_ID_APPLE_MAGICMOUSE :
887
+ report = hid_register_report (hdev , HID_INPUT_REPORT , MOUSE_REPORT_ID , 0 );
888
+ break ;
889
+ case USB_DEVICE_ID_APPLE_MAGICMOUSE2 :
890
+ case USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC :
891
+ report = hid_register_report (hdev , HID_INPUT_REPORT , MOUSE2_REPORT_ID , 0 );
892
+ break ;
893
+ case USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 :
894
+ case USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC :
895
+ switch (id -> vendor ) {
896
+ case BT_VENDOR_ID_APPLE :
880
897
report = hid_register_report (hdev , HID_INPUT_REPORT ,
881
898
TRACKPAD2_BT_REPORT_ID , 0 );
882
- else /* USB_VENDOR_ID_APPLE */
899
+ break ;
900
+ default :
883
901
report = hid_register_report (hdev , HID_INPUT_REPORT ,
884
902
TRACKPAD2_USB_REPORT_ID , 0 );
885
- } else { /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */
903
+ }
904
+ break ;
905
+ default : /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */
886
906
report = hid_register_report (hdev , HID_INPUT_REPORT ,
887
907
TRACKPAD_REPORT_ID , 0 );
888
908
report = hid_register_report (hdev , HID_INPUT_REPORT ,
@@ -909,7 +929,8 @@ static int magicmouse_probe(struct hid_device *hdev,
909
929
hid_err (hdev , "unable to request touch data (%d)\n" , ret );
910
930
goto err_stop_hw ;
911
931
}
912
- if (ret == - EIO && id -> product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 ) {
932
+ if (ret == - EIO && (id -> product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 ||
933
+ id -> product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC )) {
913
934
schedule_delayed_work (& msc -> work , msecs_to_jiffies (500 ));
914
935
}
915
936
@@ -945,6 +966,7 @@ static const __u8 *magicmouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,
945
966
*/
946
967
if (hdev -> vendor == USB_VENDOR_ID_APPLE &&
947
968
(hdev -> product == USB_DEVICE_ID_APPLE_MAGICMOUSE2 ||
969
+ hdev -> product == USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC ||
948
970
hdev -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2 ||
949
971
hdev -> product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD2_USBC ) &&
950
972
* rsize == 83 && rdesc [46 ] == 0x84 && rdesc [58 ] == 0x85 ) {
@@ -971,6 +993,10 @@ static const struct hid_device_id magic_mice[] = {
971
993
USB_DEVICE_ID_APPLE_MAGICMOUSE2 ), .driver_data = 0 },
972
994
{ HID_USB_DEVICE (USB_VENDOR_ID_APPLE ,
973
995
USB_DEVICE_ID_APPLE_MAGICMOUSE2 ), .driver_data = 0 },
996
+ { HID_BLUETOOTH_DEVICE (BT_VENDOR_ID_APPLE ,
997
+ USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC ), .driver_data = 0 },
998
+ { HID_USB_DEVICE (USB_VENDOR_ID_APPLE ,
999
+ USB_DEVICE_ID_APPLE_MAGICMOUSE2_USBC ), .driver_data = 0 },
974
1000
{ HID_BLUETOOTH_DEVICE (USB_VENDOR_ID_APPLE ,
975
1001
USB_DEVICE_ID_APPLE_MAGICTRACKPAD ), .driver_data = 0 },
976
1002
{ HID_BLUETOOTH_DEVICE (BT_VENDOR_ID_APPLE ,
0 commit comments