aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-apple.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hid/hid-apple.c')
-rw-r--r--drivers/hid/hid-apple.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index 881cf7b4f9a4..3b219b9553fb 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -46,6 +46,12 @@ module_param(iso_layout, uint, 0644);
46MODULE_PARM_DESC(iso_layout, "Enable/Disable hardcoded ISO-layout of the keyboard. " 46MODULE_PARM_DESC(iso_layout, "Enable/Disable hardcoded ISO-layout of the keyboard. "
47 "(0 = disabled, [1] = enabled)"); 47 "(0 = disabled, [1] = enabled)");
48 48
49static unsigned int swap_opt_cmd = 0;
50module_param(swap_opt_cmd, uint, 0644);
51MODULE_PARM_DESC(swap_opt_cmd, "Swap the Option (\"Alt\") and Command (\"Flag\") keys. "
52 "(For people who want to keep Windows PC keyboard muscle memory. "
53 "[0] = as-is, Mac layout. 1 = swapped, Windows layout.)");
54
49struct apple_sc { 55struct apple_sc {
50 unsigned long quirks; 56 unsigned long quirks;
51 unsigned int fn_on; 57 unsigned int fn_on;
@@ -150,6 +156,14 @@ static const struct apple_key_translation apple_iso_keyboard[] = {
150 { } 156 { }
151}; 157};
152 158
159static const struct apple_key_translation swapped_option_cmd_keys[] = {
160 { KEY_LEFTALT, KEY_LEFTMETA },
161 { KEY_LEFTMETA, KEY_LEFTALT },
162 { KEY_RIGHTALT, KEY_RIGHTMETA },
163 { KEY_RIGHTMETA,KEY_RIGHTALT },
164 { }
165};
166
153static const struct apple_key_translation *apple_find_translation( 167static const struct apple_key_translation *apple_find_translation(
154 const struct apple_key_translation *table, u16 from) 168 const struct apple_key_translation *table, u16 from)
155{ 169{
@@ -242,6 +256,14 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
242 } 256 }
243 } 257 }
244 258
259 if (swap_opt_cmd) {
260 trans = apple_find_translation(swapped_option_cmd_keys, usage->code);
261 if (trans) {
262 input_event(input, usage->type, trans->to, value);
263 return 1;
264 }
265 }
266
245 return 0; 267 return 0;
246} 268}
247 269