Skip to content

Commit e21bd7d

Browse files
committed
HID: apple: add Fn key mapping for Macbook Pro with touchbar
Signed-off-by: Janne Grunau <j@jannau.net>
1 parent e0b7864 commit e21bd7d

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
@@ -298,6 +298,28 @@ static const struct apple_key_translation apple_fn_keys_spi[] = {
298298
{ }
299299
};
300300

301+
static const struct apple_key_translation apple_fn_keys_mbp13[] = {
302+
{ KEY_BACKSPACE, KEY_DELETE },
303+
{ KEY_ENTER, KEY_INSERT },
304+
{ KEY_UP, KEY_PAGEUP },
305+
{ KEY_DOWN, KEY_PAGEDOWN },
306+
{ KEY_LEFT, KEY_HOME },
307+
{ KEY_RIGHT, KEY_END },
308+
{ KEY_1, KEY_F1 },
309+
{ KEY_2, KEY_F2 },
310+
{ KEY_3, KEY_F3 },
311+
{ KEY_4, KEY_F4 },
312+
{ KEY_5, KEY_F5 },
313+
{ KEY_6, KEY_F6 },
314+
{ KEY_7, KEY_F7 },
315+
{ KEY_8, KEY_F8 },
316+
{ KEY_9, KEY_F9 },
317+
{ KEY_0, KEY_F10 },
318+
{ KEY_MINUS, KEY_F11 },
319+
{ KEY_EQUAL, KEY_F12 },
320+
{ }
321+
};
322+
301323
static const struct apple_key_translation powerbook_fn_keys[] = {
302324
{ KEY_BACKSPACE, KEY_DELETE },
303325
{ KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
@@ -513,6 +535,9 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
513535
else if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
514536
hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
515537
table = macbookair_fn_keys;
538+
else if (hid->vendor == SPI_VENDOR_ID_APPLE &&
539+
hid->product == SPI_DEVICE_ID_APPLE_MACBOOK_PRO13_2020)
540+
table = apple_fn_keys_mbp13;
516541
else if (hid->vendor == SPI_VENDOR_ID_APPLE)
517542
table = apple_fn_keys_spi;
518543
else if (hid->product < 0x21d || hid->product >= 0x300)
@@ -695,6 +720,7 @@ static void apple_setup_input(struct input_dev *input)
695720
/* Enable all needed keys */
696721
apple_setup_key_translation(input, apple_fn_keys);
697722
apple_setup_key_translation(input, apple_fn_keys_spi);
723+
apple_setup_key_translation(input, apple_fn_keys_mbp13);
698724
apple_setup_key_translation(input, powerbook_fn_keys);
699725
apple_setup_key_translation(input, powerbook_numlock_keys);
700726
apple_setup_key_translation(input, apple_iso_keyboard);

0 commit comments

Comments
 (0)