|
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,27 @@ 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 | + { "GANSS" } |
| 325 | +}; |
| 326 | + |
| 327 | +static bool apple_is_non_apple_keyboard(struct hid_device *hdev) |
| 328 | +{ |
| 329 | + int i; |
| 330 | + |
| 331 | + for (i = 0; i < ARRAY_SIZE(non_apple_keyboards); i++) { |
| 332 | + char *non_apple = non_apple_keyboards[i].name; |
| 333 | + |
| 334 | + if (strncmp(hdev->name, non_apple, strlen(non_apple)) == 0) |
| 335 | + return true; |
| 336 | + } |
| 337 | + |
| 338 | + return false; |
| 339 | +} |
| 340 | + |
316 | 341 | static inline void apple_setup_key_translation(struct input_dev *input, |
317 | 342 | const struct apple_key_translation *table) |
318 | 343 | { |
@@ -363,7 +388,7 @@ static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, |
363 | 388 | } |
364 | 389 |
|
365 | 390 | if (fnmode == 3) { |
366 | | - real_fnmode = (asc->quirks & APPLE_IS_KEYCHRON) ? 2 : 1; |
| 391 | + real_fnmode = (asc->quirks & APPLE_IS_NON_APPLE) ? 2 : 1; |
367 | 392 | } else { |
368 | 393 | real_fnmode = fnmode; |
369 | 394 | } |
@@ -669,9 +694,9 @@ static int apple_input_configured(struct hid_device *hdev, |
669 | 694 | asc->quirks &= ~APPLE_HAS_FN; |
670 | 695 | } |
671 | 696 |
|
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; |
| 697 | + if (apple_is_non_apple_keyboard(hdev)) { |
| 698 | + hid_info(hdev, "Non-apple keyboard detected; function keys will default to fnmode=2 behavior\n"); |
| 699 | + asc->quirks |= APPLE_IS_NON_APPLE; |
675 | 700 | } |
676 | 701 |
|
677 | 702 | return 0; |
|
0 commit comments