Skip to content

Commit d31aa43

Browse files
jannaumarcan
authored andcommitted
HID: apple: add Fn key mapping for Apple silicon MacBooks
Signed-off-by: Janne Grunau <[email protected]>
1 parent dd5ea76 commit d31aa43

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

drivers/hid/hid-apple.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,28 @@ static const struct apple_key_translation apple_fn_keys[] = {
262262
{ }
263263
};
264264

265+
static const struct apple_key_translation apple_fn_keys_spi[] = {
266+
{ KEY_BACKSPACE, KEY_DELETE },
267+
{ KEY_ENTER, KEY_INSERT },
268+
{ KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
269+
{ KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
270+
{ KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
271+
{ KEY_F4, KEY_SEARCH, APPLE_FLAG_FKEY },
272+
{ KEY_F5, KEY_RECORD, APPLE_FLAG_FKEY },
273+
{ KEY_F6, KEY_SLEEP, APPLE_FLAG_FKEY },
274+
{ KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
275+
{ KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
276+
{ KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
277+
{ KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
278+
{ KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
279+
{ KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
280+
{ KEY_UP, KEY_PAGEUP },
281+
{ KEY_DOWN, KEY_PAGEDOWN },
282+
{ KEY_LEFT, KEY_HOME },
283+
{ KEY_RIGHT, KEY_END },
284+
{ }
285+
};
286+
265287
static const struct apple_key_translation powerbook_fn_keys[] = {
266288
{ KEY_BACKSPACE, KEY_DELETE },
267289
{ KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
@@ -463,6 +485,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
463485
else if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
464486
hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
465487
table = macbookair_fn_keys;
488+
else if (hid->vendor == SPI_VENDOR_ID_APPLE)
489+
table = apple_fn_keys_spi;
466490
else if (hid->product < 0x21d || hid->product >= 0x300)
467491
table = powerbook_fn_keys;
468492
else
@@ -642,6 +666,7 @@ static void apple_setup_input(struct input_dev *input)
642666

643667
/* Enable all needed keys */
644668
apple_setup_key_translation(input, apple_fn_keys);
669+
apple_setup_key_translation(input, apple_fn_keys_spi);
645670
apple_setup_key_translation(input, powerbook_fn_keys);
646671
apple_setup_key_translation(input, powerbook_numlock_keys);
647672
apple_setup_key_translation(input, apple_iso_keyboard);

0 commit comments

Comments
 (0)