|
36 | 36 | #define APPLE_NUMLOCK_EMULATION BIT(8)
|
37 | 37 | #define APPLE_RDESC_BATTERY BIT(9)
|
38 | 38 | #define APPLE_BACKLIGHT_CTL BIT(10)
|
39 |
| -#define APPLE_IS_KEYCHRON BIT(11) |
| 39 | +#define APPLE_IS_NON_APPLE BIT(11) |
40 | 40 |
|
41 | 41 | #define APPLE_FLAG_FKEY 0x01
|
42 | 42 |
|
@@ -65,6 +65,10 @@ MODULE_PARM_DESC(swap_fn_leftctrl, "Swap the Fn and left Control keys. "
|
65 | 65 | "(For people who want to keep PC keyboard muscle memory. "
|
66 | 66 | "[0] = as-is, Mac layout, 1 = swapped, PC layout)");
|
67 | 67 |
|
| 68 | +struct apple_non_apple_keyboard { |
| 69 | + char *name; |
| 70 | +}; |
| 71 | + |
68 | 72 | struct apple_sc_backlight {
|
69 | 73 | struct led_classdev cdev;
|
70 | 74 | struct hid_device *hdev;
|
@@ -313,6 +317,26 @@ static const struct apple_key_translation swapped_fn_leftctrl_keys[] = {
|
313 | 317 | { }
|
314 | 318 | };
|
315 | 319 |
|
| 320 | +static const struct apple_non_apple_keyboard non_apple_keyboards[] = { |
| 321 | + { "SONiX USB DEVICE" }, |
| 322 | + { "Keychron" }, |
| 323 | + { "AONE" } |
| 324 | +}; |
| 325 | + |
| 326 | +static bool apple_is_non_apple_keyboard(struct hid_device *hdev) |
| 327 | +{ |
| 328 | + int i; |
| 329 | + |
| 330 | + for (i = 0; i < ARRAY_SIZE(non_apple_keyboards); i++) { |
| 331 | + char *non_apple = non_apple_keyboards[i].name; |
| 332 | + |
| 333 | + if (strncmp(hdev->name, non_apple, strlen(non_apple)) == 0) |
| 334 | + return true; |
| 335 | + } |
| 336 | + |
| 337 | + return false; |
| 338 | +} |
| 339 | + |
316 | 340 | static inline void apple_setup_key_translation(struct input_dev *input,
|
317 | 341 | const struct apple_key_translation *table)
|
318 | 342 | {
|
@@ -363,7 +387,7 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input,
|
363 | 387 | }
|
364 | 388 |
|
365 | 389 | if (fnmode == 3) {
|
366 |
| - real_fnmode = (asc->quirks & APPLE_IS_KEYCHRON) ? 2 : 1; |
| 390 | + real_fnmode = (asc->quirks & APPLE_IS_NON_APPLE) ? 2 : 1; |
367 | 391 | } else {
|
368 | 392 | real_fnmode = fnmode;
|
369 | 393 | }
|
@@ -669,9 +693,9 @@ static int apple_input_configured(struct hid_device *hdev,
|
669 | 693 | asc->quirks &= ~APPLE_HAS_FN;
|
670 | 694 | }
|
671 | 695 |
|
672 |
| - if (strncmp(hdev->name, "Keychron", 8) == 0) { |
673 |
| - hid_info(hdev, "Keychron keyboard detected; function keys will default to fnmode=2 behavior\n"); |
674 |
| - asc->quirks |= APPLE_IS_KEYCHRON; |
| 696 | + if (apple_is_non_apple_keyboard(hdev)) { |
| 697 | + hid_info(hdev, "Non-apple keyboard detected; function keys will default to fnmode=2 behavior\n"); |
| 698 | + asc->quirks |= APPLE_IS_NON_APPLE; |
675 | 699 | }
|
676 | 700 |
|
677 | 701 | return 0;
|
|
0 commit comments