|
Line
Link Here
|
| 0 |
-- a/drivers/hid/hid-apple.c |
0 |
++ b/drivers/hid/hid-apple.c |
|
Lines 57-62
Link Here
|
| 57 |
"(For people who want to keep PC keyboard muscle memory. " |
57 |
"(For people who want to keep PC keyboard muscle memory. " |
| 58 |
"[0] = as-is, Mac layout, 1 = swapped, PC layout)"); |
58 |
"[0] = as-is, Mac layout, 1 = swapped, PC layout)"); |
| 59 |
|
59 |
|
|
|
60 |
static unsigned int swap_fn_f13_insert; |
| 61 |
module_param(swap_fn_f13_insert, uint, 0644); |
| 62 |
MODULE_PARM_DESC(swap_fn_f13_insert, "Swap the Fn and f13 keys, making fn insert and f13 fn. " |
| 63 |
"(For people who need insert." |
| 64 |
"[0] = as-is, Mac layout, 1 = swapped)"); |
| 65 |
|
| 66 |
static unsigned int rightalt_as_rightctrl; |
| 67 |
module_param(rightalt_as_rightctrl, uint, 0644); |
| 68 |
MODULE_PARM_DESC(rightalt_as_rightctrl, "Use the right Alt key as a right Ctrl key. " |
| 69 |
"[0] = as-is, Mac layout. 1 = Right Alt is right Ctrl"); |
| 70 |
|
| 71 |
static unsigned int ejectcd_as_delete; |
| 72 |
module_param(ejectcd_as_delete, uint, 0644); |
| 73 |
MODULE_PARM_DESC(ejectcd_as_delete, "Use Eject-CD key as Delete key. " |
| 74 |
"([0] = disabled, 1 = enabled)"); |
| 75 |
|
| 60 |
struct apple_sc { |
76 |
struct apple_sc { |
| 61 |
unsigned long quirks; |
77 |
unsigned long quirks; |
| 62 |
unsigned int fn_on; |
78 |
unsigned int fn_on; |
|
Lines 174-179
Link Here
|
| 174 |
{ } |
190 |
{ } |
| 175 |
}; |
191 |
}; |
| 176 |
|
192 |
|
|
|
193 |
static const struct apple_key_translation swapped_fn_f13_keys[] = { |
| 194 |
{ KEY_FN, KEY_F13 }, |
| 195 |
{ } |
| 196 |
}; |
| 197 |
|
| 198 |
static const struct apple_key_translation rightalt_as_rightctrl_keys[] = { |
| 199 |
{ KEY_RIGHTALT, KEY_RIGHTCTRL }, |
| 200 |
{ } |
| 201 |
}; |
| 202 |
|
| 203 |
static const struct apple_key_translation ejectcd_as_delete_keys[] = { |
| 204 |
{ KEY_EJECTCD, KEY_DELETE }, |
| 205 |
{ } |
| 206 |
}; |
| 207 |
|
| 177 |
static const struct apple_key_translation *apple_find_translation( |
208 |
static const struct apple_key_translation *apple_find_translation( |
| 178 |
const struct apple_key_translation *table, u16 from) |
209 |
const struct apple_key_translation *table, u16 from) |
| 179 |
{ |
210 |
{ |
|
Lines 197-208
Link Here
|
| 197 |
|
228 |
|
| 198 |
u16 fn_keycode = (swap_fn_leftctrl) ? (KEY_LEFTCTRL) : (KEY_FN); |
229 |
u16 fn_keycode = (swap_fn_leftctrl) ? (KEY_LEFTCTRL) : (KEY_FN); |
| 199 |
|
230 |
|
|
|
231 |
if (swap_fn_f13_insert && !swap_fn_leftctrl) |
| 232 |
fn_keycode = KEY_F13; |
| 233 |
|
| 200 |
if (usage->code == fn_keycode) { |
234 |
if (usage->code == fn_keycode) { |
| 201 |
asc->fn_on = !!value; |
235 |
asc->fn_on = !!value; |
| 202 |
input_event(input, usage->type, KEY_FN, value); |
236 |
input_event(input, usage->type, KEY_FN, value); |
| 203 |
return 1; |
237 |
return 1; |
| 204 |
} |
238 |
} |
| 205 |
|
239 |
|
|
|
240 |
if (usage->code == KEY_FN && swap_fn_f13_insert && !swap_fn_leftctrl) { |
| 241 |
input_event(input, usage->type, KEY_INSERT, value); |
| 242 |
return 1; |
| 243 |
} |
| 244 |
|
| 206 |
if (fnmode) { |
245 |
if (fnmode) { |
| 207 |
if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI && |
246 |
if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI && |
| 208 |
hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) |
247 |
hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) |
|
Lines 276-281
Link Here
|
| 276 |
} |
315 |
} |
| 277 |
} |
316 |
} |
| 278 |
|
317 |
|
|
|
318 |
if (rightalt_as_rightctrl) { |
| 319 |
trans = apple_find_translation(rightalt_as_rightctrl_keys, usage->code); |
| 320 |
if (trans) { |
| 321 |
input_event(input, usage->type, trans->to, value); |
| 322 |
return 1; |
| 323 |
} |
| 324 |
} |
| 325 |
|
| 279 |
if (swap_opt_cmd) { |
326 |
if (swap_opt_cmd) { |
| 280 |
trans = apple_find_translation(swapped_option_cmd_keys, usage->code); |
327 |
trans = apple_find_translation(swapped_option_cmd_keys, usage->code); |
| 281 |
if (trans) { |
328 |
if (trans) { |
|
Lines 292-297
Link Here
|
| 292 |
} |
339 |
} |
| 293 |
} |
340 |
} |
| 294 |
|
341 |
|
|
|
342 |
if (swap_fn_f13_insert && !swap_fn_leftctrl) { |
| 343 |
trans = apple_find_translation(swapped_fn_f13_keys, usage->code); |
| 344 |
if (trans) { |
| 345 |
input_event(input, usage->type, trans->to, value); |
| 346 |
return 1; |
| 347 |
} |
| 348 |
} |
| 349 |
|
| 350 |
if (ejectcd_as_delete) { |
| 351 |
trans = apple_find_translation(ejectcd_as_delete_keys, usage->code); |
| 352 |
if (trans) { |
| 353 |
input_event(input, usage->type, trans->to, value); |
| 354 |
return 1; |
| 355 |
} |
| 356 |
} |
| 357 |
|
| 295 |
return 0; |
358 |
return 0; |
| 296 |
} |
359 |
} |
| 297 |
|
360 |
|
|
Lines 360-365
Link Here
|
| 360 |
for (trans = swapped_fn_leftctrl_keys; trans->from; trans++) |
423 |
for (trans = swapped_fn_leftctrl_keys; trans->from; trans++) |
| 361 |
set_bit(trans->to, input->keybit); |
424 |
set_bit(trans->to, input->keybit); |
| 362 |
} |
425 |
} |
|
|
426 |
|
| 427 |
if (swap_fn_f13_insert && !swap_fn_leftctrl) { |
| 428 |
for (trans = swapped_fn_f13_keys; trans->from; trans++) |
| 429 |
set_bit(trans->to, input->keybit); |
| 430 |
} |
| 431 |
|
| 432 |
if (ejectcd_as_delete) { |
| 433 |
for (trans = ejectcd_as_delete_keys; trans->from; trans++) |
| 434 |
set_bit(trans->to, input->keybit); |
| 435 |
} |
| 436 |
|
| 437 |
if (rightalt_as_rightctrl) { |
| 438 |
for (trans = rightalt_as_rightctrl_keys; trans->from; trans++) |
| 439 |
set_bit(trans->to, input->keybit); |
| 440 |
} |
| 363 |
} |
441 |
} |
| 364 |
|
442 |
|
| 365 |
static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi, |
443 |
static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi, |