Skip to content

Commit 5f902ea

Browse files
jannaumarcan
authored andcommitted
HID: apple: add Fn key mapping for Macbook Pro with touchbar
Signed-off-by: Janne Grunau <j@jannau.net>
1 parent f79cbe9 commit 5f902ea

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
@@ -285,6 +285,28 @@ static const struct apple_key_translation apple_fn_keys_spi[] = {
285285
{ }
286286
};
287287

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

0 commit comments

Comments
 (0)