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: Orlando Chamberlain <orlandoch.dev@gmail.com>,
Kerem Karabay <kekrby@gmail.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>
Subject: [PATCH v3 1/3] HID: hid-appletb-kbd: simplify logic used to switch between media and function keys on pressing fn key
Date: Sat, 15 Feb 2025 18:38:46 +0000 [thread overview]
Message-ID: <00768D5D-F9CB-45DA-8F5A-3E21E84A8AA8@live.com> (raw)
From: Aditya Garg <gargaditya08@live.com>
This commit simplifies the logic in appletb_kbd_inp_event used for
switching between the media and function keys on pressing the fn key.
We now also prevent touching the kbd->saved_mode variable in case the esc
key only mode is chosen.
The following small fixes have also been done in this patch:
- A small comment style error has been fixed
- Fixed spelling in MODULE_DESCRIPTION
- I have added myself to MODULE_AUTHOR
Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
drivers/hid/hid-appletb-kbd.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/drivers/hid/hid-appletb-kbd.c b/drivers/hid/hid-appletb-kbd.c
index 38fc0e58c..e45cc3ac4 100644
--- a/drivers/hid/hid-appletb-kbd.c
+++ b/drivers/hid/hid-appletb-kbd.c
@@ -236,13 +236,13 @@ static void appletb_kbd_inp_event(struct input_handle *handle, unsigned int type
reset_inactivity_timer(kbd);
- if (type == EV_KEY && code == KEY_FN && appletb_tb_fn_toggle) {
+ if (type == EV_KEY && code == KEY_FN && appletb_tb_fn_toggle &&
+ (kbd->current_mode == APPLETB_KBD_MODE_SPCL ||
+ kbd->current_mode == APPLETB_KBD_MODE_FN)) {
if (value == 1) {
kbd->saved_mode = kbd->current_mode;
- if (kbd->current_mode == APPLETB_KBD_MODE_SPCL)
- appletb_kbd_set_mode(kbd, APPLETB_KBD_MODE_FN);
- else if (kbd->current_mode == APPLETB_KBD_MODE_FN)
- appletb_kbd_set_mode(kbd, APPLETB_KBD_MODE_SPCL);
+ appletb_kbd_set_mode(kbd, kbd->current_mode == APPLETB_KBD_MODE_SPCL
+ ? APPLETB_KBD_MODE_FN : APPLETB_KBD_MODE_SPCL);
} else if (value == 0) {
if (kbd->saved_mode != kbd->current_mode)
appletb_kbd_set_mode(kbd, kbd->saved_mode);
@@ -497,10 +497,11 @@ static struct hid_driver appletb_kbd_hid_driver = {
};
module_hid_driver(appletb_kbd_hid_driver);
-/* The backlight driver should be loaded before the keyboard driver is initialised*/
+/* The backlight driver should be loaded before the keyboard driver is initialised */
MODULE_SOFTDEP("pre: hid_appletb_bl");
MODULE_AUTHOR("Ronald Tschalär");
MODULE_AUTHOR("Kerem Karabay <kekrby@gmail.com>");
-MODULE_DESCRIPTION("MacBookPro Touch Bar Keyboard Mode Driver");
+MODULE_AUTHOR("Aditya Garg <gargaditya08@live.com>");
+MODULE_DESCRIPTION("MacBook Pro Touch Bar Keyboard Mode driver");
MODULE_LICENSE("GPL");
--
2.43.0
next reply other threads:[~2025-02-15 18:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-15 18:38 Aditya Garg [this message]
2025-02-15 18:39 ` [PATCH v3 2/3] HID: hid-appletb-bl: fix incorrect error message for default brightness Aditya Garg
2025-02-15 18:40 ` [PATCH v3 3/3] HID: appletb-kbd: Fix inconsistent indentation and pass -ENODEV to dev_err_probe 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=00768D5D-F9CB-45DA-8F5A-3E21E84A8AA8@live.com \
--to=gargaditya08@live.com \
--cc=benjamin.tissoires@redhat.com \
--cc=bentiss@kernel.org \
--cc=jikos@kernel.org \
--cc=jkosina@suse.com \
--cc=kekrby@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=orlandoch.dev@gmail.com \
/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®