Skip to content

Commit a0a5c2a

Browse files
ValdikSSJiri Kosina
authored andcommitted
HID: lenovo: Sync Fn-lock state on button press for Compact and TrackPoint II keyboards
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 <[email protected]> Reviewed-by: Benjamin Tissoires <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 24401f2 commit a0a5c2a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/hid/hid-lenovo.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,15 @@ static int lenovo_event_cptkbd(struct hid_device *hdev,
690690
return 1;
691691
}
692692

693+
if (usage->type == EV_KEY && usage->code == KEY_FN_ESC && value == 1) {
694+
/*
695+
* The user has toggled the Fn-lock state. Toggle our own
696+
* cached value of it and sync our value to the keyboard to
697+
* ensure things are in sync (the syncing should be a no-op).
698+
*/
699+
cptkbd_data->fn_lock = !cptkbd_data->fn_lock;
700+
}
701+
693702
return 0;
694703
}
695704

0 commit comments

Comments
 (0)