diff mbox series

[3/3] HID: apple: Bring back flag for Apple tilde key quirk

Message ID 20211008073702.5761-3-alexhenrie24@gmail.com (mailing list archive)
State New, archived
Delegated to: Jiri Kosina
Headers show
Series [1/3] HID: apple: Rename MAGIC_KEYBOARD_ANSI to MAGIC_KEYBOARD_2015 | expand

Commit Message

Alex Henrie Oct. 8, 2021, 7:37 a.m. UTC
Some Apple ISO keyboards have a quirk where the backtick/tilde key is
swapped with the less-than/greater-than key. Unfortunately, there is no
perfectly reliable way to detect whether a keyboard has the quirk or
not, but the quirk appears to only be present on models that support
Bluetooth, and the affected keyboards usually report country code 13 in
the HID descriptor.

Therefore, the best we can do is to change
/sys/module/hid_apple/parameters/iso_layout to a ternary:

0 = Not ISO or ISO and not quirky
1 = ISO and quirky
-1 = Guess based on product ID and country code

Table of keyboards I have tested:

Product    Model  Shape  Labels      Bus  Country  Quirky
=========================================================
05ac:0201  M2452  ANSI   Usonian     USB  0        No
05ac:020b  A1048  ANSI   Usonian     USB  0        No
05ac:020c  A1048  ISO    Québécois   USB  13       No
05ac:0221  A1243  ISO    Norwegian   USB  13       No
05ac:0221  A1243  ISO    Portuguese  USB  13       No
05ac:0221  A1243  ISO    Swedish     USB  13       No
05ac:0221  A1243  ISO    Swiss       USB  13       No
05ac:022c  A1255  ANSI   Usonian     BT   33       No
05ac:022d  A1255  ISO    Hebrew      BT   13       Yes
05ac:022d  A1255  ISO    Québécois   BT   13       Yes
05ac:022d  A1255  ISO    Spanish     BT   13       Yes
05ac:023a  A1314  ISO    Russian     BT   13       Yes
05ac:023a  A1314  ISO    Swiss       BT   13       Yes
05ac:024f  A1243  ANSI   Usonian     USB  0        No
05ac:0250  A1243  ISO    British     USB  13       No
05ac:0250  A1243  ISO    German      USB  13       No
05ac:0250  A1243  ISO    Italian     USB  13       No
05ac:0250  A1243  ISO    Québécois   USB  13       No
05ac:0251  A1243  JIS    Japanese    USB  15       No
05ac:0255  A1314  ANSI   Usonian     BT   33       No
05ac:0255  A1314  ANSI   Taiwanese   BT   33       No
05ac:0255  A1314  ANSI   Thai        BT   33       No
05ac:0256  A1314  ISO    Arabic      BT   13       Yes
05ac:0256  A1314  ISO    French      BT   13       Yes
05ac:0256  A1314  ISO    German      BT   13       Yes
05ac:0256  A1314  ISO    Norwegian   BT   13       Yes
05ac:0256  A1314  ISO    Spanish     BT   13       Yes
05ac:0256  A1314  ISO    Swiss       BT   13       Yes
05ac:0257  A1314  JIS    Japanese    BT   15       No
05ac:0267  A1644  ANSI   Usonian     USB  33       No
004c:0267  A1644  ANSI   Usonian     BT   0        No
05ac:0267  A1644  ISO    British     USB  13       Yes
004c:0267  A1644  ISO    British     BT   0        Yes
05ac:0267  A1644  ISO    Swiss       USB  13       Yes
004c:0267  A1644  ISO    Swiss       BT   0        Yes
05ac:0267  A1644  ISO    Québécois   USB  13       Yes
004c:0267  A1644  ISO    Québécois   BT   0        Yes
05ac:0267  A1644  JIS    Japanese    USB  15       No
004c:0267  A1644  JIS    Japanese    BT   0        No
05ac:029c  A2450  ANSI   Usonian     USB  33       No
004c:029c  A2450  ANSI   Usonian     BT   0        No
05ac:029c  A2450  ISO    Spanish     USB  13       Yes
004c:029c  A2450  ISO    Spanish     BT   0        Yes
05ac:029c  A2450  JIS    Japanese    USB  15       No
004c:029c  A2450  JIS    Japanese    BT   0        No

