Skip to content

Commit

Permalink
HID: lenovo: Sync Fn-lock state on button press for Compact and Track…
Browse files Browse the repository at this point in the history
…Point 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 <flokli@flokli.de>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
  • Loading branch information
ValdikSS authored and Jiri Kosina committed May 2, 2022
1 parent 24401f2 commit a0a5c2a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/hid/hid-lenovo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit a0a5c2a

Please sign in to comment.