mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Florian Klink <flokli@flokli.de>
To: Jiri Kosina <jikos@kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	ValdikSS <iam@valdikss.org.ru>, Florian Klink <flokli@flokli.de>
Subject: [PATCH v4 2/3] HID: lenovo: Sync Fn-lock state on button press for Compact and TrackPoint II keyboards
Date: Sun, 13 Feb 2022 22:49:23 +0100	[thread overview]
Message-ID: <20220213214924.32407-3-flokli@flokli.de> (raw)
In-Reply-To: <20220213214924.32407-1-flokli@flokli.de>

From: ValdikSS <iam@valdikss.org.ru>

When Fn-Esc is pressed on the keyboard, it emits the scancode which could
be used to sync the fn_lock sysfs state.

Previously fn_lock only allowed to set new Fn-lock state and did not
keep the value in sync upon Fn-Esc press, which is now fixed.

Signed-off-by: Florian Klink <flokli@flokli.de>
---
 drivers/hid/hid-lenovo.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c
index a612ae7dfbfc..e9466ae8a9cb 100644
--- a/drivers/hid/hid-lenovo.c
+++ b/drivers/hid/hid-lenovo.c
@@ -690,6 +690,15 @@ static int lenovo_event_cptkbd(struct hid_device *hdev,
 		return 1;
 	}
 
+	if (usage->type == EV_KEY && usage->code == KEY_FN_ESC && value == 1) {
+		/*
+		 * The user has toggled the Fn-lock state. Toggle our own
+		 * cached value of it and sync our value to the keyboard to
+		 * ensure things are in sync (the syncing should be a no-op).
+		 */
+		cptkbd_data->fn_lock = !cptkbd_data->fn_lock;
+	}
+
 	return 0;
 }
 
-- 
2.35.1


  parent reply	other threads:[~2022-02-13 21:56 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-13 21:49 [PATCH v4 0/3] HID: lenovo: Add support for ThinkPad TrackPoint Florian Klink
2022-02-13 21:49 ` [PATCH v4 1/3] HID: lenovo: Add support for ThinkPad TrackPoint Keyboard II Florian Klink
2022-04-01 10:30   ` Benjamin Tissoires
2022-04-01 11:57     ` Florian Klink
2022-02-13 21:49 ` Florian Klink [this message]
2022-02-13 21:49 ` [PATCH v4 3/3] HID: lenovo: Add note about different report numbers Florian Klink
2022-05-02 15:50 ` [PATCH v4 0/3] HID: lenovo: Add support for ThinkPad TrackPoint Jiri Kosina

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=20220213214924.32407-3-flokli@flokli.de \
    --to=flokli@flokli.de \
    --cc=benjamin.tissoires@redhat.com \
    --cc=iam@valdikss.org.ru \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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®