Skip to content

Commit 534bac4

Browse files
AdityaGarg8Jiri Kosina
authored andcommitted
HID: hid-appletb-kbd: simplify logic used to switch between media and function keys on pressing fn key
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 <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent a4fa2e6 commit 534bac4

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

drivers/hid/hid-appletb-kbd.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,13 @@ static void appletb_kbd_inp_event(struct input_handle *handle, unsigned int type
236236

237237
reset_inactivity_timer(kbd);
238238

239-
if (type == EV_KEY && code == KEY_FN && appletb_tb_fn_toggle) {
239+
if (type == EV_KEY && code == KEY_FN && appletb_tb_fn_toggle &&
240+
(kbd->current_mode == APPLETB_KBD_MODE_SPCL ||
241+
kbd->current_mode == APPLETB_KBD_MODE_FN)) {
240242
if (value == 1) {
241243
kbd->saved_mode = kbd->current_mode;
242-
if (kbd->current_mode == APPLETB_KBD_MODE_SPCL)
243-
appletb_kbd_set_mode(kbd, APPLETB_KBD_MODE_FN);
244-
else if (kbd->current_mode == APPLETB_KBD_MODE_FN)
245-
appletb_kbd_set_mode(kbd, APPLETB_KBD_MODE_SPCL);
244+
appletb_kbd_set_mode(kbd, kbd->current_mode == APPLETB_KBD_MODE_SPCL
245+
? APPLETB_KBD_MODE_FN : APPLETB_KBD_MODE_SPCL);
246246
} else if (value == 0) {
247247
if (kbd->saved_mode != kbd->current_mode)
248248
appletb_kbd_set_mode(kbd, kbd->saved_mode);
@@ -497,10 +497,11 @@ static struct hid_driver appletb_kbd_hid_driver = {
497497
};
498498
module_hid_driver(appletb_kbd_hid_driver);
499499

500-
/* The backlight driver should be loaded before the keyboard driver is initialised*/
500+
/* The backlight driver should be loaded before the keyboard driver is initialised */
501501
MODULE_SOFTDEP("pre: hid_appletb_bl");
502502

503503
MODULE_AUTHOR("Ronald Tschalär");
504504
MODULE_AUTHOR("Kerem Karabay <[email protected]>");
505-
MODULE_DESCRIPTION("MacBookPro Touch Bar Keyboard Mode Driver");
505+
MODULE_AUTHOR("Aditya Garg <[email protected]>");
506+
MODULE_DESCRIPTION("MacBook Pro Touch Bar Keyboard Mode driver");
506507
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)