xpad.c 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059
  1. /*
  2. * X-Box gamepad driver
  3. *
  4. * Copyright (c) 2002 Marko Friedemann <mfr@bmx-chemnitz.de>
  5. * 2004 Oliver Schwartz <Oliver.Schwartz@gmx.de>,
  6. * Steven Toth <steve@toth.demon.co.uk>,
  7. * Franz Lehner <franz@caos.at>,
  8. * Ivan Hawkes <blackhawk@ivanhawkes.com>
  9. * 2005 Dominic Cerquetti <binary1230@yahoo.com>
  10. * 2006 Adam Buchbinder <adam.buchbinder@gmail.com>
  11. * 2007 Jan Kratochvil <honza@jikos.cz>
  12. * 2010 Christoph Fritz <chf.fritz@googlemail.com>
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of
  17. * the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  27. *
  28. *
  29. * This driver is based on:
  30. * - information from http://euc.jp/periphs/xbox-controller.ja.html
  31. * - the iForce driver drivers/char/joystick/iforce.c
  32. * - the skeleton-driver drivers/usb/usb-skeleton.c
  33. * - Xbox 360 information http://www.free60.org/wiki/Gamepad
  34. *
  35. * Thanks to:
  36. * - ITO Takayuki for providing essential xpad information on his website
  37. * - Vojtech Pavlik - iforce driver / input subsystem
  38. * - Greg Kroah-Hartman - usb-skeleton driver
  39. * - XBOX Linux project - extra USB id's
  40. *
  41. * TODO:
  42. * - fine tune axes (especially trigger axes)
  43. * - fix "analog" buttons (reported as digital now)
  44. * - get rumble working
  45. * - need USB IDs for other dance pads
  46. *
  47. * History:
  48. *
  49. * 2002-06-27 - 0.0.1 : first version, just said "XBOX HID controller"
  50. *
  51. * 2002-07-02 - 0.0.2 : basic working version
  52. * - all axes and 9 of the 10 buttons work (german InterAct device)
  53. * - the black button does not work
  54. *
  55. * 2002-07-14 - 0.0.3 : rework by Vojtech Pavlik
  56. * - indentation fixes
  57. * - usb + input init sequence fixes
  58. *
  59. * 2002-07-16 - 0.0.4 : minor changes, merge with Vojtech's v0.0.3
  60. * - verified the lack of HID and report descriptors
  61. * - verified that ALL buttons WORK
  62. * - fixed d-pad to axes mapping
  63. *
  64. * 2002-07-17 - 0.0.5 : simplified d-pad handling
  65. *
  66. * 2004-10-02 - 0.0.6 : DDR pad support
  67. * - borrowed from the XBOX linux kernel
  68. * - USB id's for commonly used dance pads are present
  69. * - dance pads will map D-PAD to buttons, not axes
  70. * - pass the module paramater 'dpad_to_buttons' to force
  71. * the D-PAD to map to buttons if your pad is not detected
  72. *
  73. * Later changes can be tracked in SCM.
  74. */
  75. #include <linux/kernel.h>
  76. #include <linux/init.h>
  77. #include <linux/slab.h>
  78. #include <linux/stat.h>
  79. #include <linux/module.h>
  80. #include <linux/usb/input.h>
  81. #define DRIVER_AUTHOR "Marko Friedemann <mfr@bmx-chemnitz.de>"
  82. #define DRIVER_DESC "X-Box pad driver"
  83. #define XPAD_PKT_LEN 32
  84. /* xbox d-pads should map to buttons, as is required for DDR pads
  85. but we map them to axes when possible to simplify things */
  86. #define MAP_DPAD_TO_BUTTONS (1 << 0)
  87. #define MAP_TRIGGERS_TO_BUTTONS (1 << 1)
  88. #define MAP_STICKS_TO_NULL (1 << 2)
  89. #define DANCEPAD_MAP_CONFIG (MAP_DPAD_TO_BUTTONS | \
  90. MAP_TRIGGERS_TO_BUTTONS | MAP_STICKS_TO_NULL)
  91. #define XTYPE_XBOX 0
  92. #define XTYPE_XBOX360 1
  93. #define XTYPE_XBOX360W 2
  94. #define XTYPE_UNKNOWN 3
  95. static bool dpad_to_buttons;
  96. module_param(dpad_to_buttons, bool, S_IRUGO);
  97. MODULE_PARM_DESC(dpad_to_buttons, "Map D-PAD to buttons rather than axes for unknown pads");
  98. static bool triggers_to_buttons;
  99. module_param(triggers_to_buttons, bool, S_IRUGO);
  100. MODULE_PARM_DESC(triggers_to_buttons, "Map triggers to buttons rather than axes for unknown pads");
  101. static bool sticks_to_null;
  102. module_param(sticks_to_null, bool, S_IRUGO);
  103. MODULE_PARM_DESC(sticks_to_null, "Do not map sticks at all for unknown pads");
  104. static const struct xpad_device {
  105. u16 idVendor;
  106. u16 idProduct;
  107. char *name;
  108. u8 mapping;
  109. u8 xtype;
  110. } xpad_device[] = {
  111. { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", 0, XTYPE_XBOX },
  112. { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", 0, XTYPE_XBOX },
  113. { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX },
  114. { 0x045e, 0x0287, "Microsoft Xbox Controller S", 0, XTYPE_XBOX },
  115. { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W },
  116. { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", DANCEPAD_MAP_CONFIG, XTYPE_XBOX },
  117. { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
  118. { 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 },
  119. { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX },
  120. { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", 0, XTYPE_XBOX },
  121. { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", 0, XTYPE_XBOX },
  122. { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", 0, XTYPE_XBOX },
  123. { 0x0738, 0x4516, "Mad Catz Control Pad", 0, XTYPE_XBOX },
  124. { 0x0738, 0x4522, "Mad Catz LumiCON", 0, XTYPE_XBOX },
  125. { 0x0738, 0x4526, "Mad Catz Control Pad Pro", 0, XTYPE_XBOX },
  126. { 0x0738, 0x4536, "Mad Catz MicroCON", 0, XTYPE_XBOX },
  127. { 0x0738, 0x4540, "Mad Catz Beat Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
  128. { 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller", 0, XTYPE_XBOX },
  129. { 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
  130. { 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
  131. { 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
  132. { 0x0c12, 0x8802, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
  133. { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", 0, XTYPE_XBOX },
  134. { 0x0c12, 0x8810, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
  135. { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", 0, XTYPE_XBOX },
  136. { 0x0e4c, 0x1097, "Radica Gamester Controller", 0, XTYPE_XBOX },
  137. { 0x0e4c, 0x2390, "Radica Games Jtech Controller", 0, XTYPE_XBOX },
  138. { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", 0, XTYPE_XBOX },
  139. { 0x0e6f, 0x0005, "Eclipse wireless Controller", 0, XTYPE_XBOX },
  140. { 0x0e6f, 0x0006, "Edge wireless Controller", 0, XTYPE_XBOX },
  141. { 0x0e6f, 0x0006, "Pelican 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
  142. { 0x0e6f, 0x0201, "Pelican PL-3601 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
  143. { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", 0, XTYPE_XBOX },
  144. { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX },
  145. { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX },
  146. { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", 0, XTYPE_XBOX },
  147. { 0x12ab, 0x8809, "Xbox DDR dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
  148. { 0x12ab, 0x0004, "Honey Bee Xbox360 dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
  149. { 0x0e6f, 0x0105, "HSM3 Xbox360 dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
  150. { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", 0, XTYPE_XBOX360 },
  151. { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX },
  152. { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 },
  153. { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 },
  154. { 0x1bad, 0x0002, "Harmonix Rock Band Guitar", 0, XTYPE_XBOX360 },
  155. { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 },
  156. { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
  157. { 0x0f0d, 0x000d, "Hori Fighting Stick EX2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
  158. { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX },
  159. { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
  160. };
  161. /* buttons shared with xbox and xbox360 */
  162. static const signed short xpad_common_btn[] = {
  163. BTN_A, BTN_B, BTN_X, BTN_Y, /* "analog" buttons */
  164. BTN_START, BTN_SELECT, BTN_THUMBL, BTN_THUMBR, /* start/back/sticks */
  165. -1 /* terminating entry */
  166. };
  167. /* original xbox controllers only */
  168. static const signed short xpad_btn[] = {
  169. BTN_C, BTN_Z, /* "analog" buttons */
  170. -1 /* terminating entry */
  171. };
  172. /* used when dpad is mapped to buttons */
  173. static const signed short xpad_btn_pad[] = {
  174. BTN_TRIGGER_HAPPY1, BTN_TRIGGER_HAPPY2, /* d-pad left, right */
  175. BTN_TRIGGER_HAPPY3, BTN_TRIGGER_HAPPY4, /* d-pad up, down */
  176. -1 /* terminating entry */
  177. };
  178. /* used when triggers are mapped to buttons */
  179. static const signed short xpad_btn_triggers[] = {
  180. BTN_TL2, BTN_TR2, /* triggers left/right */
  181. -1
  182. };
  183. static const signed short xpad360_btn[] = { /* buttons for x360 controller */
  184. BTN_TL, BTN_TR, /* Button LB/RB */
  185. BTN_MODE, /* The big X button */
  186. -1
  187. };
  188. static const signed short xpad_abs[] = {
  189. ABS_X, ABS_Y, /* left stick */
  190. ABS_RX, ABS_RY, /* right stick */
  191. -1 /* terminating entry */
  192. };
  193. /* used when dpad is mapped to axes */
  194. static const signed short xpad_abs_pad[] = {
  195. ABS_HAT0X, ABS_HAT0Y, /* d-pad axes */
  196. -1 /* terminating entry */
  197. };
  198. /* used when triggers are mapped to axes */
  199. static const signed short xpad_abs_triggers[] = {
  200. ABS_Z, ABS_RZ, /* triggers left/right */
  201. -1
  202. };
  203. /* Xbox 360 has a vendor-specific class, so we cannot match it with only
  204. * USB_INTERFACE_INFO (also specifically refused by USB subsystem), so we
  205. * match against vendor id as well. Wired Xbox 360 devices have protocol 1,
  206. * wireless controllers have protocol 129. */
  207. #define XPAD_XBOX360_VENDOR_PROTOCOL(vend,pr) \
  208. .match_flags = USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_INT_INFO, \
  209. .idVendor = (vend), \
  210. .bInterfaceClass = USB_CLASS_VENDOR_SPEC, \
  211. .bInterfaceSubClass = 93, \
  212. .bInterfaceProtocol = (pr)
  213. #define XPAD_XBOX360_VENDOR(vend) \
  214. { XPAD_XBOX360_VENDOR_PROTOCOL(vend,1) }, \
  215. { XPAD_XBOX360_VENDOR_PROTOCOL(vend,129) }
  216. static struct usb_device_id xpad_table [] = {
  217. { USB_INTERFACE_INFO('X', 'B', 0) }, /* X-Box USB-IF not approved class */
  218. XPAD_XBOX360_VENDOR(0x045e), /* Microsoft X-Box 360 controllers */
  219. XPAD_XBOX360_VENDOR(0x046d), /* Logitech X-Box 360 style controllers */
  220. XPAD_XBOX360_VENDOR(0x0738), /* Mad Catz X-Box 360 controllers */
  221. XPAD_XBOX360_VENDOR(0x0e6f), /* 0x0e6f X-Box 360 controllers */
  222. XPAD_XBOX360_VENDOR(0x12ab), /* X-Box 360 dance pads */
  223. XPAD_XBOX360_VENDOR(0x1430), /* RedOctane X-Box 360 controllers */
  224. XPAD_XBOX360_VENDOR(0x146b), /* BigBen Interactive Controllers */
  225. XPAD_XBOX360_VENDOR(0x1bad), /* Harminix Rock Band Guitar and Drums */
  226. XPAD_XBOX360_VENDOR(0x0f0d), /* Hori Controllers */
  227. { }
  228. };
  229. MODULE_DEVICE_TABLE (usb, xpad_table);
  230. struct usb_xpad {
  231. struct input_dev *dev; /* input device interface */
  232. struct usb_device *udev; /* usb device */
  233. int pad_present;
  234. struct urb *irq_in; /* urb for interrupt in report */
  235. unsigned char *idata; /* input data */
  236. dma_addr_t idata_dma;
  237. struct urb *bulk_out;
  238. unsigned char *bdata;
  239. #if defined(CONFIG_JOYSTICK_XPAD_FF) || defined(CONFIG_JOYSTICK_XPAD_LEDS)
  240. struct urb *irq_out; /* urb for interrupt out report */
  241. unsigned char *odata; /* output data */
  242. dma_addr_t odata_dma;
  243. struct mutex odata_mutex;
  244. #endif
  245. #if defined(CONFIG_JOYSTICK_XPAD_LEDS)
  246. struct xpad_led *led;
  247. #endif
  248. char phys[64]; /* physical device path */
  249. int mapping; /* map d-pad to buttons or to axes */
  250. int xtype; /* type of xbox device */
  251. };
  252. /*
  253. * xpad_process_packet
  254. *
  255. * Completes a request by converting the data into events for the
  256. * input subsystem.
  257. *
  258. * The used report descriptor was taken from ITO Takayukis website:
  259. * http://euc.jp/periphs/xbox-controller.ja.html
  260. */
  261. static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
  262. {
  263. struct input_dev *dev = xpad->dev;
  264. if (!(xpad->mapping & MAP_STICKS_TO_NULL)) {
  265. /* left stick */
  266. input_report_abs(dev, ABS_X,
  267. (__s16) le16_to_cpup((__le16 *)(data + 12)));
  268. input_report_abs(dev, ABS_Y,
  269. ~(__s16) le16_to_cpup((__le16 *)(data + 14)));
  270. /* right stick */
  271. input_report_abs(dev, ABS_RX,
  272. (__s16) le16_to_cpup((__le16 *)(data + 16)));
  273. input_report_abs(dev, ABS_RY,
  274. ~(__s16) le16_to_cpup((__le16 *)(data + 18)));
  275. }
  276. /* triggers left/right */
  277. if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) {
  278. input_report_key(dev, BTN_TL2, data[10]);
  279. input_report_key(dev, BTN_TR2, data[11]);
  280. } else {
  281. input_report_abs(dev, ABS_Z, data[10]);
  282. input_report_abs(dev, ABS_RZ, data[11]);
  283. }
  284. /* digital pad */
  285. if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
  286. /* dpad as buttons (left, right, up, down) */
  287. input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & 0x04);
  288. input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08);
  289. input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01);
  290. input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02);
  291. } else {
  292. input_report_abs(dev, ABS_HAT0X,
  293. !!(data[2] & 0x08) - !!(data[2] & 0x04));
  294. input_report_abs(dev, ABS_HAT0Y,
  295. !!(data[2] & 0x02) - !!(data[2] & 0x01));
  296. }
  297. /* start/back buttons and stick press left/right */
  298. input_report_key(dev, BTN_START, data[2] & 0x10);
  299. input_report_key(dev, BTN_SELECT, data[2] & 0x20);
  300. input_report_key(dev, BTN_THUMBL, data[2] & 0x40);
  301. input_report_key(dev, BTN_THUMBR, data[2] & 0x80);
  302. /* "analog" buttons A, B, X, Y */
  303. input_report_key(dev, BTN_A, data[4]);
  304. input_report_key(dev, BTN_B, data[5]);
  305. input_report_key(dev, BTN_X, data[6]);
  306. input_report_key(dev, BTN_Y, data[7]);
  307. /* "analog" buttons black, white */
  308. input_report_key(dev, BTN_C, data[8]);
  309. input_report_key(dev, BTN_Z, data[9]);
  310. input_sync(dev);
  311. }
  312. /*
  313. * xpad360_process_packet
  314. *
  315. * Completes a request by converting the data into events for the
  316. * input subsystem. It is version for xbox 360 controller
  317. *
  318. * The used report descriptor was taken from:
  319. * http://www.free60.org/wiki/Gamepad
  320. */
  321. static void xpad360_process_packet(struct usb_xpad *xpad,
  322. u16 cmd, unsigned char *data)
  323. {
  324. struct input_dev *dev = xpad->dev;
  325. /* digital pad */
  326. if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
  327. /* dpad as buttons (left, right, up, down) */
  328. input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & 0x04);
  329. input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08);
  330. input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01);
  331. input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02);
  332. } else {
  333. input_report_abs(dev, ABS_HAT0X,
  334. !!(data[2] & 0x08) - !!(data[2] & 0x04));
  335. input_report_abs(dev, ABS_HAT0Y,
  336. !!(data[2] & 0x02) - !!(data[2] & 0x01));
  337. }
  338. /* start/back buttons */
  339. input_report_key(dev, BTN_START, data[2] & 0x10);
  340. input_report_key(dev, BTN_SELECT, data[2] & 0x20);
  341. /* stick press left/right */
  342. input_report_key(dev, BTN_THUMBL, data[2] & 0x40);
  343. input_report_key(dev, BTN_THUMBR, data[2] & 0x80);
  344. /* buttons A,B,X,Y,TL,TR and MODE */
  345. input_report_key(dev, BTN_A, data[3] & 0x10);
  346. input_report_key(dev, BTN_B, data[3] & 0x20);
  347. input_report_key(dev, BTN_X, data[3] & 0x40);
  348. input_report_key(dev, BTN_Y, data[3] & 0x80);
  349. input_report_key(dev, BTN_TL, data[3] & 0x01);
  350. input_report_key(dev, BTN_TR, data[3] & 0x02);
  351. input_report_key(dev, BTN_MODE, data[3] & 0x04);
  352. if (!(xpad->mapping & MAP_STICKS_TO_NULL)) {
  353. /* left stick */
  354. input_report_abs(dev, ABS_X,
  355. (__s16) le16_to_cpup((__le16 *)(data + 6)));
  356. input_report_abs(dev, ABS_Y,
  357. ~(__s16) le16_to_cpup((__le16 *)(data + 8)));
  358. /* right stick */
  359. input_report_abs(dev, ABS_RX,
  360. (__s16) le16_to_cpup((__le16 *)(data + 10)));
  361. input_report_abs(dev, ABS_RY,
  362. ~(__s16) le16_to_cpup((__le16 *)(data + 12)));
  363. }
  364. /* triggers left/right */
  365. if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) {
  366. input_report_key(dev, BTN_TL2, data[4]);
  367. input_report_key(dev, BTN_TR2, data[5]);
  368. } else {
  369. input_report_abs(dev, ABS_Z, data[4]);
  370. input_report_abs(dev, ABS_RZ, data[5]);
  371. }
  372. input_sync(dev);
  373. }
  374. /*
  375. * xpad360w_process_packet
  376. *
  377. * Completes a request by converting the data into events for the
  378. * input subsystem. It is version for xbox 360 wireless controller.
  379. *
  380. * Byte.Bit
  381. * 00.1 - Status change: The controller or headset has connected/disconnected
  382. * Bits 01.7 and 01.6 are valid
  383. * 01.7 - Controller present
  384. * 01.6 - Headset present
  385. * 01.1 - Pad state (Bytes 4+) valid
  386. *
  387. */
  388. static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
  389. {
  390. /* Presence change */
  391. if (data[0] & 0x08) {
  392. if (data[1] & 0x80) {
  393. xpad->pad_present = 1;
  394. usb_submit_urb(xpad->bulk_out, GFP_ATOMIC);
  395. } else
  396. xpad->pad_present = 0;
  397. }
  398. /* Valid pad data */
  399. if (!(data[1] & 0x1))
  400. return;
  401. xpad360_process_packet(xpad, cmd, &data[4]);
  402. }
  403. static void xpad_irq_in(struct urb *urb)
  404. {
  405. struct usb_xpad *xpad = urb->context;
  406. struct device *dev = &xpad->dev->dev;
  407. int retval, status;
  408. status = urb->status;
  409. switch (status) {
  410. case 0:
  411. /* success */
  412. break;
  413. case -ECONNRESET:
  414. case -ENOENT:
  415. case -ESHUTDOWN:
  416. /* this urb is terminated, clean up */
  417. dev_dbg(dev, "%s - urb shutting down with status: %d\n",
  418. __func__, status);
  419. return;
  420. default:
  421. dev_dbg(dev, "%s - nonzero urb status received: %d\n",
  422. __func__, status);
  423. goto exit;
  424. }
  425. switch (xpad->xtype) {
  426. case XTYPE_XBOX360:
  427. xpad360_process_packet(xpad, 0, xpad->idata);
  428. break;
  429. case XTYPE_XBOX360W:
  430. xpad360w_process_packet(xpad, 0, xpad->idata);
  431. break;
  432. default:
  433. xpad_process_packet(xpad, 0, xpad->idata);
  434. }
  435. exit:
  436. retval = usb_submit_urb(urb, GFP_ATOMIC);
  437. if (retval)
  438. dev_err(dev, "%s - usb_submit_urb failed with result %d\n",
  439. __func__, retval);
  440. }
  441. static void xpad_bulk_out(struct urb *urb)
  442. {
  443. struct usb_xpad *xpad = urb->context;
  444. struct device *dev = &xpad->dev->dev;
  445. switch (urb->status) {
  446. case 0:
  447. /* success */
  448. break;
  449. case -ECONNRESET:
  450. case -ENOENT:
  451. case -ESHUTDOWN:
  452. /* this urb is terminated, clean up */
  453. dev_dbg(dev, "%s - urb shutting down with status: %d\n",
  454. __func__, urb->status);
  455. break;
  456. default:
  457. dev_dbg(dev, "%s - nonzero urb status received: %d\n",
  458. __func__, urb->status);
  459. }
  460. }
  461. #if defined(CONFIG_JOYSTICK_XPAD_FF) || defined(CONFIG_JOYSTICK_XPAD_LEDS)
  462. static void xpad_irq_out(struct urb *urb)
  463. {
  464. struct usb_xpad *xpad = urb->context;
  465. struct device *dev = &xpad->dev->dev;
  466. int retval, status;
  467. status = urb->status;
  468. switch (status) {
  469. case 0:
  470. /* success */
  471. return;
  472. case -ECONNRESET:
  473. case -ENOENT:
  474. case -ESHUTDOWN:
  475. /* this urb is terminated, clean up */
  476. dev_dbg(dev, "%s - urb shutting down with status: %d\n",
  477. __func__, status);
  478. return;
  479. default:
  480. dev_dbg(dev, "%s - nonzero urb status received: %d\n",
  481. __func__, status);
  482. goto exit;
  483. }
  484. exit:
  485. retval = usb_submit_urb(urb, GFP_ATOMIC);
  486. if (retval)
  487. dev_err(dev, "%s - usb_submit_urb failed with result %d\n",
  488. __func__, retval);
  489. }
  490. static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad)
  491. {
  492. struct usb_endpoint_descriptor *ep_irq_out;
  493. int error;
  494. if (xpad->xtype == XTYPE_UNKNOWN)
  495. return 0;
  496. xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN,
  497. GFP_KERNEL, &xpad->odata_dma);
  498. if (!xpad->odata) {
  499. error = -ENOMEM;
  500. goto fail1;
  501. }
  502. mutex_init(&xpad->odata_mutex);
  503. xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL);
  504. if (!xpad->irq_out) {
  505. error = -ENOMEM;
  506. goto fail2;
  507. }
  508. ep_irq_out = &intf->cur_altsetting->endpoint[1].desc;
  509. usb_fill_int_urb(xpad->irq_out, xpad->udev,
  510. usb_sndintpipe(xpad->udev, ep_irq_out->bEndpointAddress),
  511. xpad->odata, XPAD_PKT_LEN,
  512. xpad_irq_out, xpad, ep_irq_out->bInterval);
  513. xpad->irq_out->transfer_dma = xpad->odata_dma;
  514. xpad->irq_out->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
  515. return 0;
  516. fail2: usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma);
  517. fail1: return error;
  518. }
  519. static void xpad_stop_output(struct usb_xpad *xpad)
  520. {
  521. if (xpad->xtype != XTYPE_UNKNOWN)
  522. usb_kill_urb(xpad->irq_out);
  523. }
  524. static void xpad_deinit_output(struct usb_xpad *xpad)
  525. {
  526. if (xpad->xtype != XTYPE_UNKNOWN) {
  527. usb_free_urb(xpad->irq_out);
  528. usb_free_coherent(xpad->udev, XPAD_PKT_LEN,
  529. xpad->odata, xpad->odata_dma);
  530. }
  531. }
  532. #else
  533. static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad) { return 0; }
  534. static void xpad_deinit_output(struct usb_xpad *xpad) {}
  535. static void xpad_stop_output(struct usb_xpad *xpad) {}
  536. #endif
  537. #ifdef CONFIG_JOYSTICK_XPAD_FF
  538. static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect)
  539. {
  540. struct usb_xpad *xpad = input_get_drvdata(dev);
  541. if (effect->type == FF_RUMBLE) {
  542. __u16 strong = effect->u.rumble.strong_magnitude;
  543. __u16 weak = effect->u.rumble.weak_magnitude;
  544. switch (xpad->xtype) {
  545. case XTYPE_XBOX:
  546. xpad->odata[0] = 0x00;
  547. xpad->odata[1] = 0x06;
  548. xpad->odata[2] = 0x00;
  549. xpad->odata[3] = strong / 256; /* left actuator */
  550. xpad->odata[4] = 0x00;
  551. xpad->odata[5] = weak / 256; /* right actuator */
  552. xpad->irq_out->transfer_buffer_length = 6;
  553. return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
  554. case XTYPE_XBOX360:
  555. xpad->odata[0] = 0x00;
  556. xpad->odata[1] = 0x08;
  557. xpad->odata[2] = 0x00;
  558. xpad->odata[3] = strong / 256; /* left actuator? */
  559. xpad->odata[4] = weak / 256; /* right actuator? */
  560. xpad->odata[5] = 0x00;
  561. xpad->odata[6] = 0x00;
  562. xpad->odata[7] = 0x00;
  563. xpad->irq_out->transfer_buffer_length = 8;
  564. return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
  565. case XTYPE_XBOX360W:
  566. xpad->odata[0] = 0x00;
  567. xpad->odata[1] = 0x01;
  568. xpad->odata[2] = 0x0F;
  569. xpad->odata[3] = 0xC0;
  570. xpad->odata[4] = 0x00;
  571. xpad->odata[5] = strong / 256;
  572. xpad->odata[6] = weak / 256;
  573. xpad->odata[7] = 0x00;
  574. xpad->odata[8] = 0x00;
  575. xpad->odata[9] = 0x00;
  576. xpad->odata[10] = 0x00;
  577. xpad->odata[11] = 0x00;
  578. xpad->irq_out->transfer_buffer_length = 12;
  579. return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
  580. default:
  581. dev_dbg(&xpad->dev->dev,
  582. "%s - rumble command sent to unsupported xpad type: %d\n",
  583. __func__, xpad->xtype);
  584. return -1;
  585. }
  586. }
  587. return 0;
  588. }
  589. static int xpad_init_ff(struct usb_xpad *xpad)
  590. {
  591. if (xpad->xtype == XTYPE_UNKNOWN)
  592. return 0;
  593. input_set_capability(xpad->dev, EV_FF, FF_RUMBLE);
  594. return input_ff_create_memless(xpad->dev, NULL, xpad_play_effect);
  595. }
  596. #else
  597. static int xpad_init_ff(struct usb_xpad *xpad) { return 0; }
  598. #endif
  599. #if defined(CONFIG_JOYSTICK_XPAD_LEDS)
  600. #include <linux/leds.h>
  601. struct xpad_led {
  602. char name[16];
  603. struct led_classdev led_cdev;
  604. struct usb_xpad *xpad;
  605. };
  606. static void xpad_send_led_command(struct usb_xpad *xpad, int command)
  607. {
  608. if (command >= 0 && command < 14) {
  609. mutex_lock(&xpad->odata_mutex);
  610. xpad->odata[0] = 0x01;
  611. xpad->odata[1] = 0x03;
  612. xpad->odata[2] = command;
  613. xpad->irq_out->transfer_buffer_length = 3;
  614. usb_submit_urb(xpad->irq_out, GFP_KERNEL);
  615. mutex_unlock(&xpad->odata_mutex);
  616. }
  617. }
  618. static void xpad_led_set(struct led_classdev *led_cdev,
  619. enum led_brightness value)
  620. {
  621. struct xpad_led *xpad_led = container_of(led_cdev,
  622. struct xpad_led, led_cdev);
  623. xpad_send_led_command(xpad_led->xpad, value);
  624. }
  625. static int xpad_led_probe(struct usb_xpad *xpad)
  626. {
  627. static atomic_t led_seq = ATOMIC_INIT(0);
  628. long led_no;
  629. struct xpad_led *led;
  630. struct led_classdev *led_cdev;
  631. int error;
  632. if (xpad->xtype != XTYPE_XBOX360)
  633. return 0;
  634. xpad->led = led = kzalloc(sizeof(struct xpad_led), GFP_KERNEL);
  635. if (!led)
  636. return -ENOMEM;
  637. led_no = (long)atomic_inc_return(&led_seq) - 1;
  638. snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
  639. led->xpad = xpad;
  640. led_cdev = &led->led_cdev;
  641. led_cdev->name = led->name;
  642. led_cdev->brightness_set = xpad_led_set;
  643. error = led_classdev_register(&xpad->udev->dev, led_cdev);
  644. if (error) {
  645. kfree(led);
  646. xpad->led = NULL;
  647. return error;
  648. }
  649. /*
  650. * Light up the segment corresponding to controller number
  651. */
  652. xpad_send_led_command(xpad, (led_no % 4) + 2);
  653. return 0;
  654. }
  655. static void xpad_led_disconnect(struct usb_xpad *xpad)
  656. {
  657. struct xpad_led *xpad_led = xpad->led;
  658. if (xpad_led) {
  659. led_classdev_unregister(&xpad_led->led_cdev);
  660. kfree(xpad_led);
  661. }
  662. }
  663. #else
  664. static int xpad_led_probe(struct usb_xpad *xpad) { return 0; }
  665. static void xpad_led_disconnect(struct usb_xpad *xpad) { }
  666. #endif
  667. static int xpad_open(struct input_dev *dev)
  668. {
  669. struct usb_xpad *xpad = input_get_drvdata(dev);
  670. /* URB was submitted in probe */
  671. if(xpad->xtype == XTYPE_XBOX360W)
  672. return 0;
  673. xpad->irq_in->dev = xpad->udev;
  674. if (usb_submit_urb(xpad->irq_in, GFP_KERNEL))
  675. return -EIO;
  676. return 0;
  677. }
  678. static void xpad_close(struct input_dev *dev)
  679. {
  680. struct usb_xpad *xpad = input_get_drvdata(dev);
  681. if (xpad->xtype != XTYPE_XBOX360W)
  682. usb_kill_urb(xpad->irq_in);
  683. xpad_stop_output(xpad);
  684. }
  685. static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)
  686. {
  687. set_bit(abs, input_dev->absbit);
  688. switch (abs) {
  689. case ABS_X:
  690. case ABS_Y:
  691. case ABS_RX:
  692. case ABS_RY: /* the two sticks */
  693. input_set_abs_params(input_dev, abs, -32768, 32767, 16, 128);
  694. break;
  695. case ABS_Z:
  696. case ABS_RZ: /* the triggers (if mapped to axes) */
  697. input_set_abs_params(input_dev, abs, 0, 255, 0, 0);
  698. break;
  699. case ABS_HAT0X:
  700. case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */
  701. input_set_abs_params(input_dev, abs, -1, 1, 0, 0);
  702. break;
  703. }
  704. }
  705. static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id)
  706. {
  707. struct usb_device *udev = interface_to_usbdev(intf);
  708. struct usb_xpad *xpad;
  709. struct input_dev *input_dev;
  710. struct usb_endpoint_descriptor *ep_irq_in;
  711. int i, error;
  712. for (i = 0; xpad_device[i].idVendor; i++) {
  713. if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) &&
  714. (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct))
  715. break;
  716. }
  717. xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL);
  718. input_dev = input_allocate_device();
  719. if (!xpad || !input_dev) {
  720. error = -ENOMEM;
  721. goto fail1;
  722. }
  723. xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN,
  724. GFP_KERNEL, &xpad->idata_dma);
  725. if (!xpad->idata) {
  726. error = -ENOMEM;
  727. goto fail1;
  728. }
  729. xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL);
  730. if (!xpad->irq_in) {
  731. error = -ENOMEM;
  732. goto fail2;
  733. }
  734. xpad->udev = udev;
  735. xpad->mapping = xpad_device[i].mapping;
  736. xpad->xtype = xpad_device[i].xtype;
  737. if (xpad->xtype == XTYPE_UNKNOWN) {
  738. if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) {
  739. if (intf->cur_altsetting->desc.bInterfaceProtocol == 129)
  740. xpad->xtype = XTYPE_XBOX360W;
  741. else
  742. xpad->xtype = XTYPE_XBOX360;
  743. } else
  744. xpad->xtype = XTYPE_XBOX;
  745. if (dpad_to_buttons)
  746. xpad->mapping |= MAP_DPAD_TO_BUTTONS;
  747. if (triggers_to_buttons)
  748. xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS;
  749. if (sticks_to_null)
  750. xpad->mapping |= MAP_STICKS_TO_NULL;
  751. }
  752. xpad->dev = input_dev;
  753. usb_make_path(udev, xpad->phys, sizeof(xpad->phys));
  754. strlcat(xpad->phys, "/input0", sizeof(xpad->phys));
  755. input_dev->name = xpad_device[i].name;
  756. input_dev->phys = xpad->phys;
  757. usb_to_input_id(udev, &input_dev->id);
  758. input_dev->dev.parent = &intf->dev;
  759. input_set_drvdata(input_dev, xpad);
  760. input_dev->open = xpad_open;
  761. input_dev->close = xpad_close;
  762. input_dev->evbit[0] = BIT_MASK(EV_KEY);
  763. if (!(xpad->mapping & MAP_STICKS_TO_NULL)) {
  764. input_dev->evbit[0] |= BIT_MASK(EV_ABS);
  765. /* set up axes */
  766. for (i = 0; xpad_abs[i] >= 0; i++)
  767. xpad_set_up_abs(input_dev, xpad_abs[i]);
  768. }
  769. /* set up standard buttons */
  770. for (i = 0; xpad_common_btn[i] >= 0; i++)
  771. __set_bit(xpad_common_btn[i], input_dev->keybit);
  772. /* set up model-specific ones */
  773. if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W) {
  774. for (i = 0; xpad360_btn[i] >= 0; i++)
  775. __set_bit(xpad360_btn[i], input_dev->keybit);
  776. } else {
  777. for (i = 0; xpad_btn[i] >= 0; i++)
  778. __set_bit(xpad_btn[i], input_dev->keybit);
  779. }
  780. if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
  781. for (i = 0; xpad_btn_pad[i] >= 0; i++)
  782. __set_bit(xpad_btn_pad[i], input_dev->keybit);
  783. } else {
  784. for (i = 0; xpad_abs_pad[i] >= 0; i++)
  785. xpad_set_up_abs(input_dev, xpad_abs_pad[i]);
  786. }
  787. if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) {
  788. for (i = 0; xpad_btn_triggers[i] >= 0; i++)
  789. __set_bit(xpad_btn_triggers[i], input_dev->keybit);
  790. } else {
  791. for (i = 0; xpad_abs_triggers[i] >= 0; i++)
  792. xpad_set_up_abs(input_dev, xpad_abs_triggers[i]);
  793. }
  794. error = xpad_init_output(intf, xpad);
  795. if (error)
  796. goto fail3;
  797. error = xpad_init_ff(xpad);
  798. if (error)
  799. goto fail4;
  800. error = xpad_led_probe(xpad);
  801. if (error)
  802. goto fail5;
  803. ep_irq_in = &intf->cur_altsetting->endpoint[0].desc;
  804. usb_fill_int_urb(xpad->irq_in, udev,
  805. usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress),
  806. xpad->idata, XPAD_PKT_LEN, xpad_irq_in,
  807. xpad, ep_irq_in->bInterval);
  808. xpad->irq_in->transfer_dma = xpad->idata_dma;
  809. xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
  810. error = input_register_device(xpad->dev);
  811. if (error)
  812. goto fail6;
  813. usb_set_intfdata(intf, xpad);
  814. if (xpad->xtype == XTYPE_XBOX360W) {
  815. /*
  816. * Setup the message to set the LEDs on the
  817. * controller when it shows up
  818. */
  819. xpad->bulk_out = usb_alloc_urb(0, GFP_KERNEL);
  820. if (!xpad->bulk_out) {
  821. error = -ENOMEM;
  822. goto fail7;
  823. }
  824. xpad->bdata = kzalloc(XPAD_PKT_LEN, GFP_KERNEL);
  825. if (!xpad->bdata) {
  826. error = -ENOMEM;
  827. goto fail8;
  828. }
  829. xpad->bdata[2] = 0x08;
  830. switch (intf->cur_altsetting->desc.bInterfaceNumber) {
  831. case 0:
  832. xpad->bdata[3] = 0x42;
  833. break;
  834. case 2:
  835. xpad->bdata[3] = 0x43;
  836. break;
  837. case 4:
  838. xpad->bdata[3] = 0x44;
  839. break;
  840. case 6:
  841. xpad->bdata[3] = 0x45;
  842. }
  843. ep_irq_in = &intf->cur_altsetting->endpoint[1].desc;
  844. usb_fill_bulk_urb(xpad->bulk_out, udev,
  845. usb_sndbulkpipe(udev, ep_irq_in->bEndpointAddress),
  846. xpad->bdata, XPAD_PKT_LEN, xpad_bulk_out, xpad);
  847. /*
  848. * Submit the int URB immediately rather than waiting for open
  849. * because we get status messages from the device whether
  850. * or not any controllers are attached. In fact, it's
  851. * exactly the message that a controller has arrived that
  852. * we're waiting for.
  853. */
  854. xpad->irq_in->dev = xpad->udev;
  855. error = usb_submit_urb(xpad->irq_in, GFP_KERNEL);
  856. if (error)
  857. goto fail9;
  858. }
  859. return 0;
  860. fail9: kfree(xpad->bdata);
  861. fail8: usb_free_urb(xpad->bulk_out);
  862. fail7: input_unregister_device(input_dev);
  863. input_dev = NULL;
  864. fail6: xpad_led_disconnect(xpad);
  865. fail5: if (input_dev)
  866. input_ff_destroy(input_dev);
  867. fail4: xpad_deinit_output(xpad);
  868. fail3: usb_free_urb(xpad->irq_in);
  869. fail2: usb_free_coherent(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma);
  870. fail1: input_free_device(input_dev);
  871. kfree(xpad);
  872. return error;
  873. }
  874. static void xpad_disconnect(struct usb_interface *intf)
  875. {
  876. struct usb_xpad *xpad = usb_get_intfdata (intf);
  877. xpad_led_disconnect(xpad);
  878. input_unregister_device(xpad->dev);
  879. xpad_deinit_output(xpad);
  880. if (xpad->xtype == XTYPE_XBOX360W) {
  881. usb_kill_urb(xpad->bulk_out);
  882. usb_free_urb(xpad->bulk_out);
  883. usb_kill_urb(xpad->irq_in);
  884. }
  885. usb_free_urb(xpad->irq_in);
  886. usb_free_coherent(xpad->udev, XPAD_PKT_LEN,
  887. xpad->idata, xpad->idata_dma);
  888. kfree(xpad->bdata);
  889. kfree(xpad);
  890. usb_set_intfdata(intf, NULL);
  891. }
  892. static struct usb_driver xpad_driver = {
  893. .name = "xpad",
  894. .probe = xpad_probe,
  895. .disconnect = xpad_disconnect,
  896. .id_table = xpad_table,
  897. };
  898. module_usb_driver(xpad_driver);
  899. MODULE_AUTHOR(DRIVER_AUTHOR);
  900. MODULE_DESCRIPTION(DRIVER_DESC);
  901. MODULE_LICENSE("GPL");