Skip to content

Commit e0b7864

Browse files
committed
HID: apple: add Fn key mapping for Apple silicon MacBooks
Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 7ba7a70 commit e0b7864

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
@@ -276,6 +276,28 @@ static const struct apple_key_translation apple_fn_keys[] = {
276276
{ }
277277
};
278278

279+
static const struct apple_key_translation apple_fn_keys_spi[] = {
280+
{ KEY_BACKSPACE, KEY_DELETE },
281+
{ KEY_ENTER, KEY_INSERT },
282+
{ KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
283+
{ KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
284+
{ KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
285+
{ KEY_F4, KEY_SEARCH, APPLE_FLAG_FKEY },
286+
{ KEY_F5, KEY_RECORD, APPLE_FLAG_FKEY },
287+
{ KEY_F6, KEY_SLEEP, APPLE_FLAG_FKEY },
288+
{ KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
289+
{ KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
290+
{ KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
291+
{ KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
292+
{ KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
293+
{ KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
294+
{ KEY_UP, KEY_PAGEUP },
295+
{ KEY_DOWN, KEY_PAGEDOWN },
296+
{ KEY_LEFT, KEY_HOME },
297+
{ KEY_RIGHT, KEY_END },
298+
{ }
299+
};
300+
279301
static const struct apple_key_translation powerbook_fn_keys[] = {
280302
{ KEY_BACKSPACE, KEY_DELETE },
281303
{ KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
@@ -491,6 +513,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
491513
else if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
492514
hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
493515
table = macbookair_fn_keys;
516+
else if (hid->vendor == SPI_VENDOR_ID_APPLE)
517+
table = apple_fn_keys_spi;
494518
else if (hid->product < 0x21d || hid->product >= 0x300)
495519
table = powerbook_fn_keys;
496520
else
@@ -670,6 +694,7 @@ static void apple_setup_input(struct input_dev *input)
670694

671695
/* Enable all needed keys */
672696
apple_setup_key_translation(input, apple_fn_keys);
697+
apple_setup_key_translation(input, apple_fn_keys_spi);
673698
apple_setup_key_translation(input, powerbook_fn_keys);
674699
apple_setup_key_translation(input, powerbook_numlock_keys);
675700
apple_setup_key_translation(input, apple_iso_keyboard);

0 commit comments

Comments
 (0)