Skip to content

Commit 7e1be65

Browse files
jannaumarcan
authored andcommitted
HID: apple: add Fn key mapping for Macbook Pro with touchbar
Signed-off-by: Janne Grunau <[email protected]>
1 parent d31aa43 commit 7e1be65

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

drivers/hid/hid-apple.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,28 @@ static const struct apple_key_translation apple_fn_keys_spi[] = {
284284
{ }
285285
};
286286

287+
static const struct apple_key_translation apple_fn_keys_mbp13[] = {
288+
{ KEY_BACKSPACE, KEY_DELETE },
289+
{ KEY_ENTER, KEY_INSERT },
290+
{ KEY_UP, KEY_PAGEUP },
291+
{ KEY_DOWN, KEY_PAGEDOWN },
292+
{ KEY_LEFT, KEY_HOME },
293+
{ KEY_RIGHT, KEY_END },
294+
{ KEY_1, KEY_F1 },
295+
{ KEY_2, KEY_F2 },
296+
{ KEY_3, KEY_F3 },
297+
{ KEY_4, KEY_F4 },
298+
{ KEY_5, KEY_F5 },
299+
{ KEY_6, KEY_F6 },
300+
{ KEY_7, KEY_F7 },
301+
{ KEY_8, KEY_F8 },
302+
{ KEY_9, KEY_F9 },
303+
{ KEY_0, KEY_F10 },
304+
{ KEY_MINUS, KEY_F11 },
305+
{ KEY_EQUAL, KEY_F12 },
306+
{ }
307+
};
308+
287309
static const struct apple_key_translation powerbook_fn_keys[] = {
288310
{ KEY_BACKSPACE, KEY_DELETE },
289311
{ KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
@@ -485,6 +507,9 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
485507
else if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
486508
hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
487509
table = macbookair_fn_keys;
510+
else if (hid->vendor == SPI_VENDOR_ID_APPLE &&
511+
hid->product == SPI_DEVICE_ID_APPLE_MACBOOK_PRO13_2020)
512+
table = apple_fn_keys_mbp13;
488513
else if (hid->vendor == SPI_VENDOR_ID_APPLE)
489514
table = apple_fn_keys_spi;
490515
else if (hid->product < 0x21d || hid->product >= 0x300)
@@ -667,6 +692,7 @@ static void apple_setup_input(struct input_dev *input)
667692
/* Enable all needed keys */
668693
apple_setup_key_translation(input, apple_fn_keys);
669694
apple_setup_key_translation(input, apple_fn_keys_spi);
695+
apple_setup_key_translation(input, apple_fn_keys_mbp13);
670696
apple_setup_key_translation(input, powerbook_fn_keys);
671697
apple_setup_key_translation(input, powerbook_numlock_keys);
672698
apple_setup_key_translation(input, apple_iso_keyboard);

0 commit comments

Comments
 (0)