|
Line
Link Here
|
| 0 |
-- a/drivers/hid/hid-apple.c |
0 |
++ b/drivers/hid/hid-apple.c |
|
Lines 52-57
Link Here
|
| 52 |
"(For people who want to keep Windows PC keyboard muscle memory. " |
52 |
"(For people who want to keep Windows PC keyboard muscle memory. " |
| 53 |
"[0] = as-is, Mac layout. 1 = swapped, Windows layout.)"); |
53 |
"[0] = as-is, Mac layout. 1 = swapped, Windows layout.)"); |
| 54 |
|
54 |
|
|
|
55 |
static unsigned int swap_fn_leftctrl; |
| 56 |
module_param(swap_fn_leftctrl, uint, 0644); |
| 57 |
MODULE_PARM_DESC(swap_fn_leftctrl, "Swap the Fn and left Control keys. " |
| 58 |
"(For people who want to keep PC keyboard muscle memory. " |
| 59 |
"[0] = as-is, Mac layout, 1 = swapped, PC layout)"); |
| 60 |
|
| 61 |
static unsigned int rightalt_as_rightctrl; |
| 62 |
module_param(rightalt_as_rightctrl, uint, 0644); |
| 63 |
MODULE_PARM_DESC(rightalt_as_rightctrl, "Use the right Alt key as a right Ctrl key. " |
| 64 |
"[0] = as-is, Mac layout. 1 = Right Alt is right Ctrl"); |
| 65 |
|
| 66 |
static unsigned int ejectcd_as_delete; |
| 67 |
module_param(ejectcd_as_delete, uint, 0644); |
| 68 |
MODULE_PARM_DESC(ejectcd_as_delete, "Use Eject-CD key as Delete key. " |
| 69 |
"([0] = disabled, 1 = enabled)"); |
| 70 |
|
| 55 |
struct apple_sc { |
71 |
struct apple_sc { |
| 56 |
unsigned long quirks; |
72 |
unsigned long quirks; |
| 57 |
unsigned int fn_on; |
73 |
unsigned int fn_on; |
|
Lines 164-169
Link Here
|
| 164 |
{ } |
180 |
{ } |
| 165 |
}; |
181 |
}; |
| 166 |
|
182 |
|
|
|
183 |
static const struct apple_key_translation swapped_fn_leftctrl_keys[] = { |
| 184 |
{ KEY_FN, KEY_LEFTCTRL }, |
| 185 |
{ } |
| 186 |
}; |
| 187 |
|
| 188 |
static const struct apple_key_translation rightalt_as_rightctrl_keys[] = { |
| 189 |
{ KEY_RIGHTALT, KEY_RIGHTCTRL }, |
| 190 |
{ } |
| 191 |
}; |
| 192 |
|
| 193 |
static const struct apple_key_translation ejectcd_as_delete_keys[] = { |
| 194 |
{ KEY_EJECTCD, KEY_DELETE }, |
| 195 |
{ } |
| 196 |
}; |
| 197 |
|
| 167 |
static const struct apple_key_translation *apple_find_translation( |
198 |
static const struct apple_key_translation *apple_find_translation( |
| 168 |
const struct apple_key_translation *table, u16 from) |
199 |
const struct apple_key_translation *table, u16 from) |
| 169 |
{ |
200 |
{ |
|
Lines 183-191
Link Here
|
| 183 |
struct apple_sc *asc = hid_get_drvdata(hid); |
214 |
struct apple_sc *asc = hid_get_drvdata(hid); |
| 184 |
const struct apple_key_translation *trans, *table; |
215 |
const struct apple_key_translation *trans, *table; |
| 185 |
|
216 |
|
| 186 |
if (usage->code == KEY_FN) { |
217 |
u16 fn_keycode = (swap_fn_leftctrl) ? (KEY_LEFTCTRL) : (KEY_FN); |
|
|
218 |
|
| 219 |
if (usage->code == fn_keycode) { |
| 187 |
asc->fn_on = !!value; |
220 |
asc->fn_on = !!value; |
| 188 |
input_event(input, usage->type, usage->code, value); |
221 |
input_event(input, usage->type, KEY_FN, value); |
| 189 |
return 1; |
222 |
return 1; |
| 190 |
} |
223 |
} |
| 191 |
|
224 |
|
|
Lines 264-269
Link Here
|
| 264 |
} |
297 |
} |
| 265 |
} |
298 |
} |
| 266 |
|
299 |
|
|
|
300 |
if (swap_fn_leftctrl) { |
| 301 |
trans = apple_find_translation(swapped_fn_leftctrl_keys, usage->code); |
| 302 |
if (trans) { |
| 303 |
input_event(input, usage->type, trans->to, value); |
| 304 |
return 1; |
| 305 |
} |
| 306 |
} |
| 307 |
|
| 308 |
if (ejectcd_as_delete) { |
| 309 |
trans = apple_find_translation(ejectcd_as_delete_keys, usage->code); |
| 310 |
if (trans) { |
| 311 |
input_event(input, usage->type, trans->to, value); |
| 312 |
return 1; |
| 313 |
} |
| 314 |
} |
| 315 |
|
| 316 |
if (rightalt_as_rightctrl) { |
| 317 |
trans = apple_find_translation(rightalt_as_rightctrl_keys, usage->code); |
| 318 |
if (trans) { |
| 319 |
input_event(input, usage->type, trans->to, value); |
| 320 |
return 1; |
| 321 |
} |
| 322 |
} |
| 323 |
|
| 267 |
return 0; |
324 |
return 0; |
| 268 |
} |
325 |
} |
| 269 |
|
326 |
|
|
Lines 327-332
Link Here
|
| 327 |
|
384 |
|
| 328 |
for (trans = apple_iso_keyboard; trans->from; trans++) |
385 |
for (trans = apple_iso_keyboard; trans->from; trans++) |
| 329 |
set_bit(trans->to, input->keybit); |
386 |
set_bit(trans->to, input->keybit); |
|
|
387 |
|
| 388 |
if (swap_fn_leftctrl) { |
| 389 |
for (trans = swapped_fn_leftctrl_keys; trans->from; trans++) |
| 390 |
set_bit(trans->to, input->keybit); |
| 391 |
} |
| 392 |
|
| 393 |
if (ejectcd_as_delete) { |
| 394 |
for (trans = ejectcd_as_delete_keys; trans->from; trans++) |
| 395 |
set_bit(trans->to, input->keybit); |
| 396 |
} |
| 397 |
|
| 398 |
if (rightalt_as_rightctrl) { |
| 399 |
for (trans = rightalt_as_rightctrl_keys; trans->from; trans++) |
| 400 |
set_bit(trans->to, input->keybit); |
| 401 |
} |
| 330 |
} |
402 |
} |
| 331 |
|
403 |
|
| 332 |
static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
404 |
static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi, |