Reported-by: José Expósito <jose.exposito89@gmail.com>
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
---
 drivers/hid/hid-apple.c | 46 +++++++++++++++++++++--------------------
 1 file changed, 24 insertions(+), 22 deletions(-)

Comments

José Expósito Oct. 9, 2021, 6:40 p.m. UTC | #1
Hi Alex,

Thank you very much for cc'ing me.

On Fri, Oct 08, 2021 at 01:37:02AM -0600, Alex Henrie wrote:
> Some Apple ISO keyboards have a quirk where the backtick/tilde key is
> swapped with the less-than/greater-than key. Unfortunately, there is no
> perfectly reliable way to detect whether a keyboard has the quirk or
> not, but the quirk appears to only be present on models that support
> Bluetooth, and the affected keyboards usually report country code 13 in
> the HID descriptor.
> 
> Therefore, the best we can do is to change
> /sys/module/hid_apple/parameters/iso_layout to a ternary:
> 
> 0 = Not ISO or ISO and not quirky
> 1 = ISO and quirky
> -1 = Guess based on product ID and country code
> 
> Table of keyboards I have tested:
> 
> Product    Model  Shape  Labels      Bus  Country  Quirky
> =========================================================
> 05ac:0201  M2452  ANSI   Usonian     USB  0        No
> 05ac:020b  A1048  ANSI   Usonian     USB  0        No
> 05ac:020c  A1048  ISO    Québécois   USB  13       No
> 05ac:0221  A1243  ISO    Norwegian   USB  13       No
> 05ac:0221  A1243  ISO    Portuguese  USB  13       No
> 05ac:0221  A1243  ISO    Swedish     USB  13       No
> 05ac:0221  A1243  ISO    Swiss       USB  13       No
> 05ac:022c  A1255  ANSI   Usonian     BT   33       No
> 05ac:022d  A1255  ISO    Hebrew      BT   13       Yes
> 05ac:022d  A1255  ISO    Québécois   BT   13       Yes
> 05ac:022d  A1255  ISO    Spanish     BT   13       Yes
> 05ac:023a  A1314  ISO    Russian     BT   13       Yes
> 05ac:023a  A1314  ISO    Swiss       BT   13       Yes
> 05ac:024f  A1243  ANSI   Usonian     USB  0        No
> 05ac:0250  A1243  ISO    British     USB  13       No
> 05ac:0250  A1243  ISO    German      USB  13       No
> 05ac:0250  A1243  ISO    Italian     USB  13       No
> 05ac:0250  A1243  ISO    Québécois   USB  13       No
> 05ac:0251  A1243  JIS    Japanese    USB  15       No
> 05ac:0255  A1314  ANSI   Usonian     BT   33       No
> 05ac:0255  A1314  ANSI   Taiwanese   BT   33       No
> 05ac:0255  A1314  ANSI   Thai        BT   33       No
> 05ac:0256  A1314  ISO    Arabic      BT   13       Yes
> 05ac:0256  A1314  ISO    French      BT   13       Yes
> 05ac:0256  A1314  ISO    German      BT   13       Yes
> 05ac:0256  A1314  ISO    Norwegian   BT   13       Yes
> 05ac:0256  A1314  ISO    Spanish     BT   13       Yes
> 05ac:0256  A1314  ISO    Swiss       BT   13       Yes
> 05ac:0257  A1314  JIS    Japanese    BT   15       No
> 05ac:0267  A1644  ANSI   Usonian     USB  33       No
> 004c:0267  A1644  ANSI   Usonian     BT   0        No
> 05ac:0267  A1644  ISO    British     USB  13       Yes
> 004c:0267  A1644  ISO    British     BT   0        Yes
> 05ac:0267  A1644  ISO    Swiss       USB  13       Yes
> 004c:0267  A1644  ISO    Swiss       BT   0        Yes
> 05ac:0267  A1644  ISO    Québécois   USB  13       Yes
> 004c:0267  A1644  ISO    Québécois   BT   0        Yes
> 05ac:0267  A1644  JIS    Japanese    USB  15       No
> 004c:0267  A1644  JIS    Japanese    BT   0        No
> 05ac:029c  A2450  ANSI   Usonian     USB  33       No
> 004c:029c  A2450  ANSI   Usonian     BT   0        No
> 05ac:029c  A2450  ISO    Spanish     USB  13       Yes
> 004c:029c  A2450  ISO    Spanish     BT   0        Yes
> 05ac:029c  A2450  JIS    Japanese    USB  15       No
> 004c:029c  A2450  JIS    Japanese    BT   0        No

