Skip to content

Commit f79cbe9

Browse files
jannaumarcan
authored andcommitted
HID: apple: add Fn key mapping for Apple silicon MacBooks
Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 85196a3 commit f79cbe9

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
@@ -263,6 +263,28 @@ static const struct apple_key_translation apple_fn_keys[] = {
263263
{ }
264264
};
265265

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

644668
/* Enable all needed keys */
645669
apple_setup_key_translation(input, apple_fn_keys);
670+
apple_setup_key_translation(input, apple_fn_keys_spi);
646671
apple_setup_key_translation(input, powerbook_fn_keys);
647672
apple_setup_key_translation(input, powerbook_numlock_keys);
648673
apple_setup_key_translation(input, apple_iso_keyboard);

0 commit comments

Comments
 (0)