From: Aditya Garg <gargaditya08@live.com>
To: Jiri Kosina <jikos@kernel.org>,
"jkosina@suse.com" <jkosina@suse.com>,
"jkosina@suse.cz" <jkosina@suse.cz>,
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 Kernel Mailing List <linux-kernel@vger.kernel.org>,
"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>
Subject: [PATCH v2 3/4] HID: apple: simplify logic for swapping only left sided option and command keys
Date: Fri, 14 Feb 2025 10:07:20 +0000 [thread overview]
Message-ID: <0DE60F20-1000-405B-99D7-70DB51A27BD2@live.com> (raw)
In-Reply-To: <CEFE855F-CC63-4361-8ABD-875BD5662294@live.com>
From: Aditya Garg <gargaditya08@live.com>
In order to swap only left sided option and command keys a separate table
was in use. This commit makes use of the APPLE_FLAG_DONT_TRANSLATE flag to
remove the need of such separate tables.
Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
drivers/hid/hid-apple.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index ca462e483..c672ffc97 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -285,14 +285,8 @@ static const struct apple_key_translation apple_iso_keyboard[] = {
static const struct apple_key_translation swapped_option_cmd_keys[] = {
{ KEY_LEFTALT, KEY_LEFTMETA },
{ KEY_LEFTMETA, KEY_LEFTALT },
- { KEY_RIGHTALT, KEY_RIGHTMETA },
- { KEY_RIGHTMETA, KEY_RIGHTALT },
- { }
-};
-
-static const struct apple_key_translation swapped_option_cmd_left_keys[] = {
- { KEY_LEFTALT, KEY_LEFTMETA },
- { KEY_LEFTMETA, KEY_LEFTALT },
+ { KEY_RIGHTALT, KEY_RIGHTMETA, APPLE_FLAG_DONT_TRANSLATE },
+ { KEY_RIGHTMETA, KEY_RIGHTALT, APPLE_FLAG_DONT_TRANSLATE },
{ }
};
@@ -399,12 +393,9 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
}
if (swap_opt_cmd) {
- if (swap_opt_cmd == 2)
- trans = apple_find_translation(swapped_option_cmd_left_keys, code);
- else
- trans = apple_find_translation(swapped_option_cmd_keys, code);
+ trans = apple_find_translation(swapped_option_cmd_keys, code);
- if (trans)
+ if (trans && !(swap_opt_cmd == 2 && trans->flags & APPLE_FLAG_DONT_TRANSLATE))
code = trans->to;
}
--
2.43.0
next prev parent reply other threads:[~2025-02-14 10:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-14 10:05 [PATCH v2 1/4] HID: apple: Use common table for MacBook Pro fn mapping Aditya Garg
2025-02-14 10:06 ` [PATCH v2 2/4] HID: apple: Use common table for Magic Keyboard aluminium and 2015 " Aditya Garg
2025-02-14 10:07 ` Aditya Garg [this message]
2025-02-14 10:08 ` [PATCH v2 4/4] HID: apple: use switch case to assign devices to their respective " Aditya Garg
2025-02-18 19:59 ` [PATCH v2 1/4] HID: apple: Use common table for MacBook Pro " Jiri Kosina
2025-02-18 20:08 ` Aditya Garg
2025-02-19 16:43 ` Aditya Garg
2025-03-04 20:23 ` Jiri Kosina
2025-03-05 3:33 ` Aditya Garg
2025-03-05 4:11 ` 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=0DE60F20-1000-405B-99D7-70DB51A27BD2@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=jkosina@suse.cz \
--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®