24
24
#define APPLE_RDESC_JIS 0x0001
25
25
#define APPLE_IGNORE_MOUSE 0x0002
26
26
#define APPLE_HAS_FN 0x0004
27
- #define APPLE_HIDDEV 0x0008
28
- /* 0x0010 reserved, was: APPLE_ISO_KEYBOARD */
27
+ /* 0x0008 reserved, was: APPLE_HIDDEV */
28
+ #define APPLE_ISO_TILDE_QUIRK 0x0010
29
29
#define APPLE_MIGHTYMOUSE 0x0020
30
30
#define APPLE_INVERT_HWHEEL 0x0040
31
- #define APPLE_IGNORE_HIDINPUT 0x0080
31
+ /* 0x0080 reserved, was: APPLE_IGNORE_HIDINPUT */
32
32
#define APPLE_NUMLOCK_EMULATION 0x0100
33
33
34
34
#define APPLE_FLAG_FKEY 0x01
@@ -40,10 +40,10 @@ module_param(fnmode, uint, 0644);
40
40
MODULE_PARM_DESC (fnmode , "Mode of fn key on Apple keyboards (0 = disabled, "
41
41
"[1] = fkeyslast, 2 = fkeysfirst)" );
42
42
43
- static unsigned int iso_layout = 1 ;
44
- module_param (iso_layout , uint , 0644 );
45
- MODULE_PARM_DESC (iso_layout , "Enable/Disable hardcoded ISO-layout of the keyboard . "
46
- "(0 = disabled, [1] = enabled)" );
43
+ static int iso_layout = - 1 ;
44
+ module_param (iso_layout , int , 0644 );
45
+ MODULE_PARM_DESC (iso_layout , "Swap the backtick/tilde and greater-than/less-than keys . "
46
+ "([-1] = auto, 0 = disabled, 1 = enabled)" );
47
47
48
48
static unsigned int swap_opt_cmd ;
49
49
module_param (swap_opt_cmd , uint , 0644 );
@@ -277,14 +277,13 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
277
277
}
278
278
}
279
279
280
- if (iso_layout ) {
281
- if (hid -> country == HID_COUNTRY_INTERNATIONAL_ISO ) {
282
- trans = apple_find_translation (apple_iso_keyboard , usage -> code );
283
- if (trans ) {
284
- input_event_with_scancode (input , usage -> type ,
285
- trans -> to , usage -> hid , value );
286
- return 1 ;
287
- }
280
+ if (iso_layout > 0 || (iso_layout < 0 && (asc -> quirks & APPLE_ISO_TILDE_QUIRK ) &&
281
+ hid -> country == HID_COUNTRY_INTERNATIONAL_ISO )) {
282
+ trans = apple_find_translation (apple_iso_keyboard , usage -> code );
283
+ if (trans ) {
284
+ input_event_with_scancode (input , usage -> type ,
285
+ trans -> to , usage -> hid , value );
286
+ return 1 ;
288
287
}
289
288
}
290
289
@@ -440,7 +439,6 @@ static int apple_probe(struct hid_device *hdev,
440
439
{
441
440
unsigned long quirks = id -> driver_data ;
442
441
struct apple_sc * asc ;
443
- unsigned int connect_mask = HID_CONNECT_DEFAULT ;
444
442
int ret ;
445
443
446
444
asc = devm_kzalloc (& hdev -> dev , sizeof (* asc ), GFP_KERNEL );
@@ -459,12 +457,7 @@ static int apple_probe(struct hid_device *hdev,
459
457
return ret ;
460
458
}
461
459
462
- if (quirks & APPLE_HIDDEV )
463
- connect_mask |= HID_CONNECT_HIDDEV_FORCE ;
464
- if (quirks & APPLE_IGNORE_HIDINPUT )
465
- connect_mask &= ~HID_CONNECT_HIDINPUT ;
466
-
467
- ret = hid_hw_start (hdev , connect_mask );
460
+ ret = hid_hw_start (hdev , HID_CONNECT_DEFAULT );
468
461
if (ret ) {
469
462
hid_err (hdev , "hw start failed\n" );
470
463
return ret ;
@@ -533,9 +526,11 @@ static const struct hid_device_id apple_devices[] = {
533
526
{ HID_BLUETOOTH_DEVICE (USB_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI ),
534
527
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
535
528
{ HID_BLUETOOTH_DEVICE (USB_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO ),
536
- .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
529
+ .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
530
+ APPLE_ISO_TILDE_QUIRK },
537
531
{ HID_BLUETOOTH_DEVICE (USB_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO ),
538
- .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
532
+ .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
533
+ APPLE_ISO_TILDE_QUIRK },
539
534
{ HID_BLUETOOTH_DEVICE (USB_VENDOR_ID_APPLE ,
540
535
USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI ),
541
536
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
@@ -544,14 +539,14 @@ static const struct hid_device_id apple_devices[] = {
544
539
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
545
540
{ HID_BLUETOOTH_DEVICE (USB_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS ),
546
541
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
547
- { HID_USB_DEVICE (USB_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI ),
548
- .driver_data = APPLE_HAS_FN },
549
- { HID_BLUETOOTH_DEVICE (BT_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI ),
550
- .driver_data = APPLE_HAS_FN },
551
- { HID_USB_DEVICE (USB_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI ),
552
- .driver_data = APPLE_HAS_FN },
553
- { HID_BLUETOOTH_DEVICE (BT_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI ),
554
- .driver_data = APPLE_HAS_FN },
542
+ { HID_USB_DEVICE (USB_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015 ),
543
+ .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
544
+ { HID_BLUETOOTH_DEVICE (BT_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015 ),
545
+ .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
546
+ { HID_USB_DEVICE (USB_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015 ),
547
+ .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
548
+ { HID_BLUETOOTH_DEVICE (BT_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015 ),
549
+ .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
555
550
{ HID_USB_DEVICE (USB_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_WELLSPRING_ANSI ),
556
551
.driver_data = APPLE_HAS_FN },
557
552
{ HID_USB_DEVICE (USB_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_WELLSPRING_ISO ),
@@ -633,13 +628,18 @@ static const struct hid_device_id apple_devices[] = {
633
628
{ HID_BLUETOOTH_DEVICE (USB_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI ),
634
629
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
635
630
{ HID_BLUETOOTH_DEVICE (USB_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO ),
636
- .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
631
+ .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
632
+ APPLE_ISO_TILDE_QUIRK },
637
633
{ HID_BLUETOOTH_DEVICE (USB_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS ),
638
634
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
639
635
{ HID_USB_DEVICE (USB_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY ),
640
636
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
641
637
{ HID_USB_DEVICE (USB_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY ),
642
638
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
639
+ { HID_USB_DEVICE (USB_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021 ),
640
+ .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
641
+ { HID_BLUETOOTH_DEVICE (BT_VENDOR_ID_APPLE , USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021 ),
642
+ .driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
643
643
644
644
{ }
645
645
};
0 commit comments