You can add to the table:

05ac:0267  A1644  ISO    Spanish     USB  13       Yes
004c:0267  A1644  ISO    Spanish     BT   0        Yes

Tested here and it works as expected, both over USB and bluetooth,
thank you very much for fixing it!

It's a pitty that we need to add a configuration option, for many users
it is not going to be easy to discover it.

macOS doesn't have this issue, so there must be a way of detecting the keyboard
layout... Unless they apply the quirk on user space checking the selected
keyboard layout and language in settings.
I bought ANSI English keyboard to see if I could figure out where is the
difference but no luck so far.

For what it's worth, Tested-by: José Expósito <jose.exposito89@gmail.com>
Jiri Kosina Oct. 18, 2021, 3:29 p.m. UTC | #2
On Sat, 9 Oct 2021, José Expósito wrote:

> > Some Apple ISO keyboards have a quirk where the backtick/tilde key is
> > swapped with the less-than/greater-than key. Unfortunately, there is no
> > perfectly reliable way to detect whether a keyboard has the quirk or
> > not, but the quirk appears to only be present on models that support
> > Bluetooth, and the affected keyboards usually report country code 13 in
> > the HID descriptor.
> > 
> > Therefore, the best we can do is to change
> > /sys/module/hid_apple/parameters/iso_layout to a ternary:
> > 
> > 0 = Not ISO or ISO and not quirky
> > 1 = ISO and quirky
> > -1 = Guess based on product ID and country code
> > 
> > Table of keyboards I have tested:
> > 
> > Product    Model  Shape  Labels      Bus  Country  Quirky
> > =========================================================
> > 05ac:0201  M2452  ANSI   Usonian     USB  0        No
> > 05ac:020b  A1048  ANSI   Usonian     USB  0        No
> > 05ac:020c  A1048  ISO    Québécois   USB  13       No
> > 05ac:0221  A1243  ISO    Norwegian   USB  13       No
> > 05ac:0221  A1243  ISO    Portuguese  USB  13       No
> > 05ac:0221  A1243  ISO    Swedish     USB  13       No
> > 05ac:0221  A1243  ISO    Swiss       USB  13       No
> > 05ac:022c  A1255  ANSI   Usonian     BT   33       No
> > 05ac:022d  A1255  ISO    Hebrew      BT   13       Yes
> > 05ac:022d  A1255  ISO    Québécois   BT   13       Yes
> > 05ac:022d  A1255  ISO    Spanish     BT   13       Yes
> > 05ac:023a  A1314  ISO    Russian     BT   13       Yes
> > 05ac:023a  A1314  ISO    Swiss       BT   13       Yes
> > 05ac:024f  A1243  ANSI   Usonian     USB  0        No
> > 05ac:0250  A1243  ISO    British     USB  13       No
> > 05ac:0250  A1243  ISO    German      USB  13       No
> > 05ac:0250  A1243  ISO    Italian     USB  13       No
> > 05ac:0250  A1243  ISO    Québécois   USB  13       No
> > 05ac:0251  A1243  JIS    Japanese    USB  15       No
> > 05ac:0255  A1314  ANSI   Usonian     BT   33       No
> > 05ac:0255  A1314  ANSI   Taiwanese   BT   33       No
> > 05ac:0255  A1314  ANSI   Thai        BT   33       No
> > 05ac:0256  A1314  ISO    Arabic      BT   13       Yes
> > 05ac:0256  A1314  ISO    French      BT   13       Yes
> > 05ac:0256  A1314  ISO    German      BT   13       Yes
> > 05ac:0256  A1314  ISO    Norwegian   BT   13       Yes
> > 05ac:0256  A1314  ISO    Spanish     BT   13       Yes
> > 05ac:0256  A1314  ISO    Swiss       BT   13       Yes
> > 05ac:0257  A1314  JIS    Japanese    BT   15       No
> > 05ac:0267  A1644  ANSI   Usonian     USB  33       No
> > 004c:0267  A1644  ANSI   Usonian     BT   0        No
> > 05ac:0267  A1644  ISO    British     USB  13       Yes
> > 004c:0267  A1644  ISO    British     BT   0        Yes
> > 05ac:0267  A1644  ISO    Swiss       USB  13       Yes
> > 004c:0267  A1644  ISO    Swiss       BT   0        Yes
> > 05ac:0267  A1644  ISO    Québécois   USB  13       Yes
> > 004c:0267  A1644  ISO    Québécois   BT   0        Yes
> > 05ac:0267  A1644  JIS    Japanese    USB  15       No
> > 004c:0267  A1644  JIS    Japanese    BT   0        No
> > 05ac:029c  A2450  ANSI   Usonian     USB  33       No
> > 004c:029c  A2450  ANSI   Usonian     BT   0        No
> > 05ac:029c  A2450  ISO    Spanish     USB  13       Yes
> > 004c:029c  A2450  ISO    Spanish     BT   0        Yes
> > 05ac:029c  A2450  JIS    Japanese    USB  15       No
> > 004c:029c  A2450  JIS    Japanese    BT   0        No
> 
> You can add to the table:
> 
> 05ac:0267  A1644  ISO    Spanish     USB  13       Yes
> 004c:0267  A1644  ISO    Spanish     BT   0        Yes
> 
> Tested here and it works as expected, both over USB and bluetooth,
> thank you very much for fixing it!
> 
> It's a pitty that we need to add a configuration option, for many users
> it is not going to be easy to discover it.
> 
> macOS doesn't have this issue, so there must be a way of detecting the keyboard
> layout... Unless they apply the quirk on user space checking the selected
> keyboard layout and language in settings.
> I bought ANSI English keyboard to see if I could figure out where is the
> difference but no luck so far.
> 
> For what it's worth, Tested-by: José Expósito <jose.exposito89@gmail.com>

