Commit | Line | Data |
---|---|---|
2874c5fd | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
8c19a515 JS |
2 | /* |
3 | * USB HID quirks support for Linux | |
4 | * | |
5 | * Copyright (c) 1999 Andreas Gal | |
6 | * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> | |
7 | * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc | |
8 | * Copyright (c) 2006-2007 Jiri Kosina | |
8c19a515 JS |
9 | * Copyright (c) 2008 Jiri Slaby <jirislaby@gmail.com> |
10 | */ | |
11 | ||
12 | /* | |
8c19a515 JS |
13 | */ |
14 | ||
4291ee30 JP |
15 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
16 | ||
8c19a515 JS |
17 | #include <linux/device.h> |
18 | #include <linux/hid.h> | |
19 | #include <linux/module.h> | |
5a0e3ad6 | 20 | #include <linux/slab.h> |
8c19a515 JS |
21 | |
22 | #include "hid-ids.h" | |
23 | ||
24 | #define APPLE_RDESC_JIS 0x0001 | |
25 | #define APPLE_IGNORE_MOUSE 0x0002 | |
26 | #define APPLE_HAS_FN 0x0004 | |
27 | #define APPLE_HIDDEV 0x0008 | |
bd77a0f0 | 28 | /* 0x0010 reserved, was: APPLE_ISO_KEYBOARD */ |
8c19a515 JS |
29 | #define APPLE_MIGHTYMOUSE 0x0020 |
30 | #define APPLE_INVERT_HWHEEL 0x0040 | |
31 | #define APPLE_IGNORE_HIDINPUT 0x0080 | |
32 | #define APPLE_NUMLOCK_EMULATION 0x0100 | |
33 | ||
34 | #define APPLE_FLAG_FKEY 0x01 | |
35 | ||
bd77a0f0 AH |
36 | #define HID_COUNTRY_INTERNATIONAL_ISO 13 |
37 | ||
8c19a515 JS |
38 | static unsigned int fnmode = 1; |
39 | module_param(fnmode, uint, 0644); | |
40 | MODULE_PARM_DESC(fnmode, "Mode of fn key on Apple keyboards (0 = disabled, " | |
41 | "[1] = fkeyslast, 2 = fkeysfirst)"); | |
42 | ||
54a6593d SG |
43 | static unsigned int iso_layout = 1; |
44 | module_param(iso_layout, uint, 0644); | |
45 | MODULE_PARM_DESC(iso_layout, "Enable/Disable hardcoded ISO-layout of the keyboard. " | |
46 | "(0 = disabled, [1] = enabled)"); | |
47 | ||
a94c79bd | 48 | static unsigned int swap_opt_cmd; |
43c83146 NL |
49 | module_param(swap_opt_cmd, uint, 0644); |
50 | MODULE_PARM_DESC(swap_opt_cmd, "Swap the Option (\"Alt\") and Command (\"Flag\") keys. " | |
51 | "(For people who want to keep Windows PC keyboard muscle memory. " | |
52 | "[0] = as-is, Mac layout. 1 = swapped, Windows layout.)"); | |
53 | ||
346338ef | 54 | static unsigned int swap_fn_leftctrl; |
55 | module_param(swap_fn_leftctrl, uint, 0644); | |
56 | MODULE_PARM_DESC(swap_fn_leftctrl, "Swap the Fn and left Control keys. " | |
57 | "(For people who want to keep PC keyboard muscle memory. " | |
58 | "[0] = as-is, Mac layout, 1 = swapped, PC layout)"); | |
59 | ||
8c19a515 JS |
60 | struct apple_sc { |
61 | unsigned long quirks; | |
62 | unsigned int fn_on; | |
a5d81646 | 63 | unsigned int fn_found; |
8c19a515 JS |
64 | DECLARE_BITMAP(pressed_numlock, KEY_CNT); |
65 | }; | |
66 | ||
67 | struct apple_key_translation { | |
68 | u16 from; | |
69 | u16 to; | |
70 | u8 flags; | |
71 | }; | |
72 | ||
99b9f758 EH |
73 | static const struct apple_key_translation macbookair_fn_keys[] = { |
74 | { KEY_BACKSPACE, KEY_DELETE }, | |
75 | { KEY_ENTER, KEY_INSERT }, | |
76 | { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, | |
77 | { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, | |
78 | { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY }, | |
79 | { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY }, | |
80 | { KEY_F6, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY }, | |
81 | { KEY_F7, KEY_PLAYPAUSE, APPLE_FLAG_FKEY }, | |
82 | { KEY_F8, KEY_NEXTSONG, APPLE_FLAG_FKEY }, | |
83 | { KEY_F9, KEY_MUTE, APPLE_FLAG_FKEY }, | |
84 | { KEY_F10, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY }, | |
85 | { KEY_F11, KEY_VOLUMEUP, APPLE_FLAG_FKEY }, | |
86 | { KEY_F12, KEY_EJECTCD, APPLE_FLAG_FKEY }, | |
87 | { KEY_UP, KEY_PAGEUP }, | |
88 | { KEY_DOWN, KEY_PAGEDOWN }, | |
89 | { KEY_LEFT, KEY_HOME }, | |
90 | { KEY_RIGHT, KEY_END }, | |
91 | { } | |
92 | }; | |
93 | ||
b2ddd54e | 94 | static const struct apple_key_translation apple_fn_keys[] = { |
8c19a515 | 95 | { KEY_BACKSPACE, KEY_DELETE }, |
437184ae | 96 | { KEY_ENTER, KEY_INSERT }, |
8c19a515 JS |
97 | { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, |
98 | { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, | |
437184ae HR |
99 | { KEY_F3, KEY_SCALE, APPLE_FLAG_FKEY }, |
100 | { KEY_F4, KEY_DASHBOARD, APPLE_FLAG_FKEY }, | |
8c19a515 JS |
101 | { KEY_F5, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY }, |
102 | { KEY_F6, KEY_KBDILLUMUP, APPLE_FLAG_FKEY }, | |
103 | { KEY_F7, KEY_PREVIOUSSONG, APPLE_FLAG_FKEY }, | |
104 | { KEY_F8, KEY_PLAYPAUSE, APPLE_FLAG_FKEY }, | |
105 | { KEY_F9, KEY_NEXTSONG, APPLE_FLAG_FKEY }, | |
106 | { KEY_F10, KEY_MUTE, APPLE_FLAG_FKEY }, | |
107 | { KEY_F11, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY }, | |
108 | { KEY_F12, KEY_VOLUMEUP, APPLE_FLAG_FKEY }, | |
109 | { KEY_UP, KEY_PAGEUP }, | |
110 | { KEY_DOWN, KEY_PAGEDOWN }, | |
111 | { KEY_LEFT, KEY_HOME }, | |
112 | { KEY_RIGHT, KEY_END }, | |
113 | { } | |
114 | }; | |
115 | ||
b2ddd54e | 116 | static const struct apple_key_translation powerbook_fn_keys[] = { |
8c19a515 JS |
117 | { KEY_BACKSPACE, KEY_DELETE }, |
118 | { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY }, | |
119 | { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY }, | |
120 | { KEY_F3, KEY_MUTE, APPLE_FLAG_FKEY }, | |
121 | { KEY_F4, KEY_VOLUMEDOWN, APPLE_FLAG_FKEY }, | |
122 | { KEY_F5, KEY_VOLUMEUP, APPLE_FLAG_FKEY }, | |
123 | { KEY_F6, KEY_NUMLOCK, APPLE_FLAG_FKEY }, | |
124 | { KEY_F7, KEY_SWITCHVIDEOMODE, APPLE_FLAG_FKEY }, | |
125 | { KEY_F8, KEY_KBDILLUMTOGGLE, APPLE_FLAG_FKEY }, | |
126 | { KEY_F9, KEY_KBDILLUMDOWN, APPLE_FLAG_FKEY }, | |
127 | { KEY_F10, KEY_KBDILLUMUP, APPLE_FLAG_FKEY }, | |
128 | { KEY_UP, KEY_PAGEUP }, | |
129 | { KEY_DOWN, KEY_PAGEDOWN }, | |
130 | { KEY_LEFT, KEY_HOME }, | |
131 | { KEY_RIGHT, KEY_END }, | |
132 | { } | |
133 | }; | |
134 | ||
b2ddd54e | 135 | static const struct apple_key_translation powerbook_numlock_keys[] = { |
8c19a515 JS |
136 | { KEY_J, KEY_KP1 }, |
137 | { KEY_K, KEY_KP2 }, | |
138 | { KEY_L, KEY_KP3 }, | |
139 | { KEY_U, KEY_KP4 }, | |
140 | { KEY_I, KEY_KP5 }, | |
141 | { KEY_O, KEY_KP6 }, | |
142 | { KEY_7, KEY_KP7 }, | |
143 | { KEY_8, KEY_KP8 }, | |
144 | { KEY_9, KEY_KP9 }, | |
145 | { KEY_M, KEY_KP0 }, | |
146 | { KEY_DOT, KEY_KPDOT }, | |
147 | { KEY_SLASH, KEY_KPPLUS }, | |
148 | { KEY_SEMICOLON, KEY_KPMINUS }, | |
149 | { KEY_P, KEY_KPASTERISK }, | |
150 | { KEY_MINUS, KEY_KPEQUAL }, | |
151 | { KEY_0, KEY_KPSLASH }, | |
152 | { KEY_F6, KEY_NUMLOCK }, | |
153 | { KEY_KPENTER, KEY_KPENTER }, | |
154 | { KEY_BACKSPACE, KEY_BACKSPACE }, | |
155 | { } | |
156 | }; | |
157 | ||
b2ddd54e | 158 | static const struct apple_key_translation apple_iso_keyboard[] = { |
8c19a515 JS |
159 | { KEY_GRAVE, KEY_102ND }, |
160 | { KEY_102ND, KEY_GRAVE }, | |
161 | { } | |
162 | }; | |
163 | ||
43c83146 NL |
164 | static const struct apple_key_translation swapped_option_cmd_keys[] = { |
165 | { KEY_LEFTALT, KEY_LEFTMETA }, | |
166 | { KEY_LEFTMETA, KEY_LEFTALT }, | |
167 | { KEY_RIGHTALT, KEY_RIGHTMETA }, | |
168 | { KEY_RIGHTMETA,KEY_RIGHTALT }, | |
169 | { } | |
170 | }; | |
171 | ||
346338ef | 172 | static const struct apple_key_translation swapped_fn_leftctrl_keys[] = { |
173 | { KEY_FN, KEY_LEFTCTRL }, | |
174 | { } | |
175 | }; | |
176 | ||
b2ddd54e PC |
177 | static const struct apple_key_translation *apple_find_translation( |
178 | const struct apple_key_translation *table, u16 from) | |
8c19a515 | 179 | { |
b2ddd54e | 180 | const struct apple_key_translation *trans; |
8c19a515 JS |
181 | |
182 | /* Look for the translation */ | |
183 | for (trans = table; trans->from; trans++) | |
184 | if (trans->from == from) | |
185 | return trans; | |
186 | ||
187 | return NULL; | |
188 | } | |
189 | ||
190 | static int hidinput_apple_event(struct hid_device *hid, struct input_dev *input, | |
191 | struct hid_usage *usage, __s32 value) | |
192 | { | |
193 | struct apple_sc *asc = hid_get_drvdata(hid); | |
a4bc6926 | 194 | const struct apple_key_translation *trans, *table; |
aec256d0 JM |
195 | bool do_translate; |
196 | u16 code = 0; | |
8c19a515 | 197 | |
346338ef | 198 | u16 fn_keycode = (swap_fn_leftctrl) ? (KEY_LEFTCTRL) : (KEY_FN); |
199 | ||
200 | if (usage->code == fn_keycode) { | |
8c19a515 | 201 | asc->fn_on = !!value; |
346338ef | 202 | input_event(input, usage->type, KEY_FN, value); |
8c19a515 JS |
203 | return 1; |
204 | } | |
205 | ||
206 | if (fnmode) { | |
a4bc6926 JK |
207 | if (hid->product >= USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI && |
208 | hid->product <= USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) | |
209 | table = macbookair_fn_keys; | |
210 | else if (hid->product < 0x21d || hid->product >= 0x300) | |
211 | table = powerbook_fn_keys; | |
212 | else | |
213 | table = apple_fn_keys; | |
214 | ||
215 | trans = apple_find_translation (table, usage->code); | |
99b9f758 | 216 | |
8c19a515 | 217 | if (trans) { |
aec256d0 JM |
218 | if (test_bit(trans->from, input->key)) |
219 | code = trans->from; | |
220 | else if (test_bit(trans->to, input->key)) | |
221 | code = trans->to; | |
222 | ||
223 | if (!code) { | |
224 | if (trans->flags & APPLE_FLAG_FKEY) { | |
225 | switch (fnmode) { | |
226 | case 1: | |
227 | do_translate = !asc->fn_on; | |
228 | break; | |
229 | case 2: | |
230 | do_translate = asc->fn_on; | |
231 | break; | |
232 | default: | |
233 | /* should never happen */ | |
234 | do_translate = false; | |
235 | } | |
236 | } else { | |
237 | do_translate = asc->fn_on; | |
238 | } | |
239 | ||
240 | code = do_translate ? trans->to : trans->from; | |
8c19a515 | 241 | } |
aec256d0 JM |
242 | |
243 | input_event(input, usage->type, code, value); | |
244 | return 1; | |
8c19a515 JS |
245 | } |
246 | ||
247 | if (asc->quirks & APPLE_NUMLOCK_EMULATION && | |
248 | (test_bit(usage->code, asc->pressed_numlock) || | |
249 | test_bit(LED_NUML, input->led))) { | |
250 | trans = apple_find_translation(powerbook_numlock_keys, | |
251 | usage->code); | |
252 | ||
253 | if (trans) { | |
254 | if (value) | |
255 | set_bit(usage->code, | |
256 | asc->pressed_numlock); | |
257 | else | |
258 | clear_bit(usage->code, | |
259 | asc->pressed_numlock); | |
260 | ||
261 | input_event(input, usage->type, trans->to, | |
262 | value); | |
263 | } | |
264 | ||
265 | return 1; | |
266 | } | |
267 | } | |
268 | ||
9f1f463a | 269 | if (iso_layout) { |
bd77a0f0 | 270 | if (hid->country == HID_COUNTRY_INTERNATIONAL_ISO) { |
54a6593d SG |
271 | trans = apple_find_translation(apple_iso_keyboard, usage->code); |
272 | if (trans) { | |
273 | input_event(input, usage->type, trans->to, value); | |
274 | return 1; | |
275 | } | |
8c19a515 JS |
276 | } |
277 | } | |
278 | ||
43c83146 NL |
279 | if (swap_opt_cmd) { |
280 | trans = apple_find_translation(swapped_option_cmd_keys, usage->code); | |
281 | if (trans) { | |
282 | input_event(input, usage->type, trans->to, value); | |
283 | return 1; | |
284 | } | |
285 | } | |
286 | ||
346338ef | 287 | if (swap_fn_leftctrl) { |
288 | trans = apple_find_translation(swapped_fn_leftctrl_keys, usage->code); | |
289 | if (trans) { | |
290 | input_event(input, usage->type, trans->to, value); | |
291 | return 1; | |
292 | } | |
293 | } | |
294 | ||
8c19a515 JS |
295 | return 0; |
296 | } | |
297 | ||
298 | static int apple_event(struct hid_device *hdev, struct hid_field *field, | |
299 | struct hid_usage *usage, __s32 value) | |
300 | { | |
301 | struct apple_sc *asc = hid_get_drvdata(hdev); | |
302 | ||
303 | if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput || | |
304 | !usage->type) | |
305 | return 0; | |
306 | ||
307 | if ((asc->quirks & APPLE_INVERT_HWHEEL) && | |
308 | usage->code == REL_HWHEEL) { | |
309 | input_event(field->hidinput->input, usage->type, usage->code, | |
310 | -value); | |
311 | return 1; | |
312 | } | |
313 | ||
314 | if ((asc->quirks & APPLE_HAS_FN) && | |
315 | hidinput_apple_event(hdev, field->hidinput->input, | |
316 | usage, value)) | |
317 | return 1; | |
318 | ||
319 | ||
320 | return 0; | |
321 | } | |
322 | ||
323 | /* | |
324 | * MacBook JIS keyboard has wrong logical maximum | |
325 | */ | |
73e4008d NK |
326 | static __u8 *apple_report_fixup(struct hid_device *hdev, __u8 *rdesc, |
327 | unsigned int *rsize) | |
8c19a515 JS |
328 | { |
329 | struct apple_sc *asc = hid_get_drvdata(hdev); | |
330 | ||
73e4008d | 331 | if ((asc->quirks & APPLE_RDESC_JIS) && *rsize >= 60 && |
8c19a515 | 332 | rdesc[53] == 0x65 && rdesc[59] == 0x65) { |
4291ee30 JP |
333 | hid_info(hdev, |
334 | "fixing up MacBook JIS keyboard report descriptor\n"); | |
8c19a515 JS |
335 | rdesc[53] = rdesc[59] = 0xe7; |
336 | } | |
73e4008d | 337 | return rdesc; |
8c19a515 JS |
338 | } |
339 | ||
340 | static void apple_setup_input(struct input_dev *input) | |
341 | { | |
b2ddd54e | 342 | const struct apple_key_translation *trans; |
8c19a515 JS |
343 | |
344 | set_bit(KEY_NUMLOCK, input->keybit); | |
345 | ||
346 | /* Enable all needed keys */ | |
347 | for (trans = apple_fn_keys; trans->from; trans++) | |
348 | set_bit(trans->to, input->keybit); | |
349 | ||
350 | for (trans = powerbook_fn_keys; trans->from; trans++) | |
351 | set_bit(trans->to, input->keybit); | |
352 | ||
353 | for (trans = powerbook_numlock_keys; trans->from; trans++) | |
354 | set_bit(trans->to, input->keybit); | |
355 | ||
356 | for (trans = apple_iso_keyboard; trans->from; trans++) | |
357 | set_bit(trans->to, input->keybit); | |
346338ef | 358 | |
359 | if (swap_fn_leftctrl) { | |
360 | for (trans = swapped_fn_leftctrl_keys; trans->from; trans++) | |
361 | set_bit(trans->to, input->keybit); | |
362 | } | |
8c19a515 JS |
363 | } |
364 | ||
365 | static int apple_input_mapping(struct hid_device *hdev, struct hid_input *hi, | |
366 | struct hid_field *field, struct hid_usage *usage, | |
367 | unsigned long **bit, int *max) | |
368 | { | |
a5d81646 HG |
369 | struct apple_sc *asc = hid_get_drvdata(hdev); |
370 | ||
ee345492 | 371 | if (usage->hid == (HID_UP_CUSTOM | 0x0003) || |
e433be92 MB |
372 | usage->hid == (HID_UP_MSVENDOR | 0x0003) || |
373 | usage->hid == (HID_UP_HPVENDOR2 | 0x0003)) { | |
8c19a515 JS |
374 | /* The fn key on Apple USB keyboards */ |
375 | set_bit(EV_REP, hi->input->evbit); | |
376 | hid_map_usage_clear(hi, usage, bit, max, EV_KEY, KEY_FN); | |
a5d81646 | 377 | asc->fn_found = true; |
8c19a515 JS |
378 | apple_setup_input(hi->input); |
379 | return 1; | |
380 | } | |
381 | ||
382 | /* we want the hid layer to go through standard path (set and ignore) */ | |
383 | return 0; | |
384 | } | |
385 | ||
386 | static int apple_input_mapped(struct hid_device *hdev, struct hid_input *hi, | |
387 | struct hid_field *field, struct hid_usage *usage, | |
388 | unsigned long **bit, int *max) | |
389 | { | |
390 | struct apple_sc *asc = hid_get_drvdata(hdev); | |
391 | ||
392 | if (asc->quirks & APPLE_MIGHTYMOUSE) { | |
393 | if (usage->hid == HID_GD_Z) | |
394 | hid_map_usage(hi, usage, bit, max, EV_REL, REL_HWHEEL); | |
395 | else if (usage->code == BTN_1) | |
396 | hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_2); | |
397 | else if (usage->code == BTN_2) | |
398 | hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_1); | |
399 | } | |
400 | ||
401 | return 0; | |
402 | } | |
403 | ||
a5d81646 HG |
404 | static int apple_input_configured(struct hid_device *hdev, |
405 | struct hid_input *hidinput) | |
406 | { | |
407 | struct apple_sc *asc = hid_get_drvdata(hdev); | |
408 | ||
409 | if ((asc->quirks & APPLE_HAS_FN) && !asc->fn_found) { | |
410 | hid_info(hdev, "Fn key not found (Apple Wireless Keyboard clone?), disabling Fn key handling\n"); | |
411 | asc->quirks = 0; | |
412 | } | |
413 | ||
414 | return 0; | |
415 | } | |
416 | ||
8c19a515 JS |
417 | static int apple_probe(struct hid_device *hdev, |
418 | const struct hid_device_id *id) | |
419 | { | |
420 | unsigned long quirks = id->driver_data; | |
421 | struct apple_sc *asc; | |
93c10132 | 422 | unsigned int connect_mask = HID_CONNECT_DEFAULT; |
8c19a515 JS |
423 | int ret; |
424 | ||
abf832bf | 425 | asc = devm_kzalloc(&hdev->dev, sizeof(*asc), GFP_KERNEL); |
8c19a515 | 426 | if (asc == NULL) { |
4291ee30 | 427 | hid_err(hdev, "can't alloc apple descriptor\n"); |
8c19a515 JS |
428 | return -ENOMEM; |
429 | } | |
430 | ||
431 | asc->quirks = quirks; | |
432 | ||
433 | hid_set_drvdata(hdev, asc); | |
434 | ||
8c19a515 JS |
435 | ret = hid_parse(hdev); |
436 | if (ret) { | |
4291ee30 | 437 | hid_err(hdev, "parse failed\n"); |
abf832bf | 438 | return ret; |
8c19a515 JS |
439 | } |
440 | ||
93c10132 JS |
441 | if (quirks & APPLE_HIDDEV) |
442 | connect_mask |= HID_CONNECT_HIDDEV_FORCE; | |
443 | if (quirks & APPLE_IGNORE_HIDINPUT) | |
444 | connect_mask &= ~HID_CONNECT_HIDINPUT; | |
445 | ||
446 | ret = hid_hw_start(hdev, connect_mask); | |
8c19a515 | 447 | if (ret) { |
4291ee30 | 448 | hid_err(hdev, "hw start failed\n"); |
abf832bf | 449 | return ret; |
8c19a515 JS |
450 | } |
451 | ||
452 | return 0; | |
8c19a515 JS |
453 | } |
454 | ||
455 | static const struct hid_device_id apple_devices[] = { | |
8c19a515 JS |
456 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE), |
457 | .driver_data = APPLE_MIGHTYMOUSE | APPLE_INVERT_HWHEEL }, | |
458 | ||
459 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI), | |
b4d8e473 | 460 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
8c19a515 | 461 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO), |
b4d8e473 | 462 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
8c19a515 | 463 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI), |
b4d8e473 | 464 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
8c19a515 | 465 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO), |
bd77a0f0 | 466 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
8c19a515 | 467 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS), |
b4d8e473 | 468 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
8c19a515 | 469 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI), |
b4d8e473 | 470 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
8c19a515 | 471 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO), |
bd77a0f0 | 472 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
8c19a515 JS |
473 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS), |
474 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | |
b4d8e473 | 475 | APPLE_RDESC_JIS }, |
8c19a515 | 476 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI), |
b4d8e473 | 477 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
8c19a515 | 478 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO), |
bd77a0f0 | 479 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
8c19a515 JS |
480 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS), |
481 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | |
b4d8e473 | 482 | APPLE_RDESC_JIS }, |
fef3f571 RF |
483 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ANSI), |
484 | .driver_data = APPLE_HAS_FN }, | |
485 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_ISO), | |
bd77a0f0 | 486 | .driver_data = APPLE_HAS_FN }, |
fef3f571 RF |
487 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_MINI_JIS), |
488 | .driver_data = APPLE_HAS_FN }, | |
8c19a515 JS |
489 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ANSI), |
490 | .driver_data = APPLE_HAS_FN }, | |
491 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_ISO), | |
bd77a0f0 | 492 | .driver_data = APPLE_HAS_FN }, |
8c19a515 JS |
493 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_JIS), |
494 | .driver_data = APPLE_HAS_FN }, | |
495 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI), | |
b4d8e473 | 496 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
8c19a515 | 497 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO), |
bd77a0f0 | 498 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
8c19a515 JS |
499 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS), |
500 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN | | |
b4d8e473 | 501 | APPLE_RDESC_JIS }, |
4a4c8799 DB |
502 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ANSI), |
503 | .driver_data = APPLE_HAS_FN }, | |
504 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO), | |
bd77a0f0 | 505 | .driver_data = APPLE_HAS_FN }, |
4c945426 BZ |
506 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_ISO), |
507 | .driver_data = APPLE_HAS_FN }, | |
4a4c8799 DB |
508 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_REVB_JIS), |
509 | .driver_data = APPLE_HAS_FN }, | |
ee8a1a0a | 510 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI), |
8c19a515 | 511 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
ee8a1a0a | 512 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO), |
bd77a0f0 | 513 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
ad734bc1 | 514 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO), |
bd77a0f0 | 515 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
0a97e1e9 AK |
516 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, |
517 | USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI), | |
518 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, | |
bd4a7ce1 HHY |
519 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, |
520 | USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_JIS), | |
521 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, | |
ee8a1a0a | 522 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS), |
8c19a515 | 523 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
b5d94275 JGGC |
524 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI), |
525 | .driver_data = APPLE_HAS_FN }, | |
ee345492 SB |
526 | { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_ANSI), |
527 | .driver_data = APPLE_HAS_FN }, | |
528 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI), | |
529 | .driver_data = APPLE_HAS_FN }, | |
530 | { HID_BLUETOOTH_DEVICE(BT_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MAGIC_KEYBOARD_NUMPAD_ANSI), | |
531 | .driver_data = APPLE_HAS_FN }, | |
8c19a515 | 532 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), |
b4d8e473 | 533 | .driver_data = APPLE_HAS_FN }, |
8c19a515 | 534 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO), |
bd77a0f0 | 535 | .driver_data = APPLE_HAS_FN }, |
8c19a515 | 536 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS), |
b4d8e473 | 537 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
8c19a515 | 538 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI), |
b4d8e473 | 539 | .driver_data = APPLE_HAS_FN }, |
8c19a515 | 540 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO), |
bd77a0f0 | 541 | .driver_data = APPLE_HAS_FN }, |
8c19a515 | 542 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS), |
b4d8e473 | 543 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, |
a96d6ef3 HR |
544 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI), |
545 | .driver_data = APPLE_HAS_FN }, | |
546 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO), | |
bd77a0f0 | 547 | .driver_data = APPLE_HAS_FN }, |
a96d6ef3 HR |
548 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS), |
549 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | |
99b9f758 EH |
550 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI), |
551 | .driver_data = APPLE_HAS_FN }, | |
552 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO), | |
bd77a0f0 | 553 | .driver_data = APPLE_HAS_FN }, |
99b9f758 EH |
554 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS), |
555 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | |
556 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI), | |
557 | .driver_data = APPLE_HAS_FN }, | |
558 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO), | |
bd77a0f0 | 559 | .driver_data = APPLE_HAS_FN }, |
99b9f758 EH |
560 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS), |
561 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | |
47340bd9 AB |
562 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI), |
563 | .driver_data = APPLE_HAS_FN }, | |
564 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO), | |
bd77a0f0 | 565 | .driver_data = APPLE_HAS_FN }, |
47340bd9 AB |
566 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS), |
567 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | |
5d922baa JD |
568 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI), |
569 | .driver_data = APPLE_HAS_FN }, | |
570 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO), | |
bd77a0f0 | 571 | .driver_data = APPLE_HAS_FN }, |
5d922baa JD |
572 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS), |
573 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | |
d762cc29 NI |
574 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI), |
575 | .driver_data = APPLE_HAS_FN }, | |
576 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO), | |
bd77a0f0 | 577 | .driver_data = APPLE_HAS_FN }, |
d762cc29 NI |
578 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS), |
579 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | |
213f9da8 GE |
580 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI), |
581 | .driver_data = APPLE_HAS_FN }, | |
582 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO), | |
bd77a0f0 | 583 | .driver_data = APPLE_HAS_FN }, |
213f9da8 GE |
584 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS), |
585 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | |
b2e6ad7d RB |
586 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI), |
587 | .driver_data = APPLE_HAS_FN }, | |
588 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO), | |
bd77a0f0 | 589 | .driver_data = APPLE_HAS_FN }, |
b2e6ad7d RB |
590 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS), |
591 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | |
8d80da90 DH |
592 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI), |
593 | .driver_data = APPLE_HAS_FN }, | |
594 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO), | |
bd77a0f0 | 595 | .driver_data = APPLE_HAS_FN }, |
8d80da90 DH |
596 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS), |
597 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | |
9d9a04ee DT |
598 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ANSI), |
599 | .driver_data = APPLE_HAS_FN }, | |
600 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_ISO), | |
bd77a0f0 | 601 | .driver_data = APPLE_HAS_FN }, |
9d9a04ee DT |
602 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING8_JIS), |
603 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | |
a4a2c545 HR |
604 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ANSI), |
605 | .driver_data = APPLE_HAS_FN }, | |
606 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_ISO), | |
bd77a0f0 | 607 | .driver_data = APPLE_HAS_FN }, |
a4a2c545 HR |
608 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING9_JIS), |
609 | .driver_data = APPLE_HAS_FN | APPLE_RDESC_JIS }, | |
23aeb61e CSW |
610 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI), |
611 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, | |
612 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO), | |
bd77a0f0 | 613 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
23aeb61e CSW |
614 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS), |
615 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, | |
8c19a515 | 616 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY), |
b4d8e473 | 617 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
8c19a515 | 618 | { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY), |
b4d8e473 | 619 | .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN }, |
8c19a515 | 620 | |
8c19a515 JS |
621 | { } |
622 | }; | |
623 | MODULE_DEVICE_TABLE(hid, apple_devices); | |
624 | ||
625 | static struct hid_driver apple_driver = { | |
626 | .name = "apple", | |
627 | .id_table = apple_devices, | |
628 | .report_fixup = apple_report_fixup, | |
629 | .probe = apple_probe, | |
8c19a515 JS |
630 | .event = apple_event, |
631 | .input_mapping = apple_input_mapping, | |
632 | .input_mapped = apple_input_mapped, | |
a5d81646 | 633 | .input_configured = apple_input_configured, |
8c19a515 | 634 | }; |
f425458e | 635 | module_hid_driver(apple_driver); |
8c19a515 | 636 | |
8c19a515 | 637 | MODULE_LICENSE("GPL"); |