Thread (2 messages) flat view 2 messages, 1 author, 2021-10-17
DORMANTno replies

[PATCH 2/2] Sync Fn-lock state on button press for Compact and TrackPoint II keyboards

From: ValdikSS <hidden>
Date: 2021-10-17 08:38:43
Subsystem: hid core layer, lenovo hid drivers, the rest · Maintainers: Jiri Kosina, Benjamin Tissoires, Derek J. Clark, Mark Pearson, Linus Torvalds

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.

Signed-off-by: ValdikSS <redacted>
---
 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 498246cab..62561fb9f 100644
--- a/drivers/hid/hid-lenovo.c
+++ b/drivers/hid/hid-lenovo.c
@@ -695,6 +695,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.31.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help