Alex, could you please add the mentioned device IDs, include José's 
Tested-by: and resend, so that I could apply it?

Thanks,
Julian Weigt Oct. 19, 2021, 7:06 a.m. UTC | #3
Hi,

On Mon, Oct 18, 2021 at 05:29:53PM +0200, Jiri Kosina wrote:
> On Sat, 9 Oct 2021, José Expósito wrote:
> 
> > > Some Apple ISO keyboards have a quirk where the backtick/tilde key is
> > > swapped with the less-than/greater-than key. Unfortunately, there is no
> > > perfectly reliable way to detect whether a keyboard has the quirk or
> > > not, but the quirk appears to only be present on models that support
> > > Bluetooth, and the affected keyboards usually report country code 13 in
> > > the HID descriptor.
> > > 
> > > Therefore, the best we can do is to change
> > > /sys/module/hid_apple/parameters/iso_layout to a ternary:
> > > 
> > > 0 = Not ISO or ISO and not quirky
> > > 1 = ISO and quirky
> > > -1 = Guess based on product ID and country code
> > > 
> > > Table of keyboards I have tested:
> > > 
> > > Product    Model  Shape  Labels      Bus  Country  Quirky
> > > =========================================================
> > > 05ac:0201  M2452  ANSI   Usonian     USB  0        No
> > > 05ac:020b  A1048  ANSI   Usonian     USB  0        No
> > > 05ac:020c  A1048  ISO    Québécois   USB  13       No
> > > 05ac:0221  A1243  ISO    Norwegian   USB  13       No
> > > 05ac:0221  A1243  ISO    Portuguese  USB  13       No
> > > 05ac:0221  A1243  ISO    Swedish     USB  13       No
> > > 05ac:0221  A1243  ISO    Swiss       USB  13       No
> > > 05ac:022c  A1255  ANSI   Usonian     BT   33       No
> > > 05ac:022d  A1255  ISO    Hebrew      BT   13       Yes
> > > 05ac:022d  A1255  ISO    Québécois   BT   13       Yes
> > > 05ac:022d  A1255  ISO    Spanish     BT   13       Yes
> > > 05ac:023a  A1314  ISO    Russian     BT   13       Yes
> > > 05ac:023a  A1314  ISO    Swiss       BT   13       Yes
> > > 05ac:024f  A1243  ANSI   Usonian     USB  0        No
> > > 05ac:0250  A1243  ISO    British     USB  13       No
> > > 05ac:0250  A1243  ISO    German      USB  13       No
> > > 05ac:0250  A1243  ISO    Italian     USB  13       No
> > > 05ac:0250  A1243  ISO    Québécois   USB  13       No
> > > 05ac:0251  A1243  JIS    Japanese    USB  15       No
> > > 05ac:0255  A1314  ANSI   Usonian     BT   33       No
> > > 05ac:0255  A1314  ANSI   Taiwanese   BT   33       No
> > > 05ac:0255  A1314  ANSI   Thai        BT   33       No
> > > 05ac:0256  A1314  ISO    Arabic      BT   13       Yes
> > > 05ac:0256  A1314  ISO    French      BT   13       Yes
> > > 05ac:0256  A1314  ISO    German      BT   13       Yes
> > > 05ac:0256  A1314  ISO    Norwegian   BT   13       Yes
> > > 05ac:0256  A1314  ISO    Spanish     BT   13       Yes
> > > 05ac:0256  A1314  ISO    Swiss       BT   13       Yes
> > > 05ac:0257  A1314  JIS    Japanese    BT   15       No
> > > 05ac:0267  A1644  ANSI   Usonian     USB  33       No
> > > 004c:0267  A1644  ANSI   Usonian     BT   0        No
> > > 05ac:0267  A1644  ISO    British     USB  13       Yes
> > > 004c:0267  A1644  ISO    British     BT   0        Yes
> > > 05ac:0267  A1644  ISO    Swiss       USB  13       Yes
> > > 004c:0267  A1644  ISO    Swiss       BT   0        Yes
> > > 05ac:0267  A1644  ISO    Québécois   USB  13       Yes
> > > 004c:0267  A1644  ISO    Québécois   BT   0        Yes
> > > 05ac:0267  A1644  JIS    Japanese    USB  15       No
> > > 004c:0267  A1644  JIS    Japanese    BT   0        No
> > > 05ac:029c  A2450  ANSI   Usonian     USB  33       No
> > > 004c:029c  A2450  ANSI   Usonian     BT   0        No
> > > 05ac:029c  A2450  ISO    Spanish     USB  13       Yes
> > > 004c:029c  A2450  ISO    Spanish     BT   0        Yes
> > > 05ac:029c  A2450  JIS    Japanese    USB  15       No
> > > 004c:029c  A2450  JIS    Japanese    BT   0        No
> > 
> > You can add to the table:
> > 
> > 05ac:0267  A1644  ISO    Spanish     USB  13       Yes
> > 004c:0267  A1644  ISO    Spanish     BT   0        Yes
> > 
> > Tested here and it works as expected, both over USB and bluetooth,
> > thank you very much for fixing it!
> > 
> > It's a pitty that we need to add a configuration option, for many users
> > it is not going to be easy to discover it.
> > 
> > macOS doesn't have this issue, so there must be a way of detecting the keyboard
> > layout... Unless they apply the quirk on user space checking the selected
> > keyboard layout and language in settings.
> > I bought ANSI English keyboard to see if I could figure out where is the
> > difference but no luck so far.
> > 
> > For what it's worth, Tested-by: José Expósito <jose.exposito89@gmail.com>
> 
> Alex, could you please add the mentioned device IDs, include José's 
> Tested-by: and resend, so that I could apply it?
> 
> Thanks,
> 
> -- 
> Jiri Kosina
> SUSE Labs

