Skip to content

Commit 531cb56

Browse files
Benjamin BergJiri Kosina
authored andcommitted
HID: apple: Add 2021 magic keyboard FN key mapping
The new 2021 apple models have a different FN key assignment. Add a new translation table and use that for the 2021 magic keyboard. Signed-off-by: Benjamin Berg <bberg@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent 5768701 commit 531cb56

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

drivers/hid/hid-apple.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,28 @@ struct apple_key_translation {
7676
u8 flags;
7777
};
7878

79+
static const struct apple_key_translation apple2021_fn_keys[] = {
80+
{ KEY_BACKSPACE, KEY_DELETE },
81+
{ KEY_ENTER, KEY_INSERT },
82+
{ KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
83+
{ KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
84+
{ KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
85+
{ KEY_F4, KEY_SEARCH, APPLE_FLAG_FKEY },
86+
{ KEY_F5, KEY_MICMUTE, APPLE_FLAG_FKEY },
87+
{ KEY_F6, KEY_SLEEP, APPLE_FLAG_FKEY },
88+
{ KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
89+
{ KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
90+
{ KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
91+
{ KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
92+
{ KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
93+
{ KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
94+
{ KEY_UP, KEY_PAGEUP },
95+
{ KEY_DOWN, KEY_PAGEDOWN },
96+
{ KEY_LEFT, KEY_HOME },
97+
{ KEY_RIGHT, KEY_END },
98+
{ }
99+
};
100+
79101
static const struct apple_key_translation macbookair_fn_keys[] = {
80102
{ KEY_BACKSPACE, KEY_DELETE },
81103
{ KEY_ENTER, KEY_INSERT },
@@ -220,7 +242,9 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
220242
}
221243

222244
if (fnmode) {
223-
if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
245+
if (hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021)
246+
table = apple2021_fn_keys;
247+
else if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
224248
hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
225249
table = macbookair_fn_keys;
226250
else if (hid->product < 0x21d || hid->product >= 0x300)
@@ -443,6 +467,9 @@ static void apple_setup_input(struct input_dev *input)
443467
for (trans = apple_iso_keyboard; trans->from; trans++)
444468
set_bit(trans->to, input->keybit);
445469

470+
for (trans = apple2021_fn_keys; trans->from; trans++)
471+
set_bit(trans->to, input->keybit);
472+
446473
if (swap_fn_leftctrl) {
447474
for (trans = swapped_fn_leftctrl_keys; trans->from; trans++)
448475
set_bit(trans->to, input->keybit);

0 commit comments

Comments
 (0)