Skip to content

Commit f43fd03

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

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 },
@@ -477,6 +499,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
477499
else if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI &&
478500
hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS)
479501
table = macbookair_fn_keys;
502+
else if (hid->vendor == SPI_VENDOR_ID_APPLE)
503+
table = apple_fn_keys_spi;
480504
else if (hid->product < 0x21d || hid->product >= 0x300)
481505
table = powerbook_fn_keys;
482506
else
@@ -656,6 +680,7 @@ static void apple_setup_input(struct input_dev *input)
656680

657681
/* Enable all needed keys */
658682
apple_setup_key_translation(input, apple_fn_keys);
683+
apple_setup_key_translation(input, apple_fn_keys_spi);
659684
apple_setup_key_translation(input, powerbook_fn_keys);
660685
apple_setup_key_translation(input, powerbook_numlock_keys);
661686
apple_setup_key_translation(input, apple_iso_keyboard);

0 commit comments

Comments
 (0)