I also tested
 
05ac:0267  A1644  ISO    Finnish     USB  13       Yes
004c:0267  A1644  ISO    Finnish     BT   0        Yes

With USB it still works out of the box. With BT the guessing goes wrong, but setting iso_layout to 1 works now, thanks!

Best, Julian
diff mbox series

Patch

diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index e7af40b737d8..283bf22914ac 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -25,7 +25,7 @@ 
 #define APPLE_IGNORE_MOUSE	0x0002
 #define APPLE_HAS_FN		0x0004
 #define APPLE_HIDDEV		0x0008
-/* 0x0010 reserved, was: APPLE_ISO_KEYBOARD */
+#define APPLE_ISO_TILDE_QUIRK	0x0010
 #define APPLE_MIGHTYMOUSE	0x0020
 #define APPLE_INVERT_HWHEEL	0x0040
 #define APPLE_IGNORE_HIDINPUT	0x0080
@@ -40,10 +40,10 @@  module_param(fnmode, uint, 0644);
 MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, "
 		"[1] = fkeyslast, 2 = fkeysfirst)");
 
-static unsigned int iso_layout = 1;
-module_param(iso_layout, uint, 0644);
-MODULE_PARM_DESC(iso_layout, "Enable/Disable hardcoded ISO-layout of the keyboard. "
-		"(0 = disabled, [1] = enabled)");
+static int iso_layout = -1;
+module_param(iso_layout, int, 0644);
+MODULE_PARM_DESC(iso_layout, "Swap the backtick/tilde and greater-than/less-than keys. "
+		"([-1] = auto, 0 = disabled, 1 = enabled)");
 
 static unsigned int swap_opt_cmd;
 module_param(swap_opt_cmd, uint, 0644);
