xpad.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061
  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. struct usb_interface *intf; /* usb interface */
  234. int pad_present;
  235. struct urb *irq_in; /* urb for interrupt in report */
  236. unsigned char *idata; /* input data */
  237. dma_addr_t idata_dma;
  238. struct urb *bulk_out;
  239. unsigned char *bdata;
  240. #if defined(CONFIG_JOYSTICK_XPAD_FF) || defined(CONFIG_JOYSTICK_XPAD_LEDS)
  241. struct urb *irq_out; /* urb for interrupt out report */
  242. unsigned char *odata; /* output data */
  243. dma_addr_t odata_dma;
  244. struct mutex odata_mutex;
  245. #endif
  246. #if defined(CONFIG_JOYSTICK_XPAD_LEDS)
  247. struct xpad_led *led;
  248. #endif
  249. char phys[64]; /* physical device path */
  250. int mapping; /* map d-pad to buttons or to axes */
  251. int xtype; /* type of xbox device */
  252. };
  253. /*
  254. * xpad_process_packet
  255. *
  256. * Completes a request by converting the data into events for the
  257. * input subsystem.
  258. *
  259. * The used report descriptor was taken from ITO Takayukis website:
  260. * http://euc.jp/periphs/xbox-controller.ja.html
  261. */
  262. static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
  263. {
  264. struct input_dev *dev = xpad->dev;
  265. if (!(xpad->mapping & MAP_STICKS_TO_NULL)) {
  266. /* left stick */
  267. input_report_abs(dev, ABS_X,
  268. (__s16) le16_to_cpup((__le16 *)(data + 12)));
  269. input_report_abs(dev, ABS_Y,
  270. ~(__s16) le16_to_cpup((__le16 *)(data + 14)));
  271. /* right stick */
  272. input_report_abs(dev, ABS_RX,
  273. (__s16) le16_to_cpup((__le16 *)(data + 16)));
  274. input_report_abs(dev, ABS_RY,
  275. ~(__s16) le16_to_cpup((__le16 *)(data + 18)));
  276. }
  277. /* triggers left/right */
  278. if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) {
  279. input_report_key(dev, BTN_TL2, data[10]);
  280. input_report_key(dev, BTN_TR2, data[11]);
  281. } else {
  282. input_report_abs(dev, ABS_Z, data[10]);
  283. input_report_abs(dev, ABS_RZ, data[11]);
  284. }
  285. /* digital pad */
  286. if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
  287. /* dpad as buttons (left, right, up, down) */
  288. input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & 0x04);
  289. input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08);
  290. input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01);
  291. input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02);
  292. } else {
  293. input_report_abs(dev, ABS_HAT0X,
  294. !!(data[2] & 0x08) - !!(data[2] & 0x04));
  295. input_report_abs(dev, ABS_HAT0Y,
  296. !!(data[2] & 0x02) - !!(data[2] & 0x01));
  297. }
  298. /* start/back buttons and stick press left/right */
  299. input_report_key(dev, BTN_START, data[2] & 0x10);
  300. input_report_key(dev, BTN_SELECT, data[2] & 0x20);
  301. input_report_key(dev, BTN_THUMBL, data[2] & 0x40);
  302. input_report_key(dev, BTN_THUMBR, data[2] & 0x80);
  303. /* "analog" buttons A, B, X, Y */
  304. input_report_key(dev, BTN_A, data[4]);
  305. input_report_key(dev, BTN_B, data[5]);
  306. input_report_key(dev, BTN_X, data[6]);
  307. input_report_key(dev, BTN_Y, data[7]);
  308. /* "analog" buttons black, white */
  309. input_report_key(dev, BTN_C, data[8]);
  310. input_report_key(dev, BTN_Z, data[9]);
  311. input_sync(dev);
  312. }
  313. /*
  314. * xpad360_process_packet
  315. *
  316. * Completes a request by converting the data into events for the
  317. * input subsystem. It is version for xbox 360 controller
  318. *
  319. * The used report descriptor was taken from:
  320. * http://www.free60.org/wiki/Gamepad
  321. */
  322. static void xpad360_process_packet(struct usb_xpad *xpad,
  323. u16 cmd, unsigned char *data)
  324. {
  325. struct input_dev *dev = xpad->dev;
  326. /* digital pad */
  327. if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
  328. /* dpad as buttons (left, right, up, down) */
  329. input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & 0x04);
  330. input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08);
  331. input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01);
  332. input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02);
  333. } else {
  334. input_report_abs(dev, ABS_HAT0X,
  335. !!(data[2] & 0x08) - !!(data[2] & 0x04));
  336. input_report_abs(dev, ABS_HAT0Y,
  337. !!(data[2] & 0x02) - !!(data[2] & 0x01));
  338. }
  339. /* start/back buttons */
  340. input_report_key(dev, BTN_START, data[2] & 0x10);
  341. input_report_key(dev, BTN_SELECT, data[2] & 0x20);
  342. /* stick press left/right */
  343. input_report_key(dev, BTN_THUMBL, data[2] & 0x40);
  344. input_report_key(dev, BTN_THUMBR, data[2] & 0x80);
  345. /* buttons A,B,X,Y,TL,TR and MODE */
  346. input_report_key(dev, BTN_A, data[3] & 0x10);
  347. input_report_key(dev, BTN_B, data[3] & 0x20);
  348. input_report_key(dev, BTN_X, data[3] & 0x40);
  349. input_report_key(dev, BTN_Y, data[3] & 0x80);
  350. input_report_key(dev, BTN_TL, data[3] & 0x01);
  351. input_report_key(dev, BTN_TR, data[3] & 0x02);
  352. input_report_key(dev, BTN_MODE, data[3] & 0x04);
  353. if (!(xpad->mapping & MAP_STICKS_TO_NULL)) {
  354. /* left stick */
  355. input_report_abs(dev, ABS_X,
  356. (__s16) le16_to_cpup((__le16 *)(data + 6)));
  357. input_report_abs(dev, ABS_Y,
  358. ~(__s16) le16_to_cpup((__le16 *)(data + 8)));
  359. /* right stick */
  360. input_report_abs(dev, ABS_RX,
  361. (__s16) le16_to_cpup((__le16 *)(data + 10)));
  362. input_report_abs(dev, ABS_RY,
  363. ~(__s16) le16_to_cpup((__le16 *)(data + 12)));
  364. }
  365. /* triggers left/right */
  366. if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) {
  367. input_report_key(dev, BTN_TL2, data[4]);
  368. input_report_key(dev, BTN_TR2, data[5]);
  369. } else {
  370. input_report_abs(dev, ABS_Z, data[4]);
  371. input_report_abs(dev, ABS_RZ, data[5]);
  372. }
  373. input_sync(dev);
  374. }
  375. /*
  376. * xpad360w_process_packet
  377. *
  378. * Completes a request by converting the data into events for the
  379. * input subsystem. It is version for xbox 360 wireless controller.
  380. *
  381. * Byte.Bit
  382. * 00.1 - Status change: The controller or headset has connected/disconnected
  383. * Bits 01.7 and 01.6 are valid
  384. * 01.7 - Controller present
  385. * 01.6 - Headset present
  386. * 01.1 - Pad state (Bytes 4+) valid
  387. *
  388. */
  389. static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data)
  390. {
  391. /* Presence change */
  392. if (data[0] & 0x08) {
  393. if (data[1] & 0x80) {
  394. xpad->pad_present = 1;
  395. usb_submit_urb(xpad->bulk_out, GFP_ATOMIC);
  396. } else
  397. xpad->pad_present = 0;
  398. }
  399. /* Valid pad data */
  400. if (!(data[1] & 0x1))
  401. return;
  402. xpad360_process_packet(xpad, cmd, &data[4]);
  403. }
  404. static void xpad_irq_in(struct urb *urb)
  405. {
  406. struct usb_xpad *xpad = urb->context;
  407. struct device *dev = &xpad->intf->dev;
  408. int retval, status;
  409. status = urb->status;
  410. switch (status) {
  411. case 0:
  412. /* success */
  413. break;
  414. case -ECONNRESET:
  415. case -ENOENT:
  416. case -ESHUTDOWN:
  417. /* this urb is terminated, clean up */
  418. dev_dbg(dev, "%s - urb shutting down with status: %d\n",
  419. __func__, status);
  420. return;
  421. default:
  422. dev_dbg(dev, "%s - nonzero urb status received: %d\n",
  423. __func__, status);
  424. goto exit;
  425. }
  426. switch (xpad->xtype) {
  427. case XTYPE_XBOX360:
  428. xpad360_process_packet(xpad, 0, xpad->idata);
  429. break;
  430. case XTYPE_XBOX360W:
  431. xpad360w_process_packet(xpad, 0, xpad->idata);
  432. break;
  433. default:
  434. xpad_process_packet(xpad, 0, xpad->idata);
  435. }
  436. exit:
  437. retval = usb_submit_urb(urb, GFP_ATOMIC);
  438. if (retval)
  439. dev_err(dev, "%s - usb_submit_urb failed with result %d\n",
  440. __func__, retval);
  441. }
  442. static void xpad_bulk_out(struct urb *urb)
  443. {
  444. struct usb_xpad *xpad = urb->context;
  445. struct device *dev = &xpad->intf->dev;
  446. switch (urb->status) {
  447. case 0:
  448. /* success */
  449. break;
  450. case -ECONNRESET:
  451. case -ENOENT:
  452. case -ESHUTDOWN:
  453. /* this urb is terminated, clean up */
  454. dev_dbg(dev, "%s - urb shutting down with status: %d\n",
  455. __func__, urb->status);
  456. break;
  457. default:
  458. dev_dbg(dev, "%s - nonzero urb status received: %d\n",
  459. __func__, urb->status);
  460. }
  461. }
  462. #if defined(CONFIG_JOYSTICK_XPAD_FF) || defined(CONFIG_JOYSTICK_XPAD_LEDS)
  463. static void xpad_irq_out(struct urb *urb)
  464. {
  465. struct usb_xpad *xpad = urb->context;
  466. struct device *dev = &xpad->intf->dev;
  467. int retval, status;
  468. status = urb->status;
  469. switch (status) {
  470. case 0:
  471. /* success */
  472. return;
  473. case -ECONNRESET:
  474. case -ENOENT:
  475. case -ESHUTDOWN:
  476. /* this urb is terminated, clean up */
  477. dev_dbg(dev, "%s - urb shutting down with status: %d\n",
  478. __func__, status);
  479. return;
  480. default:
  481. dev_dbg(dev, "%s - nonzero urb status received: %d\n",
  482. __func__, status);
  483. goto exit;
  484. }
  485. exit:
  486. retval = usb_submit_urb(urb, GFP_ATOMIC);
  487. if (retval)
  488. dev_err(dev, "%s - usb_submit_urb failed with result %d\n",
  489. __func__, retval);
  490. }
  491. static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad)
  492. {
  493. struct usb_endpoint_descriptor *ep_irq_out;
  494. int error;
  495. if (xpad->xtype == XTYPE_UNKNOWN)
  496. return 0;
  497. xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN,
  498. GFP_KERNEL, &xpad->odata_dma);
  499. if (!xpad->odata) {
  500. error = -ENOMEM;
  501. goto fail1;
  502. }
  503. mutex_init(&xpad->odata_mutex);
  504. xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL);
  505. if (!xpad->irq_out) {
  506. error = -ENOMEM;
  507. goto fail2;
  508. }
  509. ep_irq_out = &intf->cur_altsetting->endpoint[1].desc;
  510. usb_fill_int_urb(xpad->irq_out, xpad->udev,
  511. usb_sndintpipe(xpad->udev, ep_irq_out->bEndpointAddress),
  512. xpad->odata, XPAD_PKT_LEN,
  513. xpad_irq_out, xpad, ep_irq_out->bInterval);
  514. xpad->irq_out->transfer_dma = xpad->odata_dma;
  515. xpad->irq_out->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
  516. return 0;
  517. fail2: usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma);
  518. fail1: return error;
  519. }
  520. static void xpad_stop_output(struct usb_xpad *xpad)
  521. {
  522. if (xpad->xtype != XTYPE_UNKNOWN)
  523. usb_kill_urb(xpad->irq_out);
  524. }
  525. static void xpad_deinit_output(struct usb_xpad *xpad)
  526. {
  527. if (xpad->xtype != XTYPE_UNKNOWN) {
  528. usb_free_urb(xpad->irq_out);
  529. usb_free_coherent(xpad->udev, XPAD_PKT_LEN,
  530. xpad->odata, xpad->odata_dma);
  531. }
  532. }
  533. #else
  534. static int xpad_init_output(struct usb_interface *intf, struct usb_xpad *xpad) { return 0; }
  535. static void xpad_deinit_output(struct usb_xpad *xpad) {}
  536. static void xpad_stop_output(struct usb_xpad *xpad) {}
  537. #endif
  538. #ifdef CONFIG_JOYSTICK_XPAD_FF
  539. static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect)
  540. {
  541. struct usb_xpad *xpad = input_get_drvdata(dev);
  542. if (effect->type == FF_RUMBLE) {
  543. __u16 strong = effect->u.rumble.strong_magnitude;
  544. __u16 weak = effect->u.rumble.weak_magnitude;
  545. switch (xpad->xtype) {
  546. case XTYPE_XBOX:
  547. xpad->odata[0] = 0x00;
  548. xpad->odata[1] = 0x06;
  549. xpad->odata[2] = 0x00;
  550. xpad->odata[3] = strong / 256; /* left actuator */
  551. xpad->odata[4] = 0x00;
  552. xpad->odata[5] = weak / 256; /* right actuator */
  553. xpad->irq_out->transfer_buffer_length = 6;
  554. return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
  555. case XTYPE_XBOX360:
  556. xpad->odata[0] = 0x00;
  557. xpad->odata[1] = 0x08;
  558. xpad->odata[2] = 0x00;
  559. xpad->odata[3] = strong / 256; /* left actuator? */
  560. xpad->odata[4] = weak / 256; /* right actuator? */
  561. xpad->odata[5] = 0x00;
  562. xpad->odata[6] = 0x00;
  563. xpad->odata[7] = 0x00;
  564. xpad->irq_out->transfer_buffer_length = 8;
  565. return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
  566. case XTYPE_XBOX360W:
  567. xpad->odata[0] = 0x00;
  568. xpad->odata[1] = 0x01;
  569. xpad->odata[2] = 0x0F;
  570. xpad->odata[3] = 0xC0;
  571. xpad->odata[4] = 0x00;
  572. xpad->odata[5] = strong / 256;
  573. xpad->odata[6] = weak / 256;
  574. xpad->odata[7] = 0x00;
  575. xpad->odata[8] = 0x00;
  576. xpad->odata[9] = 0x00;
  577. xpad->odata[10] = 0x00;
  578. xpad->odata[11] = 0x00;
  579. xpad->irq_out->transfer_buffer_length = 12;
  580. return usb_submit_urb(xpad->irq_out, GFP_ATOMIC);
  581. default:
  582. dev_dbg(&xpad->dev->dev,
  583. "%s - rumble command sent to unsupported xpad type: %d\n",
  584. __func__, xpad->xtype);
  585. return -1;
  586. }
  587. }
  588. return 0;
  589. }
  590. static int xpad_init_ff(struct usb_xpad *xpad)
  591. {
  592. if (xpad->xtype == XTYPE_UNKNOWN)
  593. return 0;
  594. input_set_capability(xpad->dev, EV_FF, FF_RUMBLE);
  595. return input_ff_create_memless(xpad->dev, NULL, xpad_play_effect);
  596. }
  597. #else
  598. static int xpad_init_ff(struct usb_xpad *xpad) { return 0; }
  599. #endif
  600. #if defined(CONFIG_JOYSTICK_XPAD_LEDS)
  601. #include <linux/leds.h>
  602. struct xpad_led {
  603. char name[16];
  604. struct led_classdev led_cdev;
  605. struct usb_xpad *xpad;
  606. };
  607. static void xpad_send_led_command(struct usb_xpad *xpad, int command)
  608. {
  609. if (command >= 0 && command < 14) {
  610. mutex_lock(&xpad->odata_mutex);
  611. xpad->odata[0] = 0x01;
  612. xpad->odata[1] = 0x03;
  613. xpad->odata[2] = command;
  614. xpad->irq_out->transfer_buffer_length = 3;
  615. usb_submit_urb(xpad->irq_out, GFP_KERNEL);
  616. mutex_unlock(&xpad->odata_mutex);
  617. }
  618. }
  619. static void xpad_led_set(struct led_classdev *led_cdev,
  620. enum led_brightness value)
  621. {
  622. struct xpad_led *xpad_led = container_of(led_cdev,
  623. struct xpad_led, led_cdev);
  624. xpad_send_led_command(xpad_led->xpad, value);
  625. }
  626. static int xpad_led_probe(struct usb_xpad *xpad)
  627. {
  628. static atomic_t led_seq = ATOMIC_INIT(0);
  629. long led_no;
  630. struct xpad_led *led;
  631. struct led_classdev *led_cdev;
  632. int error;
  633. if (xpad->xtype != XTYPE_XBOX360)
  634. return 0;
  635. xpad->led = led = kzalloc(sizeof(struct xpad_led), GFP_KERNEL);
  636. if (!led)
  637. return -ENOMEM;
  638. led_no = (long)atomic_inc_return(&led_seq) - 1;
  639. snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
  640. led->xpad = xpad;
  641. led_cdev = &led->led_cdev;
  642. led_cdev->name = led->name;
  643. led_cdev->brightness_set = xpad_led_set;
  644. error = led_classdev_register(&xpad->udev->dev, led_cdev);
  645. if (error) {
  646. kfree(led);
  647. xpad->led = NULL;
  648. return error;
  649. }
  650. /*
  651. * Light up the segment corresponding to controller number
  652. */
  653. xpad_send_led_command(xpad, (led_no % 4) + 2);
  654. return 0;
  655. }
  656. static void xpad_led_disconnect(struct usb_xpad *xpad)
  657. {
  658. struct xpad_led *xpad_led = xpad->led;
  659. if (xpad_led) {
  660. led_classdev_unregister(&xpad_led->led_cdev);
  661. kfree(xpad_led);
  662. }
  663. }
  664. #else
  665. static int xpad_led_probe(struct usb_xpad *xpad) { return 0; }
  666. static void xpad_led_disconnect(struct usb_xpad *xpad) { }
  667. #endif
  668. static int xpad_open(struct input_dev *dev)
  669. {
  670. struct usb_xpad *xpad = input_get_drvdata(dev);
  671. /* URB was submitted in probe */
  672. if(xpad->xtype == XTYPE_XBOX360W)
  673. return 0;
  674. xpad->irq_in->dev = xpad->udev;
  675. if (usb_submit_urb(xpad->irq_in, GFP_KERNEL))
  676. return -EIO;
  677. return 0;
  678. }
  679. static void xpad_close(struct input_dev *dev)
  680. {
  681. struct usb_xpad *xpad = input_get_drvdata(dev);
  682. if (xpad->xtype != XTYPE_XBOX360W)
  683. usb_kill_urb(xpad->irq_in);
  684. xpad_stop_output(xpad);
  685. }
  686. static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)
  687. {
  688. set_bit(abs, input_dev->absbit);
  689. switch (abs) {
  690. case ABS_X:
  691. case ABS_Y:
  692. case ABS_RX:
  693. case ABS_RY: /* the two sticks */
  694. input_set_abs_params(input_dev, abs, -32768, 32767, 16, 128);
  695. break;
  696. case ABS_Z:
  697. case ABS_RZ: /* the triggers (if mapped to axes) */
  698. input_set_abs_params(input_dev, abs, 0, 255, 0, 0);
  699. break;
  700. case ABS_HAT0X:
  701. case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */
  702. input_set_abs_params(input_dev, abs, -1, 1, 0, 0);
  703. break;
  704. }
  705. }
  706. static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id)
  707. {
  708. struct usb_device *udev = interface_to_usbdev(intf);
  709. struct usb_xpad *xpad;
  710. struct input_dev *input_dev;
  711. struct usb_endpoint_descriptor *ep_irq_in;
  712. int i, error;
  713. for (i = 0; xpad_device[i].idVendor; i++) {
  714. if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) &&
  715. (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct))
  716. break;
  717. }
  718. xpad = kzalloc(sizeof(struct usb_xpad), GFP_KERNEL);
  719. input_dev = input_allocate_device();
  720. if (!xpad || !input_dev) {
  721. error = -ENOMEM;
  722. goto fail1;
  723. }
  724. xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN,
  725. GFP_KERNEL, &xpad->idata_dma);
  726. if (!xpad->idata) {
  727. error = -ENOMEM;
  728. goto fail1;
  729. }
  730. xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL);
  731. if (!xpad->irq_in) {
  732. error = -ENOMEM;
  733. goto fail2;
  734. }
  735. xpad->udev = udev;
  736. xpad->intf = intf;
  737. xpad->mapping = xpad_device[i].mapping;
  738. xpad->xtype = xpad_device[i].xtype;
  739. if (xpad->xtype == XTYPE_UNKNOWN) {
  740. if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) {
  741. if (intf->cur_altsetting->desc.bInterfaceProtocol == 129)
  742. xpad->xtype = XTYPE_XBOX360W;
  743. else
  744. xpad->xtype = XTYPE_XBOX360;
  745. } else
  746. xpad->xtype = XTYPE_XBOX;
  747. if (dpad_to_buttons)
  748. xpad->mapping |= MAP_DPAD_TO_BUTTONS;
  749. if (triggers_to_buttons)
  750. xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS;
  751. if (sticks_to_null)
  752. xpad->mapping |= MAP_STICKS_TO_NULL;
  753. }
  754. xpad->dev = input_dev;
  755. usb_make_path(udev, xpad->phys, sizeof(xpad->phys));
  756. strlcat(xpad->phys, "/input0", sizeof(xpad->phys));
  757. input_dev->name = xpad_device[i].name;
  758. input_dev->phys = xpad->phys;
  759. usb_to_input_id(udev, &input_dev->id);
  760. input_dev->dev.parent = &intf->dev;
  761. input_set_drvdata(input_dev, xpad);
  762. input_dev->open = xpad_open;
  763. input_dev->close = xpad_close;
  764. input_dev->evbit[0] = BIT_MASK(EV_KEY);
  765. if (!(xpad->mapping & MAP_STICKS_TO_NULL)) {
  766. input_dev->evbit[0] |= BIT_MASK(EV_ABS);
  767. /* set up axes */
  768. for (i = 0; xpad_abs[i] >= 0; i++)
  769. xpad_set_up_abs(input_dev, xpad_abs[i]);
  770. }
  771. /* set up standard buttons */
  772. for (i = 0; xpad_common_btn[i] >= 0; i++)
  773. __set_bit(xpad_common_btn[i], input_dev->keybit);
  774. /* set up model-specific ones */
  775. if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W) {
  776. for (i = 0; xpad360_btn[i] >= 0; i++)
  777. __set_bit(xpad360_btn[i], input_dev->keybit);
  778. } else {
  779. for (i = 0; xpad_btn[i] >= 0; i++)
  780. __set_bit(xpad_btn[i], input_dev->keybit);
  781. }
  782. if (xpad->mapping & MAP_DPAD_TO_BUTTONS) {
  783. for (i = 0; xpad_btn_pad[i] >= 0; i++)
  784. __set_bit(xpad_btn_pad[i], input_dev->keybit);
  785. } else {
  786. for (i = 0; xpad_abs_pad[i] >= 0; i++)
  787. xpad_set_up_abs(input_dev, xpad_abs_pad[i]);
  788. }
  789. if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) {
  790. for (i = 0; xpad_btn_triggers[i] >= 0; i++)
  791. __set_bit(xpad_btn_triggers[i], input_dev->keybit);
  792. } else {
  793. for (i = 0; xpad_abs_triggers[i] >= 0; i++)
  794. xpad_set_up_abs(input_dev, xpad_abs_triggers[i]);
  795. }
  796. error = xpad_init_output(intf, xpad);
  797. if (error)
  798. goto fail3;
  799. error = xpad_init_ff(xpad);
  800. if (error)
  801. goto fail4;
  802. error = xpad_led_probe(xpad);
  803. if (error)
  804. goto fail5;
  805. ep_irq_in = &intf->cur_altsetting->endpoint[0].desc;
  806. usb_fill_int_urb(xpad->irq_in, udev,
  807. usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress),
  808. xpad->idata, XPAD_PKT_LEN, xpad_irq_in,
  809. xpad, ep_irq_in->bInterval);
  810. xpad->irq_in->transfer_dma = xpad->idata_dma;
  811. xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
  812. error = input_register_device(xpad->dev);
  813. if (error)
  814. goto fail6;
  815. usb_set_intfdata(intf, xpad);
  816. if (xpad->xtype == XTYPE_XBOX360W) {
  817. /*
  818. * Setup the message to set the LEDs on the
  819. * controller when it shows up
  820. */
  821. xpad->bulk_out = usb_alloc_urb(0, GFP_KERNEL);
  822. if (!xpad->bulk_out) {
  823. error = -ENOMEM;
  824. goto fail7;
  825. }
  826. xpad->bdata = kzalloc(XPAD_PKT_LEN, GFP_KERNEL);
  827. if (!xpad->bdata) {
  828. error = -ENOMEM;
  829. goto fail8;
  830. }
  831. xpad->bdata[2] = 0x08;
  832. switch (intf->cur_altsetting->desc.bInterfaceNumber) {
  833. case 0:
  834. xpad->bdata[3] = 0x42;
  835. break;
  836. case 2:
  837. xpad->bdata[3] = 0x43;
  838. break;
  839. case 4:
  840. xpad->bdata[3] = 0x44;
  841. break;
  842. case 6:
  843. xpad->bdata[3] = 0x45;
  844. }
  845. ep_irq_in = &intf->cur_altsetting->endpoint[1].desc;
  846. usb_fill_bulk_urb(xpad->bulk_out, udev,
  847. usb_sndbulkpipe(udev, ep_irq_in->bEndpointAddress),
  848. xpad->bdata, XPAD_PKT_LEN, xpad_bulk_out, xpad);
  849. /*
  850. * Submit the int URB immediately rather than waiting for open
  851. * because we get status messages from the device whether
  852. * or not any controllers are attached. In fact, it's
  853. * exactly the message that a controller has arrived that
  854. * we're waiting for.
  855. */
  856. xpad->irq_in->dev = xpad->udev;
  857. error = usb_submit_urb(xpad->irq_in, GFP_KERNEL);
  858. if (error)
  859. goto fail9;
  860. }
  861. return 0;
  862. fail9: kfree(xpad->bdata);
  863. fail8: usb_free_urb(xpad->bulk_out);
  864. fail7: input_unregister_device(input_dev);
  865. input_dev = NULL;
  866. fail6: xpad_led_disconnect(xpad);
  867. fail5: if (input_dev)
  868. input_ff_destroy(input_dev);
  869. fail4: xpad_deinit_output(xpad);
  870. fail3: usb_free_urb(xpad->irq_in);
  871. fail2: usb_free_coherent(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma);
  872. fail1: input_free_device(input_dev);
  873. kfree(xpad);
  874. return error;
  875. }
  876. static void xpad_disconnect(struct usb_interface *intf)
  877. {
  878. struct usb_xpad *xpad = usb_get_intfdata (intf);
  879. xpad_led_disconnect(xpad);
  880. input_unregister_device(xpad->dev);
  881. xpad_deinit_output(xpad);
  882. if (xpad->xtype == XTYPE_XBOX360W) {
  883. usb_kill_urb(xpad->bulk_out);
  884. usb_free_urb(xpad->bulk_out);
  885. usb_kill_urb(xpad->irq_in);
  886. }
  887. usb_free_urb(xpad->irq_in);
  888. usb_free_coherent(xpad->udev, XPAD_PKT_LEN,
  889. xpad->idata, xpad->idata_dma);
  890. kfree(xpad->bdata);
  891. kfree(xpad);
  892. usb_set_intfdata(intf, NULL);
  893. }
  894. static struct usb_driver xpad_driver = {
  895. .name = "xpad",
  896. .probe = xpad_probe,
  897. .disconnect = xpad_disconnect,
  898. .id_table = xpad_table,
  899. };
  900. module_usb_driver(xpad_driver);
  901. MODULE_AUTHOR(DRIVER_AUTHOR);
  902. MODULE_DESCRIPTION(DRIVER_DESC);
  903. MODULE_LICENSE("GPL");