Skip to content

Commit

Permalink
FN_key swap fix for hid-apple-mod patch
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeeq committed Aug 22, 2019
1 parent f34b485 commit 1c16ea5
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions patches/hid-apple-mod.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ From: fedora kernel <[email protected]>
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. "
Expand All @@ -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 },
+ { }
Expand All @@ -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) {
Expand All @@ -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);
+
Expand All @@ -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 },
Expand All @@ -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),

0 comments on commit 1c16ea5

Please sign in to comment.