@@ -277,14 +277,13 @@  static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
 		}
 	}
 
-	if (iso_layout) {
-		if (hid->country == HID_COUNTRY_INTERNATIONAL_ISO) {
-			trans = apple_find_translation(apple_iso_keyboard, usage->code);
-			if (trans) {
-				input_event_with_scancode(input, usage->type,
-						trans->to, usage->hid, value);
-				return 1;
-			}
+	if (iso_layout > 0 || (iso_layout < 0 && (asc->quirks & APPLE_ISO_TILDE_QUIRK) &&
+			hid->country == HID_COUNTRY_INTERNATIONAL_ISO)) {
+		trans = apple_find_translation(apple_iso_keyboard, usage->code);
+		if (trans) {
+			input_event_with_scancode(input, usage->type,
+					trans->to, usage->hid, value);
+			return 1;
 		}
 	}
 
@@ -533,9 +532,11 @@  static const struct hid_device_id apple_devices[] = {
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI),
 		.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO),
-		.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
+		.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
+			APPLE_ISO_TILDE_QUIRK },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO),
-		.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
+		.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
+			APPLE_ISO_TILDE_QUIRK },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
 				USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI),
 		.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
@@ -545,13 +546,13 @@  static const struct hid_device_id apple_devices[] = {
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS),
 		.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015),
-		.driver_data = APPLE_HAS_FN },
+		.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
 	{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015),
-		.driver_data = APPLE_HAS_FN },
+		.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015),
-		.driver_data = APPLE_HAS_FN },
+		.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
 	{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015),
-		.driver_data = APPLE_HAS_FN },
+		.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI),
 		.driver_data = APPLE_HAS_FN },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO),
@@ -633,7 +634,8 @@  static const struct hid_device_id apple_devices[] = {
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI),
 		.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO),
-		.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
+		.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
+			APPLE_ISO_TILDE_QUIRK },
 	{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS),
 		.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY),
@@ -641,9 +643,9 @@  static const struct hid_device_id apple_devices[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY),
 		.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021),
-		.driver_data = APPLE_HAS_FN },
+		.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
 	{ HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021),
-		.driver_data = APPLE_HAS_FN },
+		.driver_data = APPLE_HAS_FN | APPLE_ISO_TILDE_QUIRK },
 
 	{ }
 };