From: Aditya Garg <gargaditya08@live.com>
To: Jiri Kosina <jikos@kernel.org>,
"jkosina@suse.com" <jkosina@suse.com>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
"bentiss@kernel.org" <bentiss@kernel.org>
Cc: Alex Henrie <alexhenrie24@gmail.com>,
"jose.exposito89@gmail.com" <jose.exposito89@gmail.com>,
"bruners@gmail.com" <bruners@gmail.com>,
"seobrien@chromium.org" <seobrien@chromium.org>,
"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH RESEND 2/3] HID: apple: Use common table for Magic Keyboard aluminium and 2015 fn mapping
Date: Thu, 13 Feb 2025 16:06:58 +0000 [thread overview]
Message-ID: <68C708C5-EF7E-4CF9-B593-C538E4E730AF@live.com> (raw)
In-Reply-To: <FE7D2C98-2BF5-48C2-8183-68EC1085C1EC@live.com>
From: Aditya Garg <gargaditya08@live.com>
The only difference between the fn mapping of Magic Keyboard aluminium and
2015 is of the presence of KEY_F6 in the translation table.
We can easily use a flag instead of writing the whole table again to omit
it from 2015 model.
Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
drivers/hid/hid-apple.c | 37 ++++++++-----------------------------
1 file changed, 8 insertions(+), 29 deletions(-)
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index e31c9e8e8..ca462e483 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -125,14 +125,14 @@ struct apple_key_translation {
u8 flags;
};
-static const struct apple_key_translation magic_keyboard_alu_fn_keys[] = {
+static const struct apple_key_translation magic_keyboard_alu_and_2015_fn_keys[] = {
{ KEY_BACKSPACE, KEY_DELETE },
{ KEY_ENTER, KEY_INSERT },
{ KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
{ KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
{ KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
{ KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY },
- { KEY_F6, KEY_NUMLOCK, APPLE_FLAG_FKEY },
+ { KEY_F6, KEY_NUMLOCK, APPLE_FLAG_FKEY | APPLE_FLAG_DONT_TRANSLATE },
{ KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
{ KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
{ KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
@@ -146,27 +146,7 @@ static const struct apple_key_translation magic_keyboard_alu_fn_keys[] = {
{ }
};
-static const struct apple_key_translation magic_keyboard_2015_fn_keys[] = {
- { KEY_BACKSPACE, KEY_DELETE },
- { KEY_ENTER, KEY_INSERT },
- { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
- { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
- { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY },
- { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY },
- { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY },
- { KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY },
- { KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY },
- { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY },
- { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY },
- { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY },
- { KEY_UP, KEY_PAGEUP },
- { KEY_DOWN, KEY_PAGEDOWN },
- { KEY_LEFT, KEY_HOME },
- { KEY_RIGHT, KEY_END },
- { }
-};
-
-static const struct apple_key_translation apple2021_fn_keys[] = {
+static const struct apple_key_translation magic_keyboard_2021_and_2024_fn_keys[] = {
{ KEY_BACKSPACE, KEY_DELETE },
{ KEY_ENTER, KEY_INSERT },
{ KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
@@ -448,15 +428,15 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI ||
hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO ||
hid->product == USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS)
- table = magic_keyboard_alu_fn_keys;
+ table = magic_keyboard_alu_and_2015_fn_keys;
else if (hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2015 ||
hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2015)
- table = magic_keyboard_2015_fn_keys;
+ table = magic_keyboard_alu_and_2015_fn_keys, dont_translate_flagged_key = true;
else if (hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2021 ||
hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_2024 ||
hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_FINGERPRINT_2021 ||
hid->product == USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_2021)
- table = apple2021_fn_keys;
+ table = magic_keyboard_2021_and_2024_fn_keys;
else if (hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J132 ||
hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J680 ||
hid->product == USB_DEVICE_ID_APPLE_WELLSPRINGT2_J213)
@@ -660,9 +640,8 @@ static void apple_setup_input(struct input_dev *input)
apple_setup_key_translation(input, powerbook_fn_keys);
apple_setup_key_translation(input, powerbook_numlock_keys);
apple_setup_key_translation(input, apple_iso_keyboard);
- apple_setup_key_translation(input, magic_keyboard_alu_fn_keys);
- apple_setup_key_translation(input, magic_keyboard_2015_fn_keys);
- apple_setup_key_translation(input, apple2021_fn_keys);
+ apple_setup_key_translation(input, magic_keyboard_alu_and_2015_fn_keys);
+ apple_setup_key_translation(input, magic_keyboard_2021_and_2024_fn_keys);
apple_setup_key_translation(input, macbookpro_fn_keys);
}
--
2.43.0
next prev parent reply other threads:[~2025-02-13 16:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-13 16:06 [PATCH RESEND 1/3] HID: apple: Use common table for MacBook Pro " Aditya Garg
2025-02-13 16:06 ` Aditya Garg [this message]
2025-02-13 16:07 ` [PATCH RESEND 3/3] HID: apple: simplify logic for swapping only left sided option and command keys Aditya Garg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=68C708C5-EF7E-4CF9-B593-C538E4E730AF@live.com \
--to=gargaditya08@live.com \
--cc=alexhenrie24@gmail.com \
--cc=benjamin.tissoires@redhat.com \
--cc=bentiss@kernel.org \
--cc=bruners@gmail.com \
--cc=jikos@kernel.org \
--cc=jkosina@suse.com \
--cc=jose.exposito89@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=seobrien@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®