From 1c16ea505d2e694209b2253dcbee81a7e5312c5e Mon Sep 17 00:00:00 2001 From: mikee Date: Thu, 22 Aug 2019 21:58:52 +0200 Subject: [PATCH] FN_key swap fix for hid-apple-mod patch --- patches/hid-apple-mod.patch | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/patches/hid-apple-mod.patch b/patches/hid-apple-mod.patch index 2547a34..85f185c 100644 --- a/patches/hid-apple-mod.patch +++ b/patches/hid-apple-mod.patch @@ -2,13 +2,13 @@ From: fedora kernel Subject: patch hid-apple-mod diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c -index 1cb4199..2760ffe 100644 +index 1cb4199..3f30d04 100644 --- a/drivers/hid/hid-apple.c +++ b/drivers/hid/hid-apple.c @@ -54,6 +54,17 @@ MODULE_PARM_DESC(swap_opt_cmd, "Swap the Option (\"Alt\") and Command (\"Flag\") "(For people who want to keep Windows PC keyboard muscle memory. " "[0] = as-is, Mac layout. 1 = swapped, Windows layout.)"); - + +static unsigned int swap_fn_leftctrl; +module_param(swap_fn_leftctrl, uint, 0644); +MODULE_PARM_DESC(swap_fn_leftctrl, "Swap the Fn and left Control keys. " @@ -26,7 +26,7 @@ index 1cb4199..2760ffe 100644 @@ -166,6 +177,16 @@ static const struct apple_key_translation swapped_option_cmd_keys[] = { { } }; - + +static const struct apple_key_translation swapped_fn_leftctrl_keys[] = { + { KEY_FN, KEY_LEFTCTRL }, + { } @@ -40,19 +40,24 @@ index 1cb4199..2760ffe 100644 static const struct apple_key_translation *apple_find_translation( const struct apple_key_translation *table, u16 from) { -@@ -185,6 +206,8 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, +@@ -185,9 +206,11 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, struct apple_sc *asc = hid_get_drvdata(hid); const struct apple_key_translation *trans, *table; - + +- if (usage->code == KEY_FN) { + u16 fn_keycode = (swap_fn_leftctrl) ? (KEY_LEFTCTRL) : (KEY_FN); + - if (usage->code == KEY_FN) { ++ if (usage->code == fn_keycode) { asc->fn_on = !!value; - input_event(input, usage->type, usage->code, value); +- input_event(input, usage->type, usage->code, value); ++ input_event(input, usage->type, KEY_FN, value); + return 1; + } + @@ -266,6 +289,22 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, } } - + + if (rightalt_as_rightctrl) { + trans = apple_find_translation(rightalt_as_rightctrl_keys, usage->code); + if (trans) { @@ -71,9 +76,9 @@ index 1cb4199..2760ffe 100644 + return 0; } - + @@ -329,6 +368,17 @@ static void apple_setup_input(struct input_dev *input) - + for (trans = apple_iso_keyboard; trans->from; trans++) set_bit(trans->to, input->keybit); + @@ -88,7 +93,7 @@ index 1cb4199..2760ffe 100644 + } + } - + static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi, @@ -557,6 +607,10 @@ static const struct hid_device_id apple_devices[] = { .driver_data = APPLE_HAS_FN }, @@ -101,3 +106,4 @@ index 1cb4199..2760ffe 100644 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI), .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO), +