Skip to content

Commit 72e49ca

Browse files
BrunersJiri Kosina
authored andcommitted
HID: apple: Option to swap only left side mod keys
On the Keychron K8 keyboard, and probably others, the right side keys should not be swapped to maintain PC layout. Swapping the right side keys moves 'Super' before 'Alt gr' which is not intended by the default Keychron layout or the ISO layout. Signed-off-by: Lasse Brun <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent fa56e0e commit 72e49ca

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

drivers/hid/hid-apple.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static unsigned int swap_opt_cmd;
5858
module_param(swap_opt_cmd, uint, 0644);
5959
MODULE_PARM_DESC(swap_opt_cmd, "Swap the Option (\"Alt\") and Command (\"Flag\") keys. "
6060
"(For people who want to keep Windows PC keyboard muscle memory. "
61-
"[0] = as-is, Mac layout. 1 = swapped, Windows layout.)");
61+
"[0] = as-is, Mac layout. 1 = swapped, Windows layout., 2 = swapped, Swap only left side)");
6262

6363
static unsigned int swap_ctrl_cmd;
6464
module_param(swap_ctrl_cmd, uint, 0644);
@@ -319,6 +319,12 @@ static const struct apple_key_translation swapped_option_cmd_keys[] = {
319319
{ }
320320
};
321321

322+
static const struct apple_key_translation swapped_option_cmd_left_keys[] = {
323+
{ KEY_LEFTALT, KEY_LEFTMETA },
324+
{ KEY_LEFTMETA, KEY_LEFTALT },
325+
{ }
326+
};
327+
322328
static const struct apple_key_translation swapped_ctrl_cmd_keys[] = {
323329
{ KEY_LEFTCTRL, KEY_LEFTMETA },
324330
{ KEY_LEFTMETA, KEY_LEFTCTRL },
@@ -416,7 +422,10 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
416422
}
417423

418424
if (swap_opt_cmd) {
419-
trans = apple_find_translation(swapped_option_cmd_keys, code);
425+
if (swap_opt_cmd == 2)
426+
trans = apple_find_translation(swapped_option_cmd_left_keys, code);
427+
else
428+
trans = apple_find_translation(swapped_option_cmd_keys, code);
420429

421430
if (trans)
422431
code = trans->to;

0 commit comments

Comments
 (0)