hid-magicmouse.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. /*
  2. * Apple "Magic" Wireless Mouse driver
  3. *
  4. * Copyright (c) 2010 Michael Poole <mdpoole@troilus.org>
  5. * Copyright (c) 2010 Chase Douglas <chase.douglas@canonical.com>
  6. */
  7. /*
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the Free
  10. * Software Foundation; either version 2 of the License, or (at your option)
  11. * any later version.
  12. */
  13. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  14. #include <linux/device.h>
  15. #include <linux/hid.h>
  16. #include <linux/input/mt.h>
  17. #include <linux/module.h>
  18. #include <linux/slab.h>
  19. #include "hid-ids.h"
  20. static bool emulate_3button = true;
  21. module_param(emulate_3button, bool, 0644);
  22. MODULE_PARM_DESC(emulate_3button, "Emulate a middle button");
  23. static int middle_button_start = -350;
  24. static int middle_button_stop = +350;
  25. static bool emulate_scroll_wheel = true;
  26. module_param(emulate_scroll_wheel, bool, 0644);
  27. MODULE_PARM_DESC(emulate_scroll_wheel, "Emulate a scroll wheel");
  28. static unsigned int scroll_speed = 32;
  29. static int param_set_scroll_speed(const char *val, struct kernel_param *kp) {
  30. unsigned long speed;
  31. if (!val || kstrtoul(val, 0, &speed) || speed > 63)
  32. return -EINVAL;
  33. scroll_speed = speed;
  34. return 0;
  35. }
  36. module_param_call(scroll_speed, param_set_scroll_speed, param_get_uint, &scroll_speed, 0644);
  37. MODULE_PARM_DESC(scroll_speed, "Scroll speed, value from 0 (slow) to 63 (fast)");
  38. static bool scroll_acceleration = false;
  39. module_param(scroll_acceleration, bool, 0644);
  40. MODULE_PARM_DESC(scroll_acceleration, "Accelerate sequential scroll events");
  41. static bool report_undeciphered;
  42. module_param(report_undeciphered, bool, 0644);
  43. MODULE_PARM_DESC(report_undeciphered, "Report undeciphered multi-touch state field using a MSC_RAW event");
  44. #define TRACKPAD_REPORT_ID 0x28
  45. #define MOUSE_REPORT_ID 0x29
  46. #define DOUBLE_REPORT_ID 0xf7
  47. /* These definitions are not precise, but they're close enough. (Bits
  48. * 0x03 seem to indicate the aspect ratio of the touch, bits 0x70 seem
  49. * to be some kind of bit mask -- 0x20 may be a near-field reading,
  50. * and 0x40 is actual contact, and 0x10 may be a start/stop or change
  51. * indication.)
  52. */
  53. #define TOUCH_STATE_MASK 0xf0
  54. #define TOUCH_STATE_NONE 0x00
  55. #define TOUCH_STATE_START 0x30
  56. #define TOUCH_STATE_DRAG 0x40
  57. #define SCROLL_ACCEL_DEFAULT 7
  58. /* Touch surface information. Dimension is in hundredths of a mm, min and max
  59. * are in units. */
  60. #define MOUSE_DIMENSION_X (float)9056
  61. #define MOUSE_MIN_X -1100
  62. #define MOUSE_MAX_X 1258
  63. #define MOUSE_RES_X ((MOUSE_MAX_X - MOUSE_MIN_X) / (MOUSE_DIMENSION_X / 100))
  64. #define MOUSE_DIMENSION_Y (float)5152
  65. #define MOUSE_MIN_Y -1589
  66. #define MOUSE_MAX_Y 2047
  67. #define MOUSE_RES_Y ((MOUSE_MAX_Y - MOUSE_MIN_Y) / (MOUSE_DIMENSION_Y / 100))
  68. #define TRACKPAD_DIMENSION_X (float)13000
  69. #define TRACKPAD_MIN_X -2909
  70. #define TRACKPAD_MAX_X 3167
  71. #define TRACKPAD_RES_X \
  72. ((TRACKPAD_MAX_X - TRACKPAD_MIN_X) / (TRACKPAD_DIMENSION_X / 100))
  73. #define TRACKPAD_DIMENSION_Y (float)11000
  74. #define TRACKPAD_MIN_Y -2456
  75. #define TRACKPAD_MAX_Y 2565
  76. #define TRACKPAD_RES_Y \
  77. ((TRACKPAD_MAX_Y - TRACKPAD_MIN_Y) / (TRACKPAD_DIMENSION_Y / 100))
  78. /**
  79. * struct magicmouse_sc - Tracks Magic Mouse-specific data.
  80. * @input: Input device through which we report events.
  81. * @quirks: Currently unused.
  82. * @ntouches: Number of touches in most recent touch report.
  83. * @scroll_accel: Number of consecutive scroll motions.
  84. * @scroll_jiffies: Time of last scroll motion.
  85. * @touches: Most recent data for a touch, indexed by tracking ID.
  86. * @tracking_ids: Mapping of current touch input data to @touches.
  87. */
  88. struct magicmouse_sc {
  89. struct input_dev *input;
  90. unsigned long quirks;
  91. int ntouches;
  92. int scroll_accel;
  93. unsigned long scroll_jiffies;
  94. struct {
  95. short x;
  96. short y;
  97. short scroll_x;
  98. short scroll_y;
  99. u8 size;
  100. } touches[16];
  101. int tracking_ids[16];
  102. };
  103. static int magicmouse_firm_touch(struct magicmouse_sc *msc)
  104. {
  105. int touch = -1;
  106. int ii;
  107. /* If there is only one "firm" touch, set touch to its
  108. * tracking ID.
  109. */
  110. for (ii = 0; ii < msc->ntouches; ii++) {
  111. int idx = msc->tracking_ids[ii];
  112. if (msc->touches[idx].size < 8) {
  113. /* Ignore this touch. */
  114. } else if (touch >= 0) {
  115. touch = -1;
  116. break;
  117. } else {
  118. touch = idx;
  119. }
  120. }
  121. return touch;
  122. }
  123. static void magicmouse_emit_buttons(struct magicmouse_sc *msc, int state)
  124. {
  125. int last_state = test_bit(BTN_LEFT, msc->input->key) << 0 |
  126. test_bit(BTN_RIGHT, msc->input->key) << 1 |
  127. test_bit(BTN_MIDDLE, msc->input->key) << 2;
  128. if (emulate_3button) {
  129. int id;
  130. /* If some button was pressed before, keep it held
  131. * down. Otherwise, if there's exactly one firm
  132. * touch, use that to override the mouse's guess.
  133. */
  134. if (state == 0) {
  135. /* The button was released. */
  136. } else if (last_state != 0) {
  137. state = last_state;
  138. } else if ((id = magicmouse_firm_touch(msc)) >= 0) {
  139. int x = msc->touches[id].x;
  140. if (x < middle_button_start)
  141. state = 1;
  142. else if (x > middle_button_stop)
  143. state = 2;
  144. else
  145. state = 4;
  146. } /* else: we keep the mouse's guess */
  147. input_report_key(msc->input, BTN_MIDDLE, state & 4);
  148. }
  149. input_report_key(msc->input, BTN_LEFT, state & 1);
  150. input_report_key(msc->input, BTN_RIGHT, state & 2);
  151. if (state != last_state)
  152. msc->scroll_accel = SCROLL_ACCEL_DEFAULT;
  153. }
  154. static void magicmouse_emit_touch(struct magicmouse_sc *msc, int raw_id, u8 *tdata)
  155. {
  156. struct input_dev *input = msc->input;
  157. int id, x, y, size, orientation, touch_major, touch_minor, state, down;
  158. if (input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE) {
  159. id = (tdata[6] << 2 | tdata[5] >> 6) & 0xf;
  160. x = (tdata[1] << 28 | tdata[0] << 20) >> 20;
  161. y = -((tdata[2] << 24 | tdata[1] << 16) >> 20);
  162. size = tdata[5] & 0x3f;
  163. orientation = (tdata[6] >> 2) - 32;
  164. touch_major = tdata[3];
  165. touch_minor = tdata[4];
  166. state = tdata[7] & TOUCH_STATE_MASK;
  167. down = state != TOUCH_STATE_NONE;
  168. } else { /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */
  169. id = (tdata[7] << 2 | tdata[6] >> 6) & 0xf;
  170. x = (tdata[1] << 27 | tdata[0] << 19) >> 19;
  171. y = -((tdata[3] << 30 | tdata[2] << 22 | tdata[1] << 14) >> 19);
  172. size = tdata[6] & 0x3f;
  173. orientation = (tdata[7] >> 2) - 32;
  174. touch_major = tdata[4];
  175. touch_minor = tdata[5];
  176. state = tdata[8] & TOUCH_STATE_MASK;
  177. down = state != TOUCH_STATE_NONE;
  178. }
  179. /* Store tracking ID and other fields. */
  180. msc->tracking_ids[raw_id] = id;
  181. msc->touches[id].x = x;
  182. msc->touches[id].y = y;
  183. msc->touches[id].size = size;
  184. /* If requested, emulate a scroll wheel by detecting small
  185. * vertical touch motions.
  186. */
  187. if (emulate_scroll_wheel) {
  188. unsigned long now = jiffies;
  189. int step_x = msc->touches[id].scroll_x - x;
  190. int step_y = msc->touches[id].scroll_y - y;
  191. /* Calculate and apply the scroll motion. */
  192. switch (state) {
  193. case TOUCH_STATE_START:
  194. msc->touches[id].scroll_x = x;
  195. msc->touches[id].scroll_y = y;
  196. /* Reset acceleration after half a second. */
  197. if (scroll_acceleration && time_before(now,
  198. msc->scroll_jiffies + HZ / 2))
  199. msc->scroll_accel = max_t(int,
  200. msc->scroll_accel - 1, 1);
  201. else
  202. msc->scroll_accel = SCROLL_ACCEL_DEFAULT;
  203. break;
  204. case TOUCH_STATE_DRAG:
  205. step_x /= (64 - (int)scroll_speed) * msc->scroll_accel;
  206. if (step_x != 0) {
  207. msc->touches[id].scroll_x -= step_x *
  208. (64 - scroll_speed) * msc->scroll_accel;
  209. msc->scroll_jiffies = now;
  210. input_report_rel(input, REL_HWHEEL, -step_x);
  211. }
  212. step_y /= (64 - (int)scroll_speed) * msc->scroll_accel;
  213. if (step_y != 0) {
  214. msc->touches[id].scroll_y -= step_y *
  215. (64 - scroll_speed) * msc->scroll_accel;
  216. msc->scroll_jiffies = now;
  217. input_report_rel(input, REL_WHEEL, step_y);
  218. }
  219. break;
  220. }
  221. }
  222. if (down)
  223. msc->ntouches++;
  224. input_mt_slot(input, id);
  225. input_mt_report_slot_state(input, MT_TOOL_FINGER, down);
  226. /* Generate the input events for this touch. */
  227. if (down) {
  228. input_report_abs(input, ABS_MT_TOUCH_MAJOR, touch_major << 2);
  229. input_report_abs(input, ABS_MT_TOUCH_MINOR, touch_minor << 2);
  230. input_report_abs(input, ABS_MT_ORIENTATION, -orientation);
  231. input_report_abs(input, ABS_MT_POSITION_X, x);
  232. input_report_abs(input, ABS_MT_POSITION_Y, y);
  233. if (report_undeciphered) {
  234. if (input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE)
  235. input_event(input, EV_MSC, MSC_RAW, tdata[7]);
  236. else /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */
  237. input_event(input, EV_MSC, MSC_RAW, tdata[8]);
  238. }
  239. }
  240. }
  241. static int magicmouse_raw_event(struct hid_device *hdev,
  242. struct hid_report *report, u8 *data, int size)
  243. {
  244. struct magicmouse_sc *msc = hid_get_drvdata(hdev);
  245. struct input_dev *input = msc->input;
  246. int x = 0, y = 0, ii, clicks = 0, npoints;
  247. switch (data[0]) {
  248. case TRACKPAD_REPORT_ID:
  249. /* Expect four bytes of prefix, and N*9 bytes of touch data. */
  250. if (size < 4 || ((size - 4) % 9) != 0)
  251. return 0;
  252. npoints = (size - 4) / 9;
  253. msc->ntouches = 0;
  254. for (ii = 0; ii < npoints; ii++)
  255. magicmouse_emit_touch(msc, ii, data + ii * 9 + 4);
  256. clicks = data[1];
  257. /* The following bits provide a device specific timestamp. They
  258. * are unused here.
  259. *
  260. * ts = data[1] >> 6 | data[2] << 2 | data[3] << 10;
  261. */
  262. break;
  263. case MOUSE_REPORT_ID:
  264. /* Expect six bytes of prefix, and N*8 bytes of touch data. */
  265. if (size < 6 || ((size - 6) % 8) != 0)
  266. return 0;
  267. npoints = (size - 6) / 8;
  268. msc->ntouches = 0;
  269. for (ii = 0; ii < npoints; ii++)
  270. magicmouse_emit_touch(msc, ii, data + ii * 8 + 6);
  271. /* When emulating three-button mode, it is important
  272. * to have the current touch information before
  273. * generating a click event.
  274. */
  275. x = (int)(((data[3] & 0x0c) << 28) | (data[1] << 22)) >> 22;
  276. y = (int)(((data[3] & 0x30) << 26) | (data[2] << 22)) >> 22;
  277. clicks = data[3];
  278. /* The following bits provide a device specific timestamp. They
  279. * are unused here.
  280. *
  281. * ts = data[3] >> 6 | data[4] << 2 | data[5] << 10;
  282. */
  283. break;
  284. case DOUBLE_REPORT_ID:
  285. /* Sometimes the trackpad sends two touch reports in one
  286. * packet.
  287. */
  288. magicmouse_raw_event(hdev, report, data + 2, data[1]);
  289. magicmouse_raw_event(hdev, report, data + 2 + data[1],
  290. size - 2 - data[1]);
  291. break;
  292. default:
  293. return 0;
  294. }
  295. if (input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE) {
  296. magicmouse_emit_buttons(msc, clicks & 3);
  297. input_report_rel(input, REL_X, x);
  298. input_report_rel(input, REL_Y, y);
  299. } else { /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */
  300. input_report_key(input, BTN_MOUSE, clicks & 1);
  301. input_mt_report_pointer_emulation(input, true);
  302. }
  303. input_sync(input);
  304. return 1;
  305. }
  306. static int magicmouse_setup_input(struct input_dev *input, struct hid_device *hdev)
  307. {
  308. int error;
  309. __set_bit(EV_KEY, input->evbit);
  310. if (input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE) {
  311. __set_bit(BTN_LEFT, input->keybit);
  312. __set_bit(BTN_RIGHT, input->keybit);
  313. if (emulate_3button)
  314. __set_bit(BTN_MIDDLE, input->keybit);
  315. __set_bit(EV_REL, input->evbit);
  316. __set_bit(REL_X, input->relbit);
  317. __set_bit(REL_Y, input->relbit);
  318. if (emulate_scroll_wheel) {
  319. __set_bit(REL_WHEEL, input->relbit);
  320. __set_bit(REL_HWHEEL, input->relbit);
  321. }
  322. } else { /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */
  323. /* input->keybit is initialized with incorrect button info
  324. * for Magic Trackpad. There really is only one physical
  325. * button (BTN_LEFT == BTN_MOUSE). Make sure we don't
  326. * advertise buttons that don't exist...
  327. */
  328. __clear_bit(BTN_RIGHT, input->keybit);
  329. __clear_bit(BTN_MIDDLE, input->keybit);
  330. __set_bit(BTN_MOUSE, input->keybit);
  331. __set_bit(BTN_TOOL_FINGER, input->keybit);
  332. __set_bit(BTN_TOOL_DOUBLETAP, input->keybit);
  333. __set_bit(BTN_TOOL_TRIPLETAP, input->keybit);
  334. __set_bit(BTN_TOOL_QUADTAP, input->keybit);
  335. __set_bit(BTN_TOOL_QUINTTAP, input->keybit);
  336. __set_bit(BTN_TOUCH, input->keybit);
  337. __set_bit(INPUT_PROP_POINTER, input->propbit);
  338. __set_bit(INPUT_PROP_BUTTONPAD, input->propbit);
  339. }
  340. __set_bit(EV_ABS, input->evbit);
  341. error = input_mt_init_slots(input, 16, 0);
  342. if (error)
  343. return error;
  344. input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, 255 << 2,
  345. 4, 0);
  346. input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0, 255 << 2,
  347. 4, 0);
  348. input_set_abs_params(input, ABS_MT_ORIENTATION, -31, 32, 1, 0);
  349. /* Note: Touch Y position from the device is inverted relative
  350. * to how pointer motion is reported (and relative to how USB
  351. * HID recommends the coordinates work). This driver keeps
  352. * the origin at the same position, and just uses the additive
  353. * inverse of the reported Y.
  354. */
  355. if (input->id.product == USB_DEVICE_ID_APPLE_MAGICMOUSE) {
  356. input_set_abs_params(input, ABS_MT_POSITION_X,
  357. MOUSE_MIN_X, MOUSE_MAX_X, 4, 0);
  358. input_set_abs_params(input, ABS_MT_POSITION_Y,
  359. MOUSE_MIN_Y, MOUSE_MAX_Y, 4, 0);
  360. input_abs_set_res(input, ABS_MT_POSITION_X,
  361. MOUSE_RES_X);
  362. input_abs_set_res(input, ABS_MT_POSITION_Y,
  363. MOUSE_RES_Y);
  364. } else { /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */
  365. input_set_abs_params(input, ABS_X, TRACKPAD_MIN_X,
  366. TRACKPAD_MAX_X, 4, 0);
  367. input_set_abs_params(input, ABS_Y, TRACKPAD_MIN_Y,
  368. TRACKPAD_MAX_Y, 4, 0);
  369. input_set_abs_params(input, ABS_MT_POSITION_X,
  370. TRACKPAD_MIN_X, TRACKPAD_MAX_X, 4, 0);
  371. input_set_abs_params(input, ABS_MT_POSITION_Y,
  372. TRACKPAD_MIN_Y, TRACKPAD_MAX_Y, 4, 0);
  373. input_abs_set_res(input, ABS_X, TRACKPAD_RES_X);
  374. input_abs_set_res(input, ABS_Y, TRACKPAD_RES_Y);
  375. input_abs_set_res(input, ABS_MT_POSITION_X,
  376. TRACKPAD_RES_X);
  377. input_abs_set_res(input, ABS_MT_POSITION_Y,
  378. TRACKPAD_RES_Y);
  379. }
  380. input_set_events_per_packet(input, 60);
  381. if (report_undeciphered) {
  382. __set_bit(EV_MSC, input->evbit);
  383. __set_bit(MSC_RAW, input->mscbit);
  384. }
  385. return 0;
  386. }
  387. static int magicmouse_input_mapping(struct hid_device *hdev,
  388. struct hid_input *hi, struct hid_field *field,
  389. struct hid_usage *usage, unsigned long **bit, int *max)
  390. {
  391. struct magicmouse_sc *msc = hid_get_drvdata(hdev);
  392. if (!msc->input)
  393. msc->input = hi->input;
  394. /* Magic Trackpad does not give relative data after switching to MT */
  395. if (hi->input->id.product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD &&
  396. field->flags & HID_MAIN_ITEM_RELATIVE)
  397. return -1;
  398. return 0;
  399. }
  400. static void magicmouse_input_configured(struct hid_device *hdev,
  401. struct hid_input *hi)
  402. {
  403. struct magicmouse_sc *msc = hid_get_drvdata(hdev);
  404. int ret = magicmouse_setup_input(msc->input, hdev);
  405. if (ret) {
  406. hid_err(hdev, "magicmouse setup input failed (%d)\n", ret);
  407. /* clean msc->input to notify probe() of the failure */
  408. msc->input = NULL;
  409. }
  410. }
  411. static int magicmouse_probe(struct hid_device *hdev,
  412. const struct hid_device_id *id)
  413. {
  414. __u8 feature[] = { 0xd7, 0x01 };
  415. struct magicmouse_sc *msc;
  416. struct hid_report *report;
  417. int ret;
  418. msc = devm_kzalloc(&hdev->dev, sizeof(*msc), GFP_KERNEL);
  419. if (msc == NULL) {
  420. hid_err(hdev, "can't alloc magicmouse descriptor\n");
  421. return -ENOMEM;
  422. }
  423. msc->scroll_accel = SCROLL_ACCEL_DEFAULT;
  424. msc->quirks = id->driver_data;
  425. hid_set_drvdata(hdev, msc);
  426. ret = hid_parse(hdev);
  427. if (ret) {
  428. hid_err(hdev, "magicmouse hid parse failed\n");
  429. return ret;
  430. }
  431. ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
  432. if (ret) {
  433. hid_err(hdev, "magicmouse hw start failed\n");
  434. return ret;
  435. }
  436. if (!msc->input) {
  437. hid_err(hdev, "magicmouse input not registered\n");
  438. ret = -ENOMEM;
  439. goto err_stop_hw;
  440. }
  441. if (id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE)
  442. report = hid_register_report(hdev, HID_INPUT_REPORT,
  443. MOUSE_REPORT_ID);
  444. else { /* USB_DEVICE_ID_APPLE_MAGICTRACKPAD */
  445. report = hid_register_report(hdev, HID_INPUT_REPORT,
  446. TRACKPAD_REPORT_ID);
  447. report = hid_register_report(hdev, HID_INPUT_REPORT,
  448. DOUBLE_REPORT_ID);
  449. }
  450. if (!report) {
  451. hid_err(hdev, "unable to register touch report\n");
  452. ret = -ENOMEM;
  453. goto err_stop_hw;
  454. }
  455. report->size = 6;
  456. /*
  457. * Some devices repond with 'invalid report id' when feature
  458. * report switching it into multitouch mode is sent to it.
  459. *
  460. * This results in -EIO from the _raw low-level transport callback,
  461. * but there seems to be no other way of switching the mode.
  462. * Thus the super-ugly hacky success check below.
  463. */
  464. ret = hdev->hid_output_raw_report(hdev, feature, sizeof(feature),
  465. HID_FEATURE_REPORT);
  466. if (ret != -EIO && ret != sizeof(feature)) {
  467. hid_err(hdev, "unable to request touch data (%d)\n", ret);
  468. goto err_stop_hw;
  469. }
  470. return 0;
  471. err_stop_hw:
  472. hid_hw_stop(hdev);
  473. return ret;
  474. }
  475. static const struct hid_device_id magic_mice[] = {
  476. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
  477. USB_DEVICE_ID_APPLE_MAGICMOUSE), .driver_data = 0 },
  478. { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_APPLE,
  479. USB_DEVICE_ID_APPLE_MAGICTRACKPAD), .driver_data = 0 },
  480. { }
  481. };
  482. MODULE_DEVICE_TABLE(hid, magic_mice);
  483. static struct hid_driver magicmouse_driver = {
  484. .name = "magicmouse",
  485. .id_table = magic_mice,
  486. .probe = magicmouse_probe,
  487. .raw_event = magicmouse_raw_event,
  488. .input_mapping = magicmouse_input_mapping,
  489. .input_configured = magicmouse_input_configured,
  490. };
  491. module_hid_driver(magicmouse_driver);
  492. MODULE_LICENSE("GPL");