Skip to content

Commit 250b369

Browse files
JoseExpositoJiri Kosina
authored andcommitted
HID: apple: Magic Keyboard 2015 FN key mapping
The Magic Keyboard 2015 function key mapping was not present and the default mapping was used. While this worked for most keys, the F5 and F6 keys were sending KEY_KBDILLUMDOWN and KEY_KBDILLUMUP; however, the keyboard is not backlited. Add a custom translation table for the keyboard leaving F5 and F6 unassigned to mimic the default behavior on macOS. Signed-off-by: José Expósito <jose.exposito89@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
1 parent 0fea6fe commit 250b369

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

drivers/hid/hid-apple.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,26 @@ static const struct apple_key_translation magic_keyboard_alu_fn_keys[] = {
9797
{ }
9898
};
9999

100+
static const struct apple_key_translation magic_keyboard_2015_fn_keys[] = {
101+
{ KEY_BACKSPACE, KEY_DELETE },
102+
{ KEY_ENTER, KEY_INSERT },
103+
{ KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
104+
{ KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
105+
{ KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
106+
{ KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY },
107+
{ KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
108+
{ KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
109+
{ KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
110+
{ KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
111+
{ KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
112+
{ KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
113+
{ KEY_UP, KEY_PAGEUP },
114+
{ KEY_DOWN, KEY_PAGEDOWN },
115+
{ KEY_LEFT, KEY_HOME },
116+
{ KEY_RIGHT, KEY_END },
117+
{ }
118+
};
119+
100120
static const struct apple_key_translation apple2021_fn_keys[] = {
101121
{ KEY_BACKSPACE, KEY_DELETE },
102122
{ KEY_ENTER, KEY_INSERT },
@@ -282,6 +302,9 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
282302
hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO ||
283303
hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS)
284304
table = magic_keyboard_alu_fn_keys;
305+
else if (hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015 ||
306+
hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015)
307+
table = magic_keyboard_2015_fn_keys;
285308
else if (hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021 ||
286309
hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021 ||
287310
hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021)
@@ -500,6 +523,7 @@ static void apple_setup_input(struct input_dev *input)
500523
apple_setup_key_translation(input, powerbook_numlock_keys);
501524
apple_setup_key_translation(input, apple_iso_keyboard);
502525
apple_setup_key_translation(input, magic_keyboard_alu_fn_keys);
526+
apple_setup_key_translation(input, magic_keyboard_2015_fn_keys);
503527
apple_setup_key_translation(input, apple2021_fn_keys);
504528

505529
if (swap_fn_leftctrl)

0 commit comments

Comments
 (0)