Lines Matching +full:controller +full:- +full:data
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * X-Box gamepad driver
5 * Copyright (c) 2002 Marko Friedemann <mfr@bmx-chemnitz.de>
16 * - information from http://euc.jp/periphs/xbox-controller.ja.html
17 * - the iForce driver drivers/char/joystick/iforce.c
18 * - the skeleton-driver drivers/usb/usb-skeleton.c
19 * - Xbox 360 information http://www.free60.org/wiki/Gamepad
20 * - Xbox One information https://github.com/quantus/xbox-one-controller-protocol
23 * - ITO Takayuki for providing essential xpad information on his website
24 * - Vojtech Pavlik - iforce driver / input subsystem
25 * - Greg Kroah-Hartman - usb-skeleton driver
26 * - XBOX Linux project - extra USB id's
27 * - Pekka Pöyry (quantus) - Xbox One controller reverse engineering
30 * - fine tune axes (especially trigger axes)
31 * - fix "analog" buttons (reported as digital now)
32 * - get rumble working
33 * - need USB IDs for other dance pads
37 * 2002-06-27 - 0.0.1 : first version, just said "XBOX HID controller"
39 * 2002-07-02 - 0.0.2 : basic working version
40 * - all axes and 9 of the 10 buttons work (german InterAct device)
41 * - the black button does not work
43 * 2002-07-14 - 0.0.3 : rework by Vojtech Pavlik
44 * - indentation fixes
45 * - usb + input init sequence fixes
47 * 2002-07-16 - 0.0.4 : minor changes, merge with Vojtech's v0.0.3
48 * - verified the lack of HID and report descriptors
49 * - verified that ALL buttons WORK
50 * - fixed d-pad to axes mapping
52 * 2002-07-17 - 0.0.5 : simplified d-pad handling
54 * 2004-10-02 - 0.0.6 : DDR pad support
55 * - borrowed from the XBOX linux kernel
56 * - USB id's for commonly used dance pads are present
57 * - dance pads will map D-PAD to buttons, not axes
58 * - pass the module paramater 'dpad_to_buttons' to force
59 * the D-PAD to map to buttons if your pad is not detected
76 * xbox d-pads should map to buttons, as is required for DDR pads
93 MODULE_PARM_DESC(dpad_to_buttons, "Map D-PAD to buttons rather than axes for unknown pads");
114 { 0x0079, 0x18d4, "GPD Win 2 X-Box Controller", 0, XTYPE_XBOX360 },
119 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
123 { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", 0, XTYPE_XBOX },
124 { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX },
125 { 0x045e, 0x0287, "Microsoft Xbox Controller S", 0, XTYPE_XBOX },
126 { 0x045e, 0x0288, "Microsoft Xbox Controller S v2", 0, XTYPE_XBOX },
127 { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", 0, XTYPE_XBOX },
128 { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 },
129 { 0x045e, 0x028f, "Microsoft X-Box 360 pad v2", 0, XTYPE_XBOX360 },
131 { 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE },
132 { 0x045e, 0x02dd, "Microsoft X-Box One pad (Firmware 2015)", 0, XTYPE_XBOXONE },
133 { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", 0, XTYPE_XBOXONE },
134 { 0x045e, 0x02ea, "Microsoft X-Box One S pad", 0, XTYPE_XBOXONE },
139 { 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 },
140 { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX },
141 { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", 0, XTYPE_XBOX },
144 { 0x056e, 0x2004, "Elecom JC-U3613M", 0, XTYPE_XBOX360 },
145 { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", 0, XTYPE_XBOX },
146 { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", 0, XTYPE_XBOX },
147 { 0x05fe, 0x3030, "Chic Controller", 0, XTYPE_XBOX },
148 { 0x05fe, 0x3031, "Chic Controller", 0, XTYPE_XBOX },
154 { 0x0738, 0x4506, "Mad Catz 4506 Wireless Controller", 0, XTYPE_XBOX },
162 { 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller", 0, XTYPE_XBOX },
163 { 0x0738, 0x4586, "Mad Catz MicroCon Wireless Controller", 0, XTYPE_XBOX },
166 { 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
168 { 0x0738, 0x4726, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 },
171 …{ 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX…
178 { 0x0738, 0xb726, "Mad Catz Xbox controller - MW2", 0, XTYPE_XBOX360 },
181 { 0x0738, 0xcb02, "Saitek Cyborg Rumble Pad - PC/Xbox 360", 0, XTYPE_XBOX360 },
182 { 0x0738, 0xcb03, "Saitek P3200 Rumble Pad - PC/Xbox 360", 0, XTYPE_XBOX360 },
187 { 0x0c12, 0x8801, "Nyko Xbox Controller", 0, XTYPE_XBOX },
188 { 0x0c12, 0x8802, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
190 { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", 0, XTYPE_XBOX },
191 { 0x0c12, 0x8810, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
192 { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", 0, XTYPE_XBOX },
194 { 0x0e4c, 0x1097, "Radica Gamester Controller", 0, XTYPE_XBOX },
196 { 0x0e4c, 0x2390, "Radica Games Jtech Controller", 0, XTYPE_XBOX },
198 { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", 0, XTYPE_XBOX },
199 { 0x0e6f, 0x0005, "Eclipse wireless Controller", 0, XTYPE_XBOX },
200 { 0x0e6f, 0x0006, "Edge wireless Controller", 0, XTYPE_XBOX },
201 { 0x0e6f, 0x0008, "After Glow Pro Controller", 0, XTYPE_XBOX },
204 { 0x0e6f, 0x011f, "Rock Candy Gamepad Wired Controller", 0, XTYPE_XBOX360 },
205 { 0x0e6f, 0x0131, "PDP EA Sports Controller", 0, XTYPE_XBOX360 },
206 { 0x0e6f, 0x0133, "Xbox 360 Wired Controller", 0, XTYPE_XBOX360 },
207 { 0x0e6f, 0x0139, "Afterglow Prismatic Wired Controller", 0, XTYPE_XBOXONE },
208 { 0x0e6f, 0x013a, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
209 { 0x0e6f, 0x0146, "Rock Candy Wired Controller for Xbox One", 0, XTYPE_XBOXONE },
210 { 0x0e6f, 0x0147, "PDP Marvel Xbox One Controller", 0, XTYPE_XBOXONE },
212 { 0x0e6f, 0x0161, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
213 { 0x0e6f, 0x0162, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
214 { 0x0e6f, 0x0163, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
217 { 0x0e6f, 0x0201, "Pelican PL-3601 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
221 { 0x0e6f, 0x02a0, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
222 { 0x0e6f, 0x02a1, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
223 { 0x0e6f, 0x02a2, "PDP Wired Controller for Xbox One - Crimson Red", 0, XTYPE_XBOXONE },
224 { 0x0e6f, 0x02a4, "PDP Wired Controller for Xbox One - Stealth Series", 0, XTYPE_XBOXONE },
225 { 0x0e6f, 0x02a6, "PDP Wired Controller for Xbox One - Camo Series", 0, XTYPE_XBOXONE },
226 { 0x0e6f, 0x02a7, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
227 { 0x0e6f, 0x02a8, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
228 { 0x0e6f, 0x02ab, "PDP Controller for Xbox One", 0, XTYPE_XBOXONE },
229 { 0x0e6f, 0x02ad, "PDP Wired Controller for Xbox One - Stealth Series", 0, XTYPE_XBOXONE },
230 { 0x0e6f, 0x02b3, "Afterglow Prismatic Wired Controller", 0, XTYPE_XBOXONE },
231 { 0x0e6f, 0x02b8, "Afterglow Prismatic Wired Controller", 0, XTYPE_XBOXONE },
232 { 0x0e6f, 0x0301, "Logic3 Controller", 0, XTYPE_XBOX360 },
234 { 0x0e6f, 0x0401, "Logic3 Controller", 0, XTYPE_XBOX360 },
236 { 0x0e6f, 0x0501, "PDP Xbox 360 Controller", 0, XTYPE_XBOX360 },
250 { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX },
251 { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX },
252 { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", 0, XTYPE_XBOX },
255 { 0x11c9, 0x55f0, "Nacon GC-100XF", 0, XTYPE_XBOX360 },
257 { 0x1209, 0x2882, "Ardwiino Controller", 0, XTYPE_XBOX360 },
262 { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", 0, XTYPE_XBOX360 },
264 { 0x1430, 0xf801, "RedOctane Controller", 0, XTYPE_XBOX360 },
265 { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 },
271 { 0x15e4, 0x3f0a, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 },
272 { 0x15e4, 0x3f10, "Batarang Xbox 360 controller", 0, XTYPE_XBOX360 },
273 { 0x162e, 0xbeef, "Joytech Neo-Se Take2", 0, XTYPE_XBOX360 },
280 { 0x1bad, 0xf016, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 },
284 { 0x1bad, 0xf023, "MLG Pro Circuit Controller (Xbox)", 0, XTYPE_XBOX360 },
294 …{ 0x1bad, 0xf03d, "Street Fighter IV Arcade Stick TE - Chun Li", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XB…
305 { 0x1bad, 0xf900, "Harmonix Xbox 360 Controller", 0, XTYPE_XBOX360 },
306 { 0x1bad, 0xf901, "Gamestop Xbox 360 Controller", 0, XTYPE_XBOX360 },
307 { 0x1bad, 0xf903, "Tron Xbox 360 controller", 0, XTYPE_XBOX360 },
313 { 0x20d6, 0x2001, "BDA Xbox Series X Wired Controller", 0, XTYPE_XBOXONE },
314 { 0x20d6, 0x2009, "PowerA Enhanced Wired Controller for Xbox Series X|S", 0, XTYPE_XBOXONE },
315 { 0x20d6, 0x281f, "PowerA Wired Controller For Xbox 360", 0, XTYPE_XBOX360 },
316 { 0x2e24, 0x0652, "Hyperkin Duke X-Box One pad", 0, XTYPE_XBOXONE },
318 { 0x24c6, 0x5300, "PowerA MINI PROEX Controller", 0, XTYPE_XBOX360 },
319 { 0x24c6, 0x5303, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 },
320 { 0x24c6, 0x530a, "Xbox 360 Pro EX Controller", 0, XTYPE_XBOX360 },
322 { 0x24c6, 0x5397, "FUS1ON Tournament Controller", 0, XTYPE_XBOX360 },
323 { 0x24c6, 0x541a, "PowerA Xbox One Mini Wired Controller", 0, XTYPE_XBOXONE },
325 { 0x24c6, 0x543a, "PowerA Xbox One wired controller", 0, XTYPE_XBOXONE },
327 { 0x24c6, 0x5501, "Hori Real Arcade Pro VX-SA", 0, XTYPE_XBOX360 },
332 { 0x24c6, 0x550d, "Hori GEM Xbox controller", 0, XTYPE_XBOX360 },
334 { 0x24c6, 0x551a, "PowerA FUSION Pro Controller", 0, XTYPE_XBOXONE },
335 { 0x24c6, 0x561a, "PowerA FUSION Controller", 0, XTYPE_XBOXONE },
337 { 0x24c6, 0x5b02, "Thrustmaster, Inc. GPX Controller", 0, XTYPE_XBOX360 },
342 { 0x2dc8, 0x2000, "8BitDo Pro 2 Wired Controller fox Xbox", 0, XTYPE_XBOXONE },
349 { 0x3285, 0x0607, "Nacon GC-100", 0, XTYPE_XBOX360 },
351 { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX },
352 { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
359 -1 /* terminating entry */
365 -1 /* terminating entry */
370 BTN_TRIGGER_HAPPY1, BTN_TRIGGER_HAPPY2, /* d-pad left, right */
371 BTN_TRIGGER_HAPPY3, BTN_TRIGGER_HAPPY4, /* d-pad up, down */
372 -1 /* terminating entry */
378 -1
381 static const signed short xpad360_btn[] = { /* buttons for x360 controller */
384 -1
390 -1 /* terminating entry */
395 ABS_HAT0X, ABS_HAT0Y, /* d-pad axes */
396 -1 /* terminating entry */
402 -1
406 * Xbox 360 has a vendor-specific class, so we cannot match it with only
421 /* The Xbox One controller uses subclass 71 and protocol 208. */
432 { USB_INTERFACE_INFO('X', 'B', 0) }, /* X-Box USB-IF not approved class */
433 XPAD_XBOX360_VENDOR(0x0079), /* GPD Win 2 Controller */
435 XPAD_XBOX360_VENDOR(0x044f), /* Thrustmaster X-Box 360 controllers */
437 XPAD_XBOX360_VENDOR(0x045e), /* Microsoft X-Box 360 controllers */
438 XPAD_XBOXONE_VENDOR(0x045e), /* Microsoft X-Box One controllers */
439 XPAD_XBOX360_VENDOR(0x046d), /* Logitech X-Box 360 style controllers */
440 XPAD_XBOX360_VENDOR(0x056e), /* Elecom JC-U3613M */
442 XPAD_XBOX360_VENDOR(0x0738), /* Mad Catz X-Box 360 controllers */
446 XPAD_XBOX360_VENDOR(0x0c12), /* Zeroplus X-Box 360 controllers */
447 XPAD_XBOX360_VENDOR(0x0e6f), /* 0x0e6f X-Box 360 controllers */
448 XPAD_XBOXONE_VENDOR(0x0e6f), /* 0x0e6f X-Box One controllers */
455 XPAD_XBOX360_VENDOR(0x12ab), /* X-Box 360 dance pads */
456 XPAD_XBOX360_VENDOR(0x1430), /* RedOctane X-Box 360 controllers */
460 XPAD_XBOX360_VENDOR(0x15e4), /* Numark X-Box 360 controllers */
461 XPAD_XBOX360_VENDOR(0x162e), /* Joytech X-Box 360 controllers */
470 XPAD_XBOXONE_VENDOR(0x2dc8), /* 8BitDo Pro 2 Wired Controller for Xbox */
471 XPAD_XBOXONE_VENDOR(0x2e24), /* Hyperkin Duke X-Box One pad */
474 XPAD_XBOX360_VENDOR(0x3285), /* Nacon GC-100 */
483 const u8 *data; member
491 .data = (_data), \
510 * initialize the controller that was previously used in
588 u8 data[XPAD_PKT_LEN]; member
610 unsigned char *idata; /* input data */
617 unsigned char *odata; /* output data */
631 int mapping; /* map d-pad to buttons or to axes */
645 * Completes a request by converting the data into events for the
649 * http://euc.jp/periphs/xbox-controller.ja.html
651 static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) in xpad_process_packet() argument
653 struct input_dev *dev = xpad->dev; in xpad_process_packet()
655 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad_process_packet()
658 (__s16) le16_to_cpup((__le16 *)(data + 12))); in xpad_process_packet()
660 ~(__s16) le16_to_cpup((__le16 *)(data + 14))); in xpad_process_packet()
664 (__s16) le16_to_cpup((__le16 *)(data + 16))); in xpad_process_packet()
666 ~(__s16) le16_to_cpup((__le16 *)(data + 18))); in xpad_process_packet()
670 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad_process_packet()
671 input_report_key(dev, BTN_TL2, data[10]); in xpad_process_packet()
672 input_report_key(dev, BTN_TR2, data[11]); in xpad_process_packet()
674 input_report_abs(dev, ABS_Z, data[10]); in xpad_process_packet()
675 input_report_abs(dev, ABS_RZ, data[11]); in xpad_process_packet()
679 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad_process_packet()
681 input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & 0x04); in xpad_process_packet()
682 input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08); in xpad_process_packet()
683 input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01); in xpad_process_packet()
684 input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02); in xpad_process_packet()
687 !!(data[2] & 0x08) - !!(data[2] & 0x04)); in xpad_process_packet()
689 !!(data[2] & 0x02) - !!(data[2] & 0x01)); in xpad_process_packet()
693 input_report_key(dev, BTN_START, data[2] & 0x10); in xpad_process_packet()
694 input_report_key(dev, BTN_SELECT, data[2] & 0x20); in xpad_process_packet()
695 input_report_key(dev, BTN_THUMBL, data[2] & 0x40); in xpad_process_packet()
696 input_report_key(dev, BTN_THUMBR, data[2] & 0x80); in xpad_process_packet()
699 input_report_key(dev, BTN_A, data[4]); in xpad_process_packet()
700 input_report_key(dev, BTN_B, data[5]); in xpad_process_packet()
701 input_report_key(dev, BTN_X, data[6]); in xpad_process_packet()
702 input_report_key(dev, BTN_Y, data[7]); in xpad_process_packet()
705 input_report_key(dev, BTN_C, data[8]); in xpad_process_packet()
706 input_report_key(dev, BTN_Z, data[9]); in xpad_process_packet()
714 * Completes a request by converting the data into events for the
715 * input subsystem. It is version for xbox 360 controller
722 u16 cmd, unsigned char *data) in xpad360_process_packet() argument
724 /* valid pad data */ in xpad360_process_packet()
725 if (data[0] != 0x00) in xpad360_process_packet()
729 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad360_process_packet()
731 input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & 0x04); in xpad360_process_packet()
732 input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08); in xpad360_process_packet()
733 input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01); in xpad360_process_packet()
734 input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02); in xpad360_process_packet()
743 if (!(xpad->mapping & MAP_DPAD_TO_BUTTONS) || in xpad360_process_packet()
744 xpad->xtype == XTYPE_XBOX360W) { in xpad360_process_packet()
746 !!(data[2] & 0x08) - !!(data[2] & 0x04)); in xpad360_process_packet()
748 !!(data[2] & 0x02) - !!(data[2] & 0x01)); in xpad360_process_packet()
752 input_report_key(dev, BTN_START, data[2] & 0x10); in xpad360_process_packet()
753 input_report_key(dev, BTN_SELECT, data[2] & 0x20); in xpad360_process_packet()
756 input_report_key(dev, BTN_THUMBL, data[2] & 0x40); in xpad360_process_packet()
757 input_report_key(dev, BTN_THUMBR, data[2] & 0x80); in xpad360_process_packet()
760 input_report_key(dev, BTN_A, data[3] & 0x10); in xpad360_process_packet()
761 input_report_key(dev, BTN_B, data[3] & 0x20); in xpad360_process_packet()
762 input_report_key(dev, BTN_X, data[3] & 0x40); in xpad360_process_packet()
763 input_report_key(dev, BTN_Y, data[3] & 0x80); in xpad360_process_packet()
764 input_report_key(dev, BTN_TL, data[3] & 0x01); in xpad360_process_packet()
765 input_report_key(dev, BTN_TR, data[3] & 0x02); in xpad360_process_packet()
766 input_report_key(dev, BTN_MODE, data[3] & 0x04); in xpad360_process_packet()
768 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad360_process_packet()
771 (__s16) le16_to_cpup((__le16 *)(data + 6))); in xpad360_process_packet()
773 ~(__s16) le16_to_cpup((__le16 *)(data + 8))); in xpad360_process_packet()
777 (__s16) le16_to_cpup((__le16 *)(data + 10))); in xpad360_process_packet()
779 ~(__s16) le16_to_cpup((__le16 *)(data + 12))); in xpad360_process_packet()
783 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad360_process_packet()
784 input_report_key(dev, BTN_TL2, data[4]); in xpad360_process_packet()
785 input_report_key(dev, BTN_TR2, data[5]); in xpad360_process_packet()
787 input_report_abs(dev, ABS_Z, data[4]); in xpad360_process_packet()
788 input_report_abs(dev, ABS_RZ, data[5]); in xpad360_process_packet()
799 if (xpad->pad_present) { in xpad_presence_work()
803 dev_err(&xpad->dev->dev, in xpad_presence_work()
806 rcu_assign_pointer(xpad->x360w_dev, xpad->dev); in xpad_presence_work()
809 RCU_INIT_POINTER(xpad->x360w_dev, NULL); in xpad_presence_work()
822 * Completes a request by converting the data into events for the
823 * input subsystem. It is version for xbox 360 wireless controller.
826 * 00.1 - Status change: The controller or headset has connected/disconnected
828 * 01.7 - Controller present
829 * 01.6 - Headset present
830 * 01.1 - Pad state (Bytes 4+) valid
833 static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) in xpad360w_process_packet() argument
839 if (data[0] & 0x08) { in xpad360w_process_packet()
840 present = (data[1] & 0x80) != 0; in xpad360w_process_packet()
842 if (xpad->pad_present != present) { in xpad360w_process_packet()
843 xpad->pad_present = present; in xpad360w_process_packet()
844 schedule_work(&xpad->work); in xpad360w_process_packet()
848 /* Valid pad data */ in xpad360w_process_packet()
849 if (data[1] != 0x1) in xpad360w_process_packet()
853 dev = rcu_dereference(xpad->x360w_dev); in xpad360w_process_packet()
855 xpad360_process_packet(xpad, dev, cmd, &data[4]); in xpad360w_process_packet()
862 * Completes a request by converting the data into events for the
863 * input subsystem. This version is for the Xbox One controller.
868 static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) in xpadone_process_packet() argument
870 struct input_dev *dev = xpad->dev; in xpadone_process_packet()
873 if (data[0] == 0X07) { in xpadone_process_packet()
875 * The Xbox One S controller requires these reports to be in xpadone_process_packet()
879 if (data[1] == 0x30) in xpadone_process_packet()
880 xpadone_ack_mode_report(xpad, data[2]); in xpadone_process_packet()
882 input_report_key(dev, BTN_MODE, data[4] & 0x01); in xpadone_process_packet()
887 else if (data[0] != 0X20) in xpadone_process_packet()
891 input_report_key(dev, BTN_START, data[4] & 0x04); in xpadone_process_packet()
892 input_report_key(dev, BTN_SELECT, data[4] & 0x08); in xpadone_process_packet()
895 input_report_key(dev, BTN_A, data[4] & 0x10); in xpadone_process_packet()
896 input_report_key(dev, BTN_B, data[4] & 0x20); in xpadone_process_packet()
897 input_report_key(dev, BTN_X, data[4] & 0x40); in xpadone_process_packet()
898 input_report_key(dev, BTN_Y, data[4] & 0x80); in xpadone_process_packet()
901 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpadone_process_packet()
903 input_report_key(dev, BTN_TRIGGER_HAPPY1, data[5] & 0x04); in xpadone_process_packet()
904 input_report_key(dev, BTN_TRIGGER_HAPPY2, data[5] & 0x08); in xpadone_process_packet()
905 input_report_key(dev, BTN_TRIGGER_HAPPY3, data[5] & 0x01); in xpadone_process_packet()
906 input_report_key(dev, BTN_TRIGGER_HAPPY4, data[5] & 0x02); in xpadone_process_packet()
909 !!(data[5] & 0x08) - !!(data[5] & 0x04)); in xpadone_process_packet()
911 !!(data[5] & 0x02) - !!(data[5] & 0x01)); in xpadone_process_packet()
915 input_report_key(dev, BTN_TL, data[5] & 0x10); in xpadone_process_packet()
916 input_report_key(dev, BTN_TR, data[5] & 0x20); in xpadone_process_packet()
919 input_report_key(dev, BTN_THUMBL, data[5] & 0x40); in xpadone_process_packet()
920 input_report_key(dev, BTN_THUMBR, data[5] & 0x80); in xpadone_process_packet()
922 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpadone_process_packet()
925 (__s16) le16_to_cpup((__le16 *)(data + 10))); in xpadone_process_packet()
927 ~(__s16) le16_to_cpup((__le16 *)(data + 12))); in xpadone_process_packet()
931 (__s16) le16_to_cpup((__le16 *)(data + 14))); in xpadone_process_packet()
933 ~(__s16) le16_to_cpup((__le16 *)(data + 16))); in xpadone_process_packet()
937 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpadone_process_packet()
939 (__u16) le16_to_cpup((__le16 *)(data + 6))); in xpadone_process_packet()
941 (__u16) le16_to_cpup((__le16 *)(data + 8))); in xpadone_process_packet()
944 (__u16) le16_to_cpup((__le16 *)(data + 6))); in xpadone_process_packet()
946 (__u16) le16_to_cpup((__le16 *)(data + 8))); in xpadone_process_packet()
954 struct usb_xpad *xpad = urb->context; in xpad_irq_in()
955 struct device *dev = &xpad->intf->dev; in xpad_irq_in()
958 status = urb->status; in xpad_irq_in()
964 case -ECONNRESET: in xpad_irq_in()
965 case -ENOENT: in xpad_irq_in()
966 case -ESHUTDOWN: in xpad_irq_in()
968 dev_dbg(dev, "%s - urb shutting down with status: %d\n", in xpad_irq_in()
972 dev_dbg(dev, "%s - nonzero urb status received: %d\n", in xpad_irq_in()
977 switch (xpad->xtype) { in xpad_irq_in()
979 xpad360_process_packet(xpad, xpad->dev, 0, xpad->idata); in xpad_irq_in()
982 xpad360w_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
985 xpadone_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
988 xpad_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
994 dev_err(dev, "%s - usb_submit_urb failed with result %d\n", in xpad_irq_in()
998 /* Callers must hold xpad->odata_lock spinlock */
1003 if (xpad->xtype != XTYPE_XBOXONE) in xpad_prepare_next_init_packet()
1007 while (xpad->init_seq < ARRAY_SIZE(xboxone_init_packets)) { in xpad_prepare_next_init_packet()
1008 init_packet = &xboxone_init_packets[xpad->init_seq++]; in xpad_prepare_next_init_packet()
1010 if (init_packet->idVendor != 0 && in xpad_prepare_next_init_packet()
1011 init_packet->idVendor != xpad->dev->id.vendor) in xpad_prepare_next_init_packet()
1014 if (init_packet->idProduct != 0 && in xpad_prepare_next_init_packet()
1015 init_packet->idProduct != xpad->dev->id.product) in xpad_prepare_next_init_packet()
1019 memcpy(xpad->odata, init_packet->data, init_packet->len); in xpad_prepare_next_init_packet()
1020 xpad->irq_out->transfer_buffer_length = init_packet->len; in xpad_prepare_next_init_packet()
1023 xpad->odata[2] = xpad->odata_serial++; in xpad_prepare_next_init_packet()
1030 /* Callers must hold xpad->odata_lock spinlock */
1041 if (++xpad->last_out_packet >= XPAD_NUM_OUT_PACKETS) in xpad_prepare_next_out_packet()
1042 xpad->last_out_packet = 0; in xpad_prepare_next_out_packet()
1044 pkt = &xpad->out_packets[xpad->last_out_packet]; in xpad_prepare_next_out_packet()
1045 if (pkt->pending) { in xpad_prepare_next_out_packet()
1046 dev_dbg(&xpad->intf->dev, in xpad_prepare_next_out_packet()
1047 "%s - found pending output packet %d\n", in xpad_prepare_next_out_packet()
1048 __func__, xpad->last_out_packet); in xpad_prepare_next_out_packet()
1055 memcpy(xpad->odata, packet->data, packet->len); in xpad_prepare_next_out_packet()
1056 xpad->irq_out->transfer_buffer_length = packet->len; in xpad_prepare_next_out_packet()
1057 packet->pending = false; in xpad_prepare_next_out_packet()
1064 /* Callers must hold xpad->odata_lock spinlock */
1069 if (!xpad->irq_out_active && xpad_prepare_next_out_packet(xpad)) { in xpad_try_sending_next_out_packet()
1070 usb_anchor_urb(xpad->irq_out, &xpad->irq_out_anchor); in xpad_try_sending_next_out_packet()
1071 error = usb_submit_urb(xpad->irq_out, GFP_ATOMIC); in xpad_try_sending_next_out_packet()
1073 dev_err(&xpad->intf->dev, in xpad_try_sending_next_out_packet()
1074 "%s - usb_submit_urb failed with result %d\n", in xpad_try_sending_next_out_packet()
1076 usb_unanchor_urb(xpad->irq_out); in xpad_try_sending_next_out_packet()
1077 return -EIO; in xpad_try_sending_next_out_packet()
1080 xpad->irq_out_active = true; in xpad_try_sending_next_out_packet()
1088 struct usb_xpad *xpad = urb->context; in xpad_irq_out()
1089 struct device *dev = &xpad->intf->dev; in xpad_irq_out()
1090 int status = urb->status; in xpad_irq_out()
1094 spin_lock_irqsave(&xpad->odata_lock, flags); in xpad_irq_out()
1099 xpad->irq_out_active = xpad_prepare_next_out_packet(xpad); in xpad_irq_out()
1102 case -ECONNRESET: in xpad_irq_out()
1103 case -ENOENT: in xpad_irq_out()
1104 case -ESHUTDOWN: in xpad_irq_out()
1106 dev_dbg(dev, "%s - urb shutting down with status: %d\n", in xpad_irq_out()
1108 xpad->irq_out_active = false; in xpad_irq_out()
1112 dev_dbg(dev, "%s - nonzero urb status received: %d\n", in xpad_irq_out()
1117 if (xpad->irq_out_active) { in xpad_irq_out()
1118 usb_anchor_urb(urb, &xpad->irq_out_anchor); in xpad_irq_out()
1122 "%s - usb_submit_urb failed with result %d\n", in xpad_irq_out()
1125 xpad->irq_out_active = false; in xpad_irq_out()
1129 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpad_irq_out()
1137 if (xpad->xtype == XTYPE_UNKNOWN) in xpad_init_output()
1140 init_usb_anchor(&xpad->irq_out_anchor); in xpad_init_output()
1142 xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_init_output()
1143 GFP_KERNEL, &xpad->odata_dma); in xpad_init_output()
1144 if (!xpad->odata) in xpad_init_output()
1145 return -ENOMEM; in xpad_init_output()
1147 spin_lock_init(&xpad->odata_lock); in xpad_init_output()
1149 xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL); in xpad_init_output()
1150 if (!xpad->irq_out) { in xpad_init_output()
1151 error = -ENOMEM; in xpad_init_output()
1155 usb_fill_int_urb(xpad->irq_out, xpad->udev, in xpad_init_output()
1156 usb_sndintpipe(xpad->udev, ep_irq_out->bEndpointAddress), in xpad_init_output()
1157 xpad->odata, XPAD_PKT_LEN, in xpad_init_output()
1158 xpad_irq_out, xpad, ep_irq_out->bInterval); in xpad_init_output()
1159 xpad->irq_out->transfer_dma = xpad->odata_dma; in xpad_init_output()
1160 xpad->irq_out->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in xpad_init_output()
1165 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma); in xpad_init_output()
1171 if (xpad->xtype != XTYPE_UNKNOWN) { in xpad_stop_output()
1172 if (!usb_wait_anchor_empty_timeout(&xpad->irq_out_anchor, in xpad_stop_output()
1174 dev_warn(&xpad->intf->dev, in xpad_stop_output()
1176 usb_kill_anchored_urbs(&xpad->irq_out_anchor); in xpad_stop_output()
1183 if (xpad->xtype != XTYPE_UNKNOWN) { in xpad_deinit_output()
1184 usb_free_urb(xpad->irq_out); in xpad_deinit_output()
1185 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_deinit_output()
1186 xpad->odata, xpad->odata_dma); in xpad_deinit_output()
1193 &xpad->out_packets[XPAD_OUT_CMD_IDX]; in xpad_inquiry_pad_presence()
1197 spin_lock_irqsave(&xpad->odata_lock, flags); in xpad_inquiry_pad_presence()
1199 packet->data[0] = 0x08; in xpad_inquiry_pad_presence()
1200 packet->data[1] = 0x00; in xpad_inquiry_pad_presence()
1201 packet->data[2] = 0x0F; in xpad_inquiry_pad_presence()
1202 packet->data[3] = 0xC0; in xpad_inquiry_pad_presence()
1203 packet->data[4] = 0x00; in xpad_inquiry_pad_presence()
1204 packet->data[5] = 0x00; in xpad_inquiry_pad_presence()
1205 packet->data[6] = 0x00; in xpad_inquiry_pad_presence()
1206 packet->data[7] = 0x00; in xpad_inquiry_pad_presence()
1207 packet->data[8] = 0x00; in xpad_inquiry_pad_presence()
1208 packet->data[9] = 0x00; in xpad_inquiry_pad_presence()
1209 packet->data[10] = 0x00; in xpad_inquiry_pad_presence()
1210 packet->data[11] = 0x00; in xpad_inquiry_pad_presence()
1211 packet->len = 12; in xpad_inquiry_pad_presence()
1212 packet->pending = true; in xpad_inquiry_pad_presence()
1215 xpad->last_out_packet = -1; in xpad_inquiry_pad_presence()
1218 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpad_inquiry_pad_presence()
1228 spin_lock_irqsave(&xpad->odata_lock, flags); in xpad_start_xbox_one()
1235 xpad->init_seq = 0; in xpad_start_xbox_one()
1238 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpad_start_xbox_one()
1247 &xpad->out_packets[XPAD_OUT_CMD_IDX]; in xpadone_ack_mode_report()
1253 spin_lock_irqsave(&xpad->odata_lock, flags); in xpadone_ack_mode_report()
1255 packet->len = sizeof(mode_report_ack); in xpadone_ack_mode_report()
1256 memcpy(packet->data, mode_report_ack, packet->len); in xpadone_ack_mode_report()
1257 packet->data[2] = seq_num; in xpadone_ack_mode_report()
1258 packet->pending = true; in xpadone_ack_mode_report()
1261 xpad->last_out_packet = -1; in xpadone_ack_mode_report()
1264 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpadone_ack_mode_report()
1268 static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect) in xpad_play_effect() argument
1271 struct xpad_output_packet *packet = &xpad->out_packets[XPAD_OUT_FF_IDX]; in xpad_play_effect()
1277 if (effect->type != FF_RUMBLE) in xpad_play_effect()
1280 strong = effect->u.rumble.strong_magnitude; in xpad_play_effect()
1281 weak = effect->u.rumble.weak_magnitude; in xpad_play_effect()
1283 spin_lock_irqsave(&xpad->odata_lock, flags); in xpad_play_effect()
1285 switch (xpad->xtype) { in xpad_play_effect()
1287 packet->data[0] = 0x00; in xpad_play_effect()
1288 packet->data[1] = 0x06; in xpad_play_effect()
1289 packet->data[2] = 0x00; in xpad_play_effect()
1290 packet->data[3] = strong / 256; /* left actuator */ in xpad_play_effect()
1291 packet->data[4] = 0x00; in xpad_play_effect()
1292 packet->data[5] = weak / 256; /* right actuator */ in xpad_play_effect()
1293 packet->len = 6; in xpad_play_effect()
1294 packet->pending = true; in xpad_play_effect()
1298 packet->data[0] = 0x00; in xpad_play_effect()
1299 packet->data[1] = 0x08; in xpad_play_effect()
1300 packet->data[2] = 0x00; in xpad_play_effect()
1301 packet->data[3] = strong / 256; /* left actuator? */ in xpad_play_effect()
1302 packet->data[4] = weak / 256; /* right actuator? */ in xpad_play_effect()
1303 packet->data[5] = 0x00; in xpad_play_effect()
1304 packet->data[6] = 0x00; in xpad_play_effect()
1305 packet->data[7] = 0x00; in xpad_play_effect()
1306 packet->len = 8; in xpad_play_effect()
1307 packet->pending = true; in xpad_play_effect()
1311 packet->data[0] = 0x00; in xpad_play_effect()
1312 packet->data[1] = 0x01; in xpad_play_effect()
1313 packet->data[2] = 0x0F; in xpad_play_effect()
1314 packet->data[3] = 0xC0; in xpad_play_effect()
1315 packet->data[4] = 0x00; in xpad_play_effect()
1316 packet->data[5] = strong / 256; in xpad_play_effect()
1317 packet->data[6] = weak / 256; in xpad_play_effect()
1318 packet->data[7] = 0x00; in xpad_play_effect()
1319 packet->data[8] = 0x00; in xpad_play_effect()
1320 packet->data[9] = 0x00; in xpad_play_effect()
1321 packet->data[10] = 0x00; in xpad_play_effect()
1322 packet->data[11] = 0x00; in xpad_play_effect()
1323 packet->len = 12; in xpad_play_effect()
1324 packet->pending = true; in xpad_play_effect()
1328 packet->data[0] = 0x09; /* activate rumble */ in xpad_play_effect()
1329 packet->data[1] = 0x00; in xpad_play_effect()
1330 packet->data[2] = xpad->odata_serial++; in xpad_play_effect()
1331 packet->data[3] = 0x09; in xpad_play_effect()
1332 packet->data[4] = 0x00; in xpad_play_effect()
1333 packet->data[5] = 0x0F; in xpad_play_effect()
1334 packet->data[6] = 0x00; in xpad_play_effect()
1335 packet->data[7] = 0x00; in xpad_play_effect()
1336 packet->data[8] = strong / 512; /* left actuator */ in xpad_play_effect()
1337 packet->data[9] = weak / 512; /* right actuator */ in xpad_play_effect()
1338 packet->data[10] = 0xFF; /* on period */ in xpad_play_effect()
1339 packet->data[11] = 0x00; /* off period */ in xpad_play_effect()
1340 packet->data[12] = 0xFF; /* repeat count */ in xpad_play_effect()
1341 packet->len = 13; in xpad_play_effect()
1342 packet->pending = true; in xpad_play_effect()
1346 dev_dbg(&xpad->dev->dev, in xpad_play_effect()
1347 "%s - rumble command sent to unsupported xpad type: %d\n", in xpad_play_effect()
1348 __func__, xpad->xtype); in xpad_play_effect()
1349 retval = -EINVAL; in xpad_play_effect()
1356 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpad_play_effect()
1362 if (xpad->xtype == XTYPE_UNKNOWN) in xpad_init_ff()
1365 input_set_capability(xpad->dev, EV_FF, FF_RUMBLE); in xpad_init_ff()
1367 return input_ff_create_memless(xpad->dev, NULL, xpad_play_effect); in xpad_init_ff()
1391 * 2: 1/top-left blink, then on
1392 * 3: 2/top-right blink, then on
1393 * 4: 3/bottom-left blink, then on
1394 * 5: 4/bottom-right blink, then on
1395 * 6: 1/top-left on
1396 * 7: 2/top-right on
1397 * 8: 3/bottom-left on
1398 * 9: 4/bottom-right on
1409 &xpad->out_packets[XPAD_OUT_LED_IDX]; in xpad_send_led_command()
1414 spin_lock_irqsave(&xpad->odata_lock, flags); in xpad_send_led_command()
1416 switch (xpad->xtype) { in xpad_send_led_command()
1418 packet->data[0] = 0x01; in xpad_send_led_command()
1419 packet->data[1] = 0x03; in xpad_send_led_command()
1420 packet->data[2] = command; in xpad_send_led_command()
1421 packet->len = 3; in xpad_send_led_command()
1422 packet->pending = true; in xpad_send_led_command()
1426 packet->data[0] = 0x00; in xpad_send_led_command()
1427 packet->data[1] = 0x00; in xpad_send_led_command()
1428 packet->data[2] = 0x08; in xpad_send_led_command()
1429 packet->data[3] = 0x40 + command; in xpad_send_led_command()
1430 packet->data[4] = 0x00; in xpad_send_led_command()
1431 packet->data[5] = 0x00; in xpad_send_led_command()
1432 packet->data[6] = 0x00; in xpad_send_led_command()
1433 packet->data[7] = 0x00; in xpad_send_led_command()
1434 packet->data[8] = 0x00; in xpad_send_led_command()
1435 packet->data[9] = 0x00; in xpad_send_led_command()
1436 packet->data[10] = 0x00; in xpad_send_led_command()
1437 packet->data[11] = 0x00; in xpad_send_led_command()
1438 packet->len = 12; in xpad_send_led_command()
1439 packet->pending = true; in xpad_send_led_command()
1445 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpad_send_led_command()
1454 led_set_brightness(&xpad->led->led_cdev, (xpad->pad_nr % 4) + 2); in xpad_identify_controller()
1463 xpad_send_led_command(xpad_led->xpad, value); in xpad_led_set()
1472 if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX360W) in xpad_led_probe()
1475 xpad->led = led = kzalloc(sizeof(struct xpad_led), GFP_KERNEL); in xpad_led_probe()
1477 return -ENOMEM; in xpad_led_probe()
1479 xpad->pad_nr = ida_simple_get(&xpad_pad_seq, 0, 0, GFP_KERNEL); in xpad_led_probe()
1480 if (xpad->pad_nr < 0) { in xpad_led_probe()
1481 error = xpad->pad_nr; in xpad_led_probe()
1485 snprintf(led->name, sizeof(led->name), "xpad%d", xpad->pad_nr); in xpad_led_probe()
1486 led->xpad = xpad; in xpad_led_probe()
1488 led_cdev = &led->led_cdev; in xpad_led_probe()
1489 led_cdev->name = led->name; in xpad_led_probe()
1490 led_cdev->brightness_set = xpad_led_set; in xpad_led_probe()
1491 led_cdev->flags = LED_CORE_SUSPENDRESUME; in xpad_led_probe()
1493 error = led_classdev_register(&xpad->udev->dev, led_cdev); in xpad_led_probe()
1502 ida_simple_remove(&xpad_pad_seq, xpad->pad_nr); in xpad_led_probe()
1505 xpad->led = NULL; in xpad_led_probe()
1511 struct xpad_led *xpad_led = xpad->led; in xpad_led_disconnect()
1514 led_classdev_unregister(&xpad_led->led_cdev); in xpad_led_disconnect()
1515 ida_simple_remove(&xpad_pad_seq, xpad->pad_nr); in xpad_led_disconnect()
1528 if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) in xpad_start_input()
1529 return -EIO; in xpad_start_input()
1531 if (xpad->xtype == XTYPE_XBOXONE) { in xpad_start_input()
1534 usb_kill_urb(xpad->irq_in); in xpad_start_input()
1544 usb_kill_urb(xpad->irq_in); in xpad_stop_input()
1551 &xpad->out_packets[XPAD_OUT_CMD_IDX]; in xpad360w_poweroff_controller()
1553 spin_lock_irqsave(&xpad->odata_lock, flags); in xpad360w_poweroff_controller()
1555 packet->data[0] = 0x00; in xpad360w_poweroff_controller()
1556 packet->data[1] = 0x00; in xpad360w_poweroff_controller()
1557 packet->data[2] = 0x08; in xpad360w_poweroff_controller()
1558 packet->data[3] = 0xC0; in xpad360w_poweroff_controller()
1559 packet->data[4] = 0x00; in xpad360w_poweroff_controller()
1560 packet->data[5] = 0x00; in xpad360w_poweroff_controller()
1561 packet->data[6] = 0x00; in xpad360w_poweroff_controller()
1562 packet->data[7] = 0x00; in xpad360w_poweroff_controller()
1563 packet->data[8] = 0x00; in xpad360w_poweroff_controller()
1564 packet->data[9] = 0x00; in xpad360w_poweroff_controller()
1565 packet->data[10] = 0x00; in xpad360w_poweroff_controller()
1566 packet->data[11] = 0x00; in xpad360w_poweroff_controller()
1567 packet->len = 12; in xpad360w_poweroff_controller()
1568 packet->pending = true; in xpad360w_poweroff_controller()
1571 xpad->last_out_packet = -1; in xpad360w_poweroff_controller()
1574 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpad360w_poweroff_controller()
1581 error = usb_submit_urb(xpad->irq_in, GFP_KERNEL); in xpad360w_start_input()
1583 return -EIO; in xpad360w_start_input()
1587 * This will force the controller to resend connection packets. in xpad360w_start_input()
1594 usb_kill_urb(xpad->irq_in); in xpad360w_start_input()
1603 usb_kill_urb(xpad->irq_in); in xpad360w_stop_input()
1606 flush_work(&xpad->work); in xpad360w_stop_input()
1632 input_set_abs_params(input_dev, abs, -32768, 32767, 16, 128); in xpad_set_up_abs()
1636 if (xpad->xtype == XTYPE_XBOXONE) in xpad_set_up_abs()
1642 case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */ in xpad_set_up_abs()
1643 input_set_abs_params(input_dev, abs, -1, 1, 0, 0); in xpad_set_up_abs()
1653 if (xpad->input_created) { in xpad_deinit_input()
1654 xpad->input_created = false; in xpad_deinit_input()
1656 input_unregister_device(xpad->dev); in xpad_deinit_input()
1667 return -ENOMEM; in xpad_init_input()
1669 xpad->dev = input_dev; in xpad_init_input()
1670 input_dev->name = xpad->name; in xpad_init_input()
1671 input_dev->phys = xpad->phys; in xpad_init_input()
1672 usb_to_input_id(xpad->udev, &input_dev->id); in xpad_init_input()
1674 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_init_input()
1676 input_dev->id.product = 0x02a1; in xpad_init_input()
1679 input_dev->dev.parent = &xpad->intf->dev; in xpad_init_input()
1683 if (xpad->xtype != XTYPE_XBOX360W) { in xpad_init_input()
1684 input_dev->open = xpad_open; in xpad_init_input()
1685 input_dev->close = xpad_close; in xpad_init_input()
1688 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad_init_input()
1698 /* set up model-specific ones */ in xpad_init_input()
1699 if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W || in xpad_init_input()
1700 xpad->xtype == XTYPE_XBOXONE) { in xpad_init_input()
1708 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad_init_input()
1720 if (!(xpad->mapping & MAP_DPAD_TO_BUTTONS) || in xpad_init_input()
1721 xpad->xtype == XTYPE_XBOX360W) { in xpad_init_input()
1726 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad_init_input()
1743 error = input_register_device(xpad->dev); in xpad_init_input()
1747 xpad->input_created = true; in xpad_init_input()
1766 if (intf->cur_altsetting->desc.bNumEndpoints != 2) in xpad_probe()
1767 return -ENODEV; in xpad_probe()
1770 if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && in xpad_probe()
1771 (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct)) in xpad_probe()
1777 return -ENOMEM; in xpad_probe()
1779 usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); in xpad_probe()
1780 strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); in xpad_probe()
1782 xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN, in xpad_probe()
1783 GFP_KERNEL, &xpad->idata_dma); in xpad_probe()
1784 if (!xpad->idata) { in xpad_probe()
1785 error = -ENOMEM; in xpad_probe()
1789 xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); in xpad_probe()
1790 if (!xpad->irq_in) { in xpad_probe()
1791 error = -ENOMEM; in xpad_probe()
1795 xpad->udev = udev; in xpad_probe()
1796 xpad->intf = intf; in xpad_probe()
1797 xpad->mapping = xpad_device[i].mapping; in xpad_probe()
1798 xpad->xtype = xpad_device[i].xtype; in xpad_probe()
1799 xpad->name = xpad_device[i].name; in xpad_probe()
1800 INIT_WORK(&xpad->work, xpad_presence_work); in xpad_probe()
1802 if (xpad->xtype == XTYPE_UNKNOWN) { in xpad_probe()
1803 if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) { in xpad_probe()
1804 if (intf->cur_altsetting->desc.bInterfaceProtocol == 129) in xpad_probe()
1805 xpad->xtype = XTYPE_XBOX360W; in xpad_probe()
1806 else if (intf->cur_altsetting->desc.bInterfaceProtocol == 208) in xpad_probe()
1807 xpad->xtype = XTYPE_XBOXONE; in xpad_probe()
1809 xpad->xtype = XTYPE_XBOX360; in xpad_probe()
1811 xpad->xtype = XTYPE_XBOX; in xpad_probe()
1815 xpad->mapping |= MAP_DPAD_TO_BUTTONS; in xpad_probe()
1817 xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS; in xpad_probe()
1819 xpad->mapping |= MAP_STICKS_TO_NULL; in xpad_probe()
1822 if (xpad->xtype == XTYPE_XBOXONE && in xpad_probe()
1823 intf->cur_altsetting->desc.bInterfaceNumber != GIP_WIRED_INTF_DATA) { in xpad_probe()
1825 * The Xbox One controller lists three interfaces all with the in xpad_probe()
1829 error = -ENODEV; in xpad_probe()
1837 &intf->cur_altsetting->endpoint[i].desc; in xpad_probe()
1848 error = -ENODEV; in xpad_probe()
1856 usb_fill_int_urb(xpad->irq_in, udev, in xpad_probe()
1857 usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), in xpad_probe()
1858 xpad->idata, XPAD_PKT_LEN, xpad_irq_in, in xpad_probe()
1859 xpad, ep_irq_in->bInterval); in xpad_probe()
1860 xpad->irq_in->transfer_dma = xpad->idata_dma; in xpad_probe()
1861 xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in xpad_probe()
1865 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_probe()
1870 * exactly the message that a controller has arrived that in xpad_probe()
1883 udev->quirks |= USB_QUIRK_RESET_RESUME; in xpad_probe()
1894 usb_free_urb(xpad->irq_in); in xpad_probe()
1896 usb_free_coherent(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); in xpad_probe()
1906 if (xpad->xtype == XTYPE_XBOX360W) in xpad_disconnect()
1919 usb_free_urb(xpad->irq_in); in xpad_disconnect()
1920 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_disconnect()
1921 xpad->idata, xpad->idata_dma); in xpad_disconnect()
1931 struct input_dev *input = xpad->dev; in xpad_suspend()
1933 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_suspend()
1936 * they are notified when controller shows up in xpad_suspend()
1947 if (auto_poweroff && xpad->pad_present) in xpad_suspend()
1950 mutex_lock(&input->mutex); in xpad_suspend()
1951 if (input->users) in xpad_suspend()
1953 mutex_unlock(&input->mutex); in xpad_suspend()
1964 struct input_dev *input = xpad->dev; in xpad_resume()
1967 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_resume()
1970 mutex_lock(&input->mutex); in xpad_resume()
1971 if (input->users) { in xpad_resume()
1973 } else if (xpad->xtype == XTYPE_XBOXONE) { in xpad_resume()
1981 mutex_unlock(&input->mutex); in xpad_resume()
1998 MODULE_AUTHOR("Marko Friedemann <mfr@bmx-chemnitz.de>");
1999 MODULE_DESCRIPTION("X-Box pad driver");