Skip to content

Commit 930b000

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

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 },
@@ -499,6 +521,9 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
499521
else if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
500522
hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
501523
table = macbookair_fn_keys;
524+
else if (hid->vendor == SPI_VENDOR_ID_APPLE &&
525+
hid->product == SPI_DEVICE_ID_APPLE_MACBOOK_PRO13_2020)
526+
table = apple_fn_keys_mbp13;
502527
else if (hid->vendor == SPI_VENDOR_ID_APPLE)
503528
table = apple_fn_keys_spi;
504529
else if (hid->product < 0x21d || hid->product >= 0x300)
@@ -681,6 +706,7 @@ static void apple_setup_input(struct input_dev *input)
681706
/* Enable all needed keys */
682707
apple_setup_key_translation(input, apple_fn_keys);
683708
apple_setup_key_translation(input, apple_fn_keys_spi);
709+
apple_setup_key_translation(input, apple_fn_keys_mbp13);
684710
apple_setup_key_translation(input, powerbook_fn_keys);
685711
apple_setup_key_translation(input, powerbook_numlock_keys);
686712
apple_setup_key_translation(input, apple_iso_keyboard);

0 commit comments

Comments
 (0)