• Home
  • Raw
  • Download

Lines Matching +full:controller +full:- +full:data

1 // SPDX-License-Identifier: GPL-2.0-or-later
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 IDs
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
77 * xbox d-pads should map to buttons, as is required for DDR pads
97 /* Send power-off packet to xpad360w after holding the mode button for this many
110 MODULE_PARM_DESC(dpad_to_buttons, "Map D-PAD to buttons rather than axes for unknown pads");
132 { 0x0079, 0x18d4, "GPD Win 2 X-Box Controller", 0, XTYPE_XBOX360 },
143 { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX },
147 { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", 0, XTYPE_XBOX },
148 { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX },
149 { 0x045e, 0x0287, "Microsoft Xbox Controller S", 0, XTYPE_XBOX },
150 { 0x045e, 0x0288, "Microsoft Xbox Controller S v2", 0, XTYPE_XBOX },
151 { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", 0, XTYPE_XBOX },
152 { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 },
153 { 0x045e, 0x028f, "Microsoft X-Box 360 pad v2", 0, XTYPE_XBOX360 },
156 { 0x045e, 0x02d1, "Microsoft X-Box One pad", 0, XTYPE_XBOXONE },
157 { 0x045e, 0x02dd, "Microsoft X-Box One pad (Firmware 2015)", 0, XTYPE_XBOXONE },
158 { 0x045e, 0x02e3, "Microsoft X-Box One Elite pad", MAP_PADDLES, XTYPE_XBOXONE },
159 { 0x045e, 0x02ea, "Microsoft X-Box One S pad", 0, XTYPE_XBOXONE },
161 { 0x045e, 0x0b00, "Microsoft X-Box One Elite 2 pad", MAP_PADDLES, XTYPE_XBOXONE },
162 { 0x045e, 0x0b0a, "Microsoft X-Box Adaptive Controller", MAP_PROFILE_BUTTON, XTYPE_XBOXONE },
163 …{ 0x045e, 0x0b12, "Microsoft Xbox Series S|X Controller", MAP_SHARE_BUTTON | MAP_SHARE_OFFSET, XTY…
167 { 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 },
168 { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX },
169 { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", 0, XTYPE_XBOX },
173 { 0x056e, 0x2004, "Elecom JC-U3613M", 0, XTYPE_XBOX360 },
174 { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", 0, XTYPE_XBOX },
175 { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", 0, XTYPE_XBOX },
176 { 0x05fe, 0x3030, "Chic Controller", 0, XTYPE_XBOX },
177 { 0x05fe, 0x3031, "Chic Controller", 0, XTYPE_XBOX },
184 { 0x0738, 0x4506, "Mad Catz 4506 Wireless Controller", 0, XTYPE_XBOX },
192 { 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller", 0, XTYPE_XBOX },
193 { 0x0738, 0x4586, "Mad Catz MicroCon Wireless Controller", 0, XTYPE_XBOX },
196 { 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
198 { 0x0738, 0x4726, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 },
201 …{ 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX…
208 { 0x0738, 0xb726, "Mad Catz Xbox controller - MW2", 0, XTYPE_XBOX360 },
211 { 0x0738, 0xcb02, "Saitek Cyborg Rumble Pad - PC/Xbox 360", 0, XTYPE_XBOX360 },
212 { 0x0738, 0xcb03, "Saitek P3200 Rumble Pad - PC/Xbox 360", 0, XTYPE_XBOX360 },
219 { 0x0c12, 0x8801, "Nyko Xbox Controller", 0, XTYPE_XBOX },
220 { 0x0c12, 0x8802, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
222 { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", 0, XTYPE_XBOX },
223 { 0x0c12, 0x8810, "Zeroplus Xbox Controller", 0, XTYPE_XBOX },
224 { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", 0, XTYPE_XBOX },
226 { 0x0db0, 0x1901, "Micro Star International Xbox360 Controller for Windows", 0, XTYPE_XBOX360 },
227 { 0x0e4c, 0x1097, "Radica Gamester Controller", 0, XTYPE_XBOX },
229 { 0x0e4c, 0x2390, "Radica Games Jtech Controller", 0, XTYPE_XBOX },
231 { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", 0, XTYPE_XBOX },
232 { 0x0e6f, 0x0005, "Eclipse wireless Controller", 0, XTYPE_XBOX },
233 { 0x0e6f, 0x0006, "Edge wireless Controller", 0, XTYPE_XBOX },
234 { 0x0e6f, 0x0008, "After Glow Pro Controller", 0, XTYPE_XBOX },
237 { 0x0e6f, 0x011f, "Rock Candy Gamepad Wired Controller", 0, XTYPE_XBOX360 },
238 { 0x0e6f, 0x0131, "PDP EA Sports Controller", 0, XTYPE_XBOX360 },
239 { 0x0e6f, 0x0133, "Xbox 360 Wired Controller", 0, XTYPE_XBOX360 },
240 { 0x0e6f, 0x0139, "Afterglow Prismatic Wired Controller", 0, XTYPE_XBOXONE },
241 { 0x0e6f, 0x013a, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
242 { 0x0e6f, 0x0146, "Rock Candy Wired Controller for Xbox One", 0, XTYPE_XBOXONE },
243 { 0x0e6f, 0x0147, "PDP Marvel Xbox One Controller", 0, XTYPE_XBOXONE },
245 { 0x0e6f, 0x015d, "PDP Mirror's Edge Official Wired Controller for Xbox One", 0, XTYPE_XBOXONE },
246 { 0x0e6f, 0x0161, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
247 { 0x0e6f, 0x0162, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
248 { 0x0e6f, 0x0163, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
251 { 0x0e6f, 0x0201, "Pelican PL-3601 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 },
255 { 0x0e6f, 0x02a0, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
256 { 0x0e6f, 0x02a1, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
257 { 0x0e6f, 0x02a2, "PDP Wired Controller for Xbox One - Crimson Red", 0, XTYPE_XBOXONE },
258 { 0x0e6f, 0x02a4, "PDP Wired Controller for Xbox One - Stealth Series", 0, XTYPE_XBOXONE },
259 { 0x0e6f, 0x02a6, "PDP Wired Controller for Xbox One - Camo Series", 0, XTYPE_XBOXONE },
260 { 0x0e6f, 0x02a7, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
261 { 0x0e6f, 0x02a8, "PDP Xbox One Controller", 0, XTYPE_XBOXONE },
262 { 0x0e6f, 0x02ab, "PDP Controller for Xbox One", 0, XTYPE_XBOXONE },
263 { 0x0e6f, 0x02ad, "PDP Wired Controller for Xbox One - Stealth Series", 0, XTYPE_XBOXONE },
264 { 0x0e6f, 0x02b3, "Afterglow Prismatic Wired Controller", 0, XTYPE_XBOXONE },
265 { 0x0e6f, 0x02b8, "Afterglow Prismatic Wired Controller", 0, XTYPE_XBOXONE },
266 { 0x0e6f, 0x0301, "Logic3 Controller", 0, XTYPE_XBOX360 },
268 { 0x0e6f, 0x0401, "Logic3 Controller", 0, XTYPE_XBOX360 },
270 { 0x0e6f, 0x0501, "PDP Xbox 360 Controller", 0, XTYPE_XBOX360 },
287 { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX },
288 { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX },
289 { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", 0, XTYPE_XBOX },
292 { 0x10f5, 0x7005, "Turtle Beach Recon Controller", 0, XTYPE_XBOXONE },
293 { 0x10f5, 0x7008, "Turtle Beach Recon Controller", MAP_SHARE_BUTTON, XTYPE_XBOXONE },
294 { 0x10f5, 0x7073, "Turtle Beach Stealth Ultra Controller", MAP_SHARE_BUTTON, XTYPE_XBOXONE },
295 { 0x11c9, 0x55f0, "Nacon GC-100XF", 0, XTYPE_XBOX360 },
297 { 0x1209, 0x2882, "Ardwiino Controller", 0, XTYPE_XBOX360 },
302 { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", 0, XTYPE_XBOX360 },
304 { 0x1430, 0xf801, "RedOctane Controller", 0, XTYPE_XBOX360 },
305 { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", 0, XTYPE_XBOX360 },
311 { 0x15e4, 0x3f0a, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 },
312 { 0x15e4, 0x3f10, "Batarang Xbox 360 controller", 0, XTYPE_XBOX360 },
313 { 0x162e, 0xbeef, "Joytech Neo-Se Take2", 0, XTYPE_XBOX360 },
317 { 0x17ef, 0x6182, "Lenovo Legion Controller for Windows", 0, XTYPE_XBOX360 },
318 { 0x1949, 0x041a, "Amazon Game Controller", 0, XTYPE_XBOX360 },
323 { 0x1bad, 0xf016, "Mad Catz Xbox 360 Controller", 0, XTYPE_XBOX360 },
327 { 0x1bad, 0xf023, "MLG Pro Circuit Controller (Xbox)", 0, XTYPE_XBOX360 },
337 …{ 0x1bad, 0xf03d, "Street Fighter IV Arcade Stick TE - Chun Li", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XB…
348 { 0x1bad, 0xf900, "Harmonix Xbox 360 Controller", 0, XTYPE_XBOX360 },
349 { 0x1bad, 0xf901, "Gamestop Xbox 360 Controller", 0, XTYPE_XBOX360 },
350 { 0x1bad, 0xf903, "Tron Xbox 360 controller", 0, XTYPE_XBOX360 },
357 { 0x20d6, 0x2001, "BDA Xbox Series X Wired Controller", 0, XTYPE_XBOXONE },
358 { 0x20d6, 0x2009, "PowerA Enhanced Wired Controller for Xbox Series X|S", 0, XTYPE_XBOXONE },
359 { 0x20d6, 0x2064, "PowerA Wired Controller for Xbox", MAP_SHARE_BUTTON, XTYPE_XBOXONE },
360 { 0x20d6, 0x281f, "PowerA Wired Controller For Xbox 360", 0, XTYPE_XBOX360 },
362 { 0x24c6, 0x5300, "PowerA MINI PROEX Controller", 0, XTYPE_XBOX360 },
363 { 0x24c6, 0x5303, "Xbox Airflo wired controller", 0, XTYPE_XBOX360 },
364 { 0x24c6, 0x530a, "Xbox 360 Pro EX Controller", 0, XTYPE_XBOX360 },
366 { 0x24c6, 0x5397, "FUS1ON Tournament Controller", 0, XTYPE_XBOX360 },
367 { 0x24c6, 0x541a, "PowerA Xbox One Mini Wired Controller", 0, XTYPE_XBOXONE },
369 { 0x24c6, 0x543a, "PowerA Xbox One wired controller", 0, XTYPE_XBOXONE },
371 { 0x24c6, 0x5501, "Hori Real Arcade Pro VX-SA", 0, XTYPE_XBOX360 },
375 { 0x24c6, 0x550d, "Hori GEM Xbox controller", 0, XTYPE_XBOX360 },
378 { 0x24c6, 0x551a, "PowerA FUSION Pro Controller", 0, XTYPE_XBOXONE },
379 { 0x24c6, 0x561a, "PowerA FUSION Controller", 0, XTYPE_XBOXONE },
380 { 0x24c6, 0x581a, "ThrustMaster XB1 Classic Controller", 0, XTYPE_XBOXONE },
382 { 0x24c6, 0x5b02, "Thrustmaster, Inc. GPX Controller", 0, XTYPE_XBOX360 },
390 { 0x2dc8, 0x2000, "8BitDo Pro 2 Wired Controller fox Xbox", 0, XTYPE_XBOXONE },
391 { 0x2dc8, 0x3106, "8BitDo Ultimate Wireless / Pro 2 Wired Controller", 0, XTYPE_XBOX360 },
393 { 0x2dc8, 0x310a, "8BitDo Ultimate 2C Wireless Controller", 0, XTYPE_XBOX360 },
394 { 0x2dc8, 0x310b, "8BitDo Ultimate 2 Wireless Controller", 0, XTYPE_XBOX360 },
396 { 0x2e24, 0x0652, "Hyperkin Duke X-Box One pad", 0, XTYPE_XBOXONE },
397 { 0x2e24, 0x1688, "Hyperkin X91 X-Box One pad", 0, XTYPE_XBOXONE },
398 { 0x2e95, 0x0504, "SCUF Gaming Controller", MAP_SHARE_BUTTON, XTYPE_XBOXONE },
406 { 0x3285, 0x0603, "Nacon Pro Compact controller for Xbox", 0, XTYPE_XBOXONE },
407 { 0x3285, 0x0607, "Nacon GC-100", 0, XTYPE_XBOX360 },
411 { 0x3285, 0x0663, "Nacon Evol-X", 0, XTYPE_XBOXONE },
416 { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX },
417 { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN }
424 -1 /* terminating entry */
430 -1 /* terminating entry */
435 BTN_TRIGGER_HAPPY1, BTN_TRIGGER_HAPPY2, /* d-pad left, right */
436 BTN_TRIGGER_HAPPY3, BTN_TRIGGER_HAPPY4, /* d-pad up, down */
437 -1 /* terminating entry */
443 -1
446 static const signed short xpad360_btn[] = { /* buttons for x360 controller */
449 -1
455 -1 /* terminating entry */
460 ABS_HAT0X, ABS_HAT0Y, /* d-pad axes */
461 -1 /* terminating entry */
467 -1
470 /* used when the controller has extra paddle buttons */
474 -1 /* terminating entry */
478 * Xbox 360 has a vendor-specific class, so we cannot match it with only
493 /* The Xbox One controller uses subclass 71 and protocol 208. */
506 * macros - XPAD_XBOX360_VENDOR and XPAD_XBOXONE_VENDOR.
508 { USB_INTERFACE_INFO('X', 'B', 0) }, /* Xbox USB-IF not-approved class */
509 XPAD_XBOX360_VENDOR(0x0079), /* GPD Win 2 controller */
517 XPAD_XBOX360_VENDOR(0x046d), /* Logitech Xbox 360-style controllers */
519 XPAD_XBOX360_VENDOR(0x056e), /* Elecom JC-U3613M */
526 XPAD_XBOX360_VENDOR(0x0c12), /* Zeroplus X-Box 360 controllers */
527 XPAD_XBOX360_VENDOR(0x0db0), /* Micro Star International X-Box 360 controllers */
563 XPAD_XBOXONE_VENDOR(0x2e95), /* SCUF Gaming Controller */
565 XPAD_XBOX360_VENDOR(0x3285), /* Nacon GC-100 */
566 XPAD_XBOXONE_VENDOR(0x3285), /* Nacon Evol-X */
569 XPAD_XBOX360_VENDOR(0x413d), /* Black Shark Green Ghost Controller */
578 const u8 *data; member
586 .data = (_data), \
593 * - https://github.com/xpadneo/gip-dissector/blob/main/src/gip-dissector.lua
594 * - https://github.com/medusalix/xone/blob/master/bus/protocol.c
614 * which is a no-op for N < 128
644 * initialize the controller that was previously used in
652 * This packet is required to get additional input data
654 * We mostly do this right now to get paddle data
734 u8 data[XPAD_PKT_LEN]; member
756 unsigned char *idata; /* input data */
763 unsigned char *odata; /* output data */
777 int mapping; /* map d-pad to buttons or to axes */
794 * Completes a request by converting the data into events for the
798 * http://euc.jp/periphs/xbox-controller.ja.html
800 static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) in xpad_process_packet() argument
802 struct input_dev *dev = xpad->dev; in xpad_process_packet()
804 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad_process_packet()
807 (__s16) le16_to_cpup((__le16 *)(data + 12))); in xpad_process_packet()
809 ~(__s16) le16_to_cpup((__le16 *)(data + 14))); in xpad_process_packet()
813 (__s16) le16_to_cpup((__le16 *)(data + 16))); in xpad_process_packet()
815 ~(__s16) le16_to_cpup((__le16 *)(data + 18))); in xpad_process_packet()
819 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad_process_packet()
820 input_report_key(dev, BTN_TL2, data[10]); in xpad_process_packet()
821 input_report_key(dev, BTN_TR2, data[11]); in xpad_process_packet()
823 input_report_abs(dev, ABS_Z, data[10]); in xpad_process_packet()
824 input_report_abs(dev, ABS_RZ, data[11]); in xpad_process_packet()
828 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad_process_packet()
830 input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & BIT(2)); in xpad_process_packet()
831 input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & BIT(3)); in xpad_process_packet()
832 input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & BIT(0)); in xpad_process_packet()
833 input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & BIT(1)); in xpad_process_packet()
836 !!(data[2] & 0x08) - !!(data[2] & 0x04)); in xpad_process_packet()
838 !!(data[2] & 0x02) - !!(data[2] & 0x01)); in xpad_process_packet()
842 input_report_key(dev, BTN_START, data[2] & BIT(4)); in xpad_process_packet()
843 input_report_key(dev, BTN_SELECT, data[2] & BIT(5)); in xpad_process_packet()
844 input_report_key(dev, BTN_THUMBL, data[2] & BIT(6)); in xpad_process_packet()
845 input_report_key(dev, BTN_THUMBR, data[2] & BIT(7)); in xpad_process_packet()
848 input_report_key(dev, BTN_A, data[4]); in xpad_process_packet()
849 input_report_key(dev, BTN_B, data[5]); in xpad_process_packet()
850 input_report_key(dev, BTN_X, data[6]); in xpad_process_packet()
851 input_report_key(dev, BTN_Y, data[7]); in xpad_process_packet()
854 input_report_key(dev, BTN_C, data[8]); in xpad_process_packet()
855 input_report_key(dev, BTN_Z, data[9]); in xpad_process_packet()
864 * Completes a request by converting the data into events for the
865 * input subsystem. It is version for xbox 360 controller
872 u16 cmd, unsigned char *data) in xpad360_process_packet() argument
874 /* valid pad data */ in xpad360_process_packet()
875 if (data[0] != 0x00) in xpad360_process_packet()
879 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad360_process_packet()
881 input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & BIT(2)); in xpad360_process_packet()
882 input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & BIT(3)); in xpad360_process_packet()
883 input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & BIT(0)); in xpad360_process_packet()
884 input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & BIT(1)); in xpad360_process_packet()
893 if (!(xpad->mapping & MAP_DPAD_TO_BUTTONS) || in xpad360_process_packet()
894 xpad->xtype == XTYPE_XBOX360W) { in xpad360_process_packet()
896 !!(data[2] & 0x08) - !!(data[2] & 0x04)); in xpad360_process_packet()
898 !!(data[2] & 0x02) - !!(data[2] & 0x01)); in xpad360_process_packet()
902 input_report_key(dev, BTN_START, data[2] & BIT(4)); in xpad360_process_packet()
903 input_report_key(dev, BTN_SELECT, data[2] & BIT(5)); in xpad360_process_packet()
906 input_report_key(dev, BTN_THUMBL, data[2] & BIT(6)); in xpad360_process_packet()
907 input_report_key(dev, BTN_THUMBR, data[2] & BIT(7)); in xpad360_process_packet()
910 input_report_key(dev, BTN_A, data[3] & BIT(4)); in xpad360_process_packet()
911 input_report_key(dev, BTN_B, data[3] & BIT(5)); in xpad360_process_packet()
912 input_report_key(dev, BTN_X, data[3] & BIT(6)); in xpad360_process_packet()
913 input_report_key(dev, BTN_Y, data[3] & BIT(7)); in xpad360_process_packet()
914 input_report_key(dev, BTN_TL, data[3] & BIT(0)); in xpad360_process_packet()
915 input_report_key(dev, BTN_TR, data[3] & BIT(1)); in xpad360_process_packet()
916 input_report_key(dev, BTN_MODE, data[3] & BIT(2)); in xpad360_process_packet()
918 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad360_process_packet()
921 (__s16) le16_to_cpup((__le16 *)(data + 6))); in xpad360_process_packet()
923 ~(__s16) le16_to_cpup((__le16 *)(data + 8))); in xpad360_process_packet()
927 (__s16) le16_to_cpup((__le16 *)(data + 10))); in xpad360_process_packet()
929 ~(__s16) le16_to_cpup((__le16 *)(data + 12))); in xpad360_process_packet()
933 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad360_process_packet()
934 input_report_key(dev, BTN_TL2, data[4]); in xpad360_process_packet()
935 input_report_key(dev, BTN_TR2, data[5]); in xpad360_process_packet()
937 input_report_abs(dev, ABS_Z, data[4]); in xpad360_process_packet()
938 input_report_abs(dev, ABS_RZ, data[5]); in xpad360_process_packet()
944 if (xpad->xtype == XTYPE_XBOX360W) { in xpad360_process_packet()
945 if (xpad->mode_btn_down_ts > 0 && xpad->pad_present && in xpad360_process_packet()
946 ((ktime_get_seconds() - xpad->mode_btn_down_ts) >= in xpad360_process_packet()
949 xpad->mode_btn_down_ts = 0; in xpad360_process_packet()
954 if (data[3] & BIT(2)) in xpad360_process_packet()
955 xpad->mode_btn_down_ts = ktime_get_seconds(); in xpad360_process_packet()
957 xpad->mode_btn_down_ts = 0; in xpad360_process_packet()
966 if (xpad->pad_present) { in xpad_presence_work()
970 dev_err(&xpad->dev->dev, in xpad_presence_work()
973 rcu_assign_pointer(xpad->x360w_dev, xpad->dev); in xpad_presence_work()
976 RCU_INIT_POINTER(xpad->x360w_dev, NULL); in xpad_presence_work()
989 * Completes a request by converting the data into events for the
990 * input subsystem. It is version for xbox 360 wireless controller.
993 * 00.1 - Status change: The controller or headset has connected/disconnected
995 * 01.7 - Controller present
996 * 01.6 - Headset present
997 * 01.1 - Pad state (Bytes 4+) valid
1000 static void xpad360w_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data) in xpad360w_process_packet() argument
1006 if (data[0] & 0x08) { in xpad360w_process_packet()
1007 present = (data[1] & 0x80) != 0; in xpad360w_process_packet()
1009 if (xpad->pad_present != present) { in xpad360w_process_packet()
1010 xpad->pad_present = present; in xpad360w_process_packet()
1011 schedule_work(&xpad->work); in xpad360w_process_packet()
1015 /* Valid pad data */ in xpad360w_process_packet()
1016 if (data[1] != 0x1) in xpad360w_process_packet()
1020 dev = rcu_dereference(xpad->x360w_dev); in xpad360w_process_packet()
1022 xpad360_process_packet(xpad, dev, cmd, &data[4]); in xpad360w_process_packet()
1029 * Completes a request by converting the data into events for the
1030 * input subsystem. This version is for the Xbox One controller.
1035 static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *data, u32 len) in xpadone_process_packet() argument
1037 struct input_dev *dev = xpad->dev; in xpadone_process_packet()
1041 if (data[0] == GIP_CMD_VIRTUAL_KEY) { in xpadone_process_packet()
1043 * The Xbox One S controller requires these reports to be in xpadone_process_packet()
1047 if (data[1] == (GIP_OPT_ACK | GIP_OPT_INTERNAL)) in xpadone_process_packet()
1048 xpadone_ack_mode_report(xpad, data[2]); in xpadone_process_packet()
1050 input_report_key(dev, BTN_MODE, data[4] & GENMASK(1, 0)); in xpadone_process_packet()
1054 } else if (data[0] == GIP_CMD_FIRMWARE) { in xpadone_process_packet()
1056 if (xpad->packet_type == PKT_XBE2_FW_5_11) { in xpadone_process_packet()
1057 /* Mute paddles if controller is in a custom profile slot in xpadone_process_packet()
1061 if (data[19] != 0) in xpadone_process_packet()
1062 data[18] = 0; in xpadone_process_packet()
1065 input_report_key(dev, BTN_TRIGGER_HAPPY5, data[18] & BIT(0)); in xpadone_process_packet()
1066 input_report_key(dev, BTN_TRIGGER_HAPPY6, data[18] & BIT(1)); in xpadone_process_packet()
1067 input_report_key(dev, BTN_TRIGGER_HAPPY7, data[18] & BIT(2)); in xpadone_process_packet()
1068 input_report_key(dev, BTN_TRIGGER_HAPPY8, data[18] & BIT(3)); in xpadone_process_packet()
1072 } else if (data[0] == GIP_CMD_INPUT) { /* The main valid packet type for inputs */ in xpadone_process_packet()
1074 input_report_key(dev, BTN_START, data[4] & BIT(2)); in xpadone_process_packet()
1075 input_report_key(dev, BTN_SELECT, data[4] & BIT(3)); in xpadone_process_packet()
1076 if (xpad->mapping & MAP_SHARE_BUTTON) { in xpadone_process_packet()
1077 if (xpad->mapping & MAP_SHARE_OFFSET) in xpadone_process_packet()
1078 input_report_key(dev, KEY_RECORD, data[len - 26] & BIT(0)); in xpadone_process_packet()
1080 input_report_key(dev, KEY_RECORD, data[len - 18] & BIT(0)); in xpadone_process_packet()
1084 input_report_key(dev, BTN_A, data[4] & BIT(4)); in xpadone_process_packet()
1085 input_report_key(dev, BTN_B, data[4] & BIT(5)); in xpadone_process_packet()
1086 input_report_key(dev, BTN_X, data[4] & BIT(6)); in xpadone_process_packet()
1087 input_report_key(dev, BTN_Y, data[4] & BIT(7)); in xpadone_process_packet()
1090 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpadone_process_packet()
1092 input_report_key(dev, BTN_TRIGGER_HAPPY1, data[5] & BIT(2)); in xpadone_process_packet()
1093 input_report_key(dev, BTN_TRIGGER_HAPPY2, data[5] & BIT(3)); in xpadone_process_packet()
1094 input_report_key(dev, BTN_TRIGGER_HAPPY3, data[5] & BIT(0)); in xpadone_process_packet()
1095 input_report_key(dev, BTN_TRIGGER_HAPPY4, data[5] & BIT(1)); in xpadone_process_packet()
1098 !!(data[5] & 0x08) - !!(data[5] & 0x04)); in xpadone_process_packet()
1100 !!(data[5] & 0x02) - !!(data[5] & 0x01)); in xpadone_process_packet()
1104 input_report_key(dev, BTN_TL, data[5] & BIT(4)); in xpadone_process_packet()
1105 input_report_key(dev, BTN_TR, data[5] & BIT(5)); in xpadone_process_packet()
1108 input_report_key(dev, BTN_THUMBL, data[5] & BIT(6)); in xpadone_process_packet()
1109 input_report_key(dev, BTN_THUMBR, data[5] & BIT(7)); in xpadone_process_packet()
1111 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpadone_process_packet()
1114 (__s16) le16_to_cpup((__le16 *)(data + 10))); in xpadone_process_packet()
1116 ~(__s16) le16_to_cpup((__le16 *)(data + 12))); in xpadone_process_packet()
1120 (__s16) le16_to_cpup((__le16 *)(data + 14))); in xpadone_process_packet()
1122 ~(__s16) le16_to_cpup((__le16 *)(data + 16))); in xpadone_process_packet()
1126 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpadone_process_packet()
1128 (__u16) le16_to_cpup((__le16 *)(data + 6))); in xpadone_process_packet()
1130 (__u16) le16_to_cpup((__le16 *)(data + 8))); in xpadone_process_packet()
1133 (__u16) le16_to_cpup((__le16 *)(data + 6))); in xpadone_process_packet()
1135 (__u16) le16_to_cpup((__le16 *)(data + 8))); in xpadone_process_packet()
1138 /* Profile button has a value of 0-3, so it is reported as an axis */ in xpadone_process_packet()
1139 if (xpad->mapping & MAP_PROFILE_BUTTON) in xpadone_process_packet()
1140 input_report_abs(dev, ABS_PROFILE, data[34]); in xpadone_process_packet()
1144 if (xpad->mapping & MAP_PADDLES) { in xpadone_process_packet()
1145 if (xpad->packet_type == PKT_XBE1) { in xpadone_process_packet()
1146 /* Mute paddles if controller has a custom mapping applied. in xpadone_process_packet()
1150 if (memcmp(&data[4], &data[18], 2) != 0) in xpadone_process_packet()
1151 data[32] = 0; in xpadone_process_packet()
1153 /* OG Elite Series Controller paddle bits */ in xpadone_process_packet()
1154 input_report_key(dev, BTN_TRIGGER_HAPPY5, data[32] & BIT(1)); in xpadone_process_packet()
1155 input_report_key(dev, BTN_TRIGGER_HAPPY6, data[32] & BIT(3)); in xpadone_process_packet()
1156 input_report_key(dev, BTN_TRIGGER_HAPPY7, data[32] & BIT(0)); in xpadone_process_packet()
1157 input_report_key(dev, BTN_TRIGGER_HAPPY8, data[32] & BIT(2)); in xpadone_process_packet()
1158 } else if (xpad->packet_type == PKT_XBE2_FW_OLD) { in xpadone_process_packet()
1159 /* Mute paddles if controller has a custom mapping applied. in xpadone_process_packet()
1163 if (data[19] != 0) in xpadone_process_packet()
1164 data[18] = 0; in xpadone_process_packet()
1167 input_report_key(dev, BTN_TRIGGER_HAPPY5, data[18] & BIT(0)); in xpadone_process_packet()
1168 input_report_key(dev, BTN_TRIGGER_HAPPY6, data[18] & BIT(1)); in xpadone_process_packet()
1169 input_report_key(dev, BTN_TRIGGER_HAPPY7, data[18] & BIT(2)); in xpadone_process_packet()
1170 input_report_key(dev, BTN_TRIGGER_HAPPY8, data[18] & BIT(3)); in xpadone_process_packet()
1171 } else if (xpad->packet_type == PKT_XBE2_FW_5_EARLY) { in xpadone_process_packet()
1172 /* Mute paddles if controller has a custom mapping applied. in xpadone_process_packet()
1176 if (data[23] != 0) in xpadone_process_packet()
1177 data[22] = 0; in xpadone_process_packet()
1182 input_report_key(dev, BTN_TRIGGER_HAPPY5, data[22] & BIT(0)); in xpadone_process_packet()
1183 input_report_key(dev, BTN_TRIGGER_HAPPY6, data[22] & BIT(1)); in xpadone_process_packet()
1184 input_report_key(dev, BTN_TRIGGER_HAPPY7, data[22] & BIT(2)); in xpadone_process_packet()
1185 input_report_key(dev, BTN_TRIGGER_HAPPY8, data[22] & BIT(3)); in xpadone_process_packet()
1198 struct usb_xpad *xpad = urb->context; in xpad_irq_in()
1199 struct device *dev = &xpad->intf->dev; in xpad_irq_in()
1202 status = urb->status; in xpad_irq_in()
1208 case -ECONNRESET: in xpad_irq_in()
1209 case -ENOENT: in xpad_irq_in()
1210 case -ESHUTDOWN: in xpad_irq_in()
1212 dev_dbg(dev, "%s - urb shutting down with status: %d\n", in xpad_irq_in()
1216 dev_dbg(dev, "%s - nonzero urb status received: %d\n", in xpad_irq_in()
1221 switch (xpad->xtype) { in xpad_irq_in()
1223 xpad360_process_packet(xpad, xpad->dev, 0, xpad->idata); in xpad_irq_in()
1226 xpad360w_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
1229 xpadone_process_packet(xpad, 0, xpad->idata, urb->actual_length); in xpad_irq_in()
1232 xpad_process_packet(xpad, 0, xpad->idata); in xpad_irq_in()
1238 dev_err(dev, "%s - usb_submit_urb failed with result %d\n", in xpad_irq_in()
1242 /* Callers must hold xpad->odata_lock spinlock */
1247 if (xpad->xtype != XTYPE_XBOXONE) in xpad_prepare_next_init_packet()
1251 while (xpad->init_seq < ARRAY_SIZE(xboxone_init_packets)) { in xpad_prepare_next_init_packet()
1252 init_packet = &xboxone_init_packets[xpad->init_seq++]; in xpad_prepare_next_init_packet()
1254 if (init_packet->idVendor != 0 && in xpad_prepare_next_init_packet()
1255 init_packet->idVendor != xpad->dev->id.vendor) in xpad_prepare_next_init_packet()
1258 if (init_packet->idProduct != 0 && in xpad_prepare_next_init_packet()
1259 init_packet->idProduct != xpad->dev->id.product) in xpad_prepare_next_init_packet()
1263 memcpy(xpad->odata, init_packet->data, init_packet->len); in xpad_prepare_next_init_packet()
1264 xpad->irq_out->transfer_buffer_length = init_packet->len; in xpad_prepare_next_init_packet()
1267 xpad->odata[2] = xpad->odata_serial++; in xpad_prepare_next_init_packet()
1274 /* Callers must hold xpad->odata_lock spinlock */
1285 if (++xpad->last_out_packet >= XPAD_NUM_OUT_PACKETS) in xpad_prepare_next_out_packet()
1286 xpad->last_out_packet = 0; in xpad_prepare_next_out_packet()
1288 pkt = &xpad->out_packets[xpad->last_out_packet]; in xpad_prepare_next_out_packet()
1289 if (pkt->pending) { in xpad_prepare_next_out_packet()
1290 dev_dbg(&xpad->intf->dev, in xpad_prepare_next_out_packet()
1291 "%s - found pending output packet %d\n", in xpad_prepare_next_out_packet()
1292 __func__, xpad->last_out_packet); in xpad_prepare_next_out_packet()
1299 memcpy(xpad->odata, packet->data, packet->len); in xpad_prepare_next_out_packet()
1300 xpad->irq_out->transfer_buffer_length = packet->len; in xpad_prepare_next_out_packet()
1301 packet->pending = false; in xpad_prepare_next_out_packet()
1308 /* Callers must hold xpad->odata_lock spinlock */
1313 if (!xpad->irq_out_active && xpad_prepare_next_out_packet(xpad)) { in xpad_try_sending_next_out_packet()
1314 usb_anchor_urb(xpad->irq_out, &xpad->irq_out_anchor); in xpad_try_sending_next_out_packet()
1315 error = usb_submit_urb(xpad->irq_out, GFP_ATOMIC); in xpad_try_sending_next_out_packet()
1317 dev_err(&xpad->intf->dev, in xpad_try_sending_next_out_packet()
1318 "%s - usb_submit_urb failed with result %d\n", in xpad_try_sending_next_out_packet()
1320 usb_unanchor_urb(xpad->irq_out); in xpad_try_sending_next_out_packet()
1321 return -EIO; in xpad_try_sending_next_out_packet()
1324 xpad->irq_out_active = true; in xpad_try_sending_next_out_packet()
1332 struct usb_xpad *xpad = urb->context; in xpad_irq_out()
1333 struct device *dev = &xpad->intf->dev; in xpad_irq_out()
1334 int status = urb->status; in xpad_irq_out()
1338 spin_lock_irqsave(&xpad->odata_lock, flags); in xpad_irq_out()
1343 xpad->irq_out_active = xpad_prepare_next_out_packet(xpad); in xpad_irq_out()
1346 case -ECONNRESET: in xpad_irq_out()
1347 case -ENOENT: in xpad_irq_out()
1348 case -ESHUTDOWN: in xpad_irq_out()
1350 dev_dbg(dev, "%s - urb shutting down with status: %d\n", in xpad_irq_out()
1352 xpad->irq_out_active = false; in xpad_irq_out()
1356 dev_dbg(dev, "%s - nonzero urb status received: %d\n", in xpad_irq_out()
1361 if (xpad->irq_out_active) { in xpad_irq_out()
1362 usb_anchor_urb(urb, &xpad->irq_out_anchor); in xpad_irq_out()
1366 "%s - usb_submit_urb failed with result %d\n", in xpad_irq_out()
1369 xpad->irq_out_active = false; in xpad_irq_out()
1373 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpad_irq_out()
1381 if (xpad->xtype == XTYPE_UNKNOWN) in xpad_init_output()
1384 init_usb_anchor(&xpad->irq_out_anchor); in xpad_init_output()
1386 xpad->odata = usb_alloc_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_init_output()
1387 GFP_KERNEL, &xpad->odata_dma); in xpad_init_output()
1388 if (!xpad->odata) in xpad_init_output()
1389 return -ENOMEM; in xpad_init_output()
1391 spin_lock_init(&xpad->odata_lock); in xpad_init_output()
1393 xpad->irq_out = usb_alloc_urb(0, GFP_KERNEL); in xpad_init_output()
1394 if (!xpad->irq_out) { in xpad_init_output()
1395 error = -ENOMEM; in xpad_init_output()
1399 usb_fill_int_urb(xpad->irq_out, xpad->udev, in xpad_init_output()
1400 usb_sndintpipe(xpad->udev, ep_irq_out->bEndpointAddress), in xpad_init_output()
1401 xpad->odata, XPAD_PKT_LEN, in xpad_init_output()
1402 xpad_irq_out, xpad, ep_irq_out->bInterval); in xpad_init_output()
1403 xpad->irq_out->transfer_dma = xpad->odata_dma; in xpad_init_output()
1404 xpad->irq_out->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in xpad_init_output()
1409 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, xpad->odata, xpad->odata_dma); in xpad_init_output()
1415 if (xpad->xtype != XTYPE_UNKNOWN) { in xpad_stop_output()
1416 if (!usb_wait_anchor_empty_timeout(&xpad->irq_out_anchor, in xpad_stop_output()
1418 dev_warn(&xpad->intf->dev, in xpad_stop_output()
1420 usb_kill_anchored_urbs(&xpad->irq_out_anchor); in xpad_stop_output()
1427 if (xpad->xtype != XTYPE_UNKNOWN) { in xpad_deinit_output()
1428 usb_free_urb(xpad->irq_out); in xpad_deinit_output()
1429 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_deinit_output()
1430 xpad->odata, xpad->odata_dma); in xpad_deinit_output()
1437 &xpad->out_packets[XPAD_OUT_CMD_IDX]; in xpad_inquiry_pad_presence()
1441 spin_lock_irqsave(&xpad->odata_lock, flags); in xpad_inquiry_pad_presence()
1443 packet->data[0] = 0x08; in xpad_inquiry_pad_presence()
1444 packet->data[1] = 0x00; in xpad_inquiry_pad_presence()
1445 packet->data[2] = 0x0F; in xpad_inquiry_pad_presence()
1446 packet->data[3] = 0xC0; in xpad_inquiry_pad_presence()
1447 packet->data[4] = 0x00; in xpad_inquiry_pad_presence()
1448 packet->data[5] = 0x00; in xpad_inquiry_pad_presence()
1449 packet->data[6] = 0x00; in xpad_inquiry_pad_presence()
1450 packet->data[7] = 0x00; in xpad_inquiry_pad_presence()
1451 packet->data[8] = 0x00; in xpad_inquiry_pad_presence()
1452 packet->data[9] = 0x00; in xpad_inquiry_pad_presence()
1453 packet->data[10] = 0x00; in xpad_inquiry_pad_presence()
1454 packet->data[11] = 0x00; in xpad_inquiry_pad_presence()
1455 packet->len = 12; in xpad_inquiry_pad_presence()
1456 packet->pending = true; in xpad_inquiry_pad_presence()
1459 xpad->last_out_packet = -1; in xpad_inquiry_pad_presence()
1462 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpad_inquiry_pad_presence()
1472 if (usb_ifnum_to_if(xpad->udev, GIP_WIRED_INTF_AUDIO)) { in xpad_start_xbox_one()
1476 * Controller for Series X|S (0x20d6:0x200e) to report the in xpad_start_xbox_one()
1479 retval = usb_set_interface(xpad->udev, in xpad_start_xbox_one()
1482 dev_warn(&xpad->dev->dev, in xpad_start_xbox_one()
1487 spin_lock_irqsave(&xpad->odata_lock, flags); in xpad_start_xbox_one()
1494 xpad->init_seq = 0; in xpad_start_xbox_one()
1497 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpad_start_xbox_one()
1506 &xpad->out_packets[XPAD_OUT_CMD_IDX]; in xpadone_ack_mode_report()
1512 spin_lock_irqsave(&xpad->odata_lock, flags); in xpadone_ack_mode_report()
1514 packet->len = sizeof(mode_report_ack); in xpadone_ack_mode_report()
1515 memcpy(packet->data, mode_report_ack, packet->len); in xpadone_ack_mode_report()
1516 packet->data[2] = seq_num; in xpadone_ack_mode_report()
1517 packet->pending = true; in xpadone_ack_mode_report()
1520 xpad->last_out_packet = -1; in xpadone_ack_mode_report()
1523 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpadone_ack_mode_report()
1527 static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect *effect) in xpad_play_effect() argument
1530 struct xpad_output_packet *packet = &xpad->out_packets[XPAD_OUT_FF_IDX]; in xpad_play_effect()
1536 if (effect->type != FF_RUMBLE) in xpad_play_effect()
1539 strong = effect->u.rumble.strong_magnitude; in xpad_play_effect()
1540 weak = effect->u.rumble.weak_magnitude; in xpad_play_effect()
1542 spin_lock_irqsave(&xpad->odata_lock, flags); in xpad_play_effect()
1544 switch (xpad->xtype) { in xpad_play_effect()
1546 packet->data[0] = 0x00; in xpad_play_effect()
1547 packet->data[1] = 0x06; in xpad_play_effect()
1548 packet->data[2] = 0x00; in xpad_play_effect()
1549 packet->data[3] = strong / 256; /* left actuator */ in xpad_play_effect()
1550 packet->data[4] = 0x00; in xpad_play_effect()
1551 packet->data[5] = weak / 256; /* right actuator */ in xpad_play_effect()
1552 packet->len = 6; in xpad_play_effect()
1553 packet->pending = true; in xpad_play_effect()
1557 packet->data[0] = 0x00; in xpad_play_effect()
1558 packet->data[1] = 0x08; in xpad_play_effect()
1559 packet->data[2] = 0x00; in xpad_play_effect()
1560 packet->data[3] = strong / 256; /* left actuator? */ in xpad_play_effect()
1561 packet->data[4] = weak / 256; /* right actuator? */ in xpad_play_effect()
1562 packet->data[5] = 0x00; in xpad_play_effect()
1563 packet->data[6] = 0x00; in xpad_play_effect()
1564 packet->data[7] = 0x00; in xpad_play_effect()
1565 packet->len = 8; in xpad_play_effect()
1566 packet->pending = true; in xpad_play_effect()
1570 packet->data[0] = 0x00; in xpad_play_effect()
1571 packet->data[1] = 0x01; in xpad_play_effect()
1572 packet->data[2] = 0x0F; in xpad_play_effect()
1573 packet->data[3] = 0xC0; in xpad_play_effect()
1574 packet->data[4] = 0x00; in xpad_play_effect()
1575 packet->data[5] = strong / 256; in xpad_play_effect()
1576 packet->data[6] = weak / 256; in xpad_play_effect()
1577 packet->data[7] = 0x00; in xpad_play_effect()
1578 packet->data[8] = 0x00; in xpad_play_effect()
1579 packet->data[9] = 0x00; in xpad_play_effect()
1580 packet->data[10] = 0x00; in xpad_play_effect()
1581 packet->data[11] = 0x00; in xpad_play_effect()
1582 packet->len = 12; in xpad_play_effect()
1583 packet->pending = true; in xpad_play_effect()
1587 packet->data[0] = GIP_CMD_RUMBLE; /* activate rumble */ in xpad_play_effect()
1588 packet->data[1] = 0x00; in xpad_play_effect()
1589 packet->data[2] = xpad->odata_serial++; in xpad_play_effect()
1590 packet->data[3] = GIP_PL_LEN(9); in xpad_play_effect()
1591 packet->data[4] = 0x00; in xpad_play_effect()
1592 packet->data[5] = GIP_MOTOR_ALL; in xpad_play_effect()
1593 packet->data[6] = 0x00; /* left trigger */ in xpad_play_effect()
1594 packet->data[7] = 0x00; /* right trigger */ in xpad_play_effect()
1595 packet->data[8] = strong / 512; /* left actuator */ in xpad_play_effect()
1596 packet->data[9] = weak / 512; /* right actuator */ in xpad_play_effect()
1597 packet->data[10] = 0xFF; /* on period */ in xpad_play_effect()
1598 packet->data[11] = 0x00; /* off period */ in xpad_play_effect()
1599 packet->data[12] = 0xFF; /* repeat count */ in xpad_play_effect()
1600 packet->len = 13; in xpad_play_effect()
1601 packet->pending = true; in xpad_play_effect()
1605 dev_dbg(&xpad->dev->dev, in xpad_play_effect()
1606 "%s - rumble command sent to unsupported xpad type: %d\n", in xpad_play_effect()
1607 __func__, xpad->xtype); in xpad_play_effect()
1608 retval = -EINVAL; in xpad_play_effect()
1615 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpad_play_effect()
1621 if (xpad->xtype == XTYPE_UNKNOWN) in xpad_init_ff()
1624 input_set_capability(xpad->dev, EV_FF, FF_RUMBLE); in xpad_init_ff()
1626 return input_ff_create_memless(xpad->dev, NULL, xpad_play_effect); in xpad_init_ff()
1650 * 2: 1/top-left blink, then on
1651 * 3: 2/top-right blink, then on
1652 * 4: 3/bottom-left blink, then on
1653 * 5: 4/bottom-right blink, then on
1654 * 6: 1/top-left on
1655 * 7: 2/top-right on
1656 * 8: 3/bottom-left on
1657 * 9: 4/bottom-right on
1668 &xpad->out_packets[XPAD_OUT_LED_IDX]; in xpad_send_led_command()
1673 spin_lock_irqsave(&xpad->odata_lock, flags); in xpad_send_led_command()
1675 switch (xpad->xtype) { in xpad_send_led_command()
1677 packet->data[0] = 0x01; in xpad_send_led_command()
1678 packet->data[1] = 0x03; in xpad_send_led_command()
1679 packet->data[2] = command; in xpad_send_led_command()
1680 packet->len = 3; in xpad_send_led_command()
1681 packet->pending = true; in xpad_send_led_command()
1685 packet->data[0] = 0x00; in xpad_send_led_command()
1686 packet->data[1] = 0x00; in xpad_send_led_command()
1687 packet->data[2] = 0x08; in xpad_send_led_command()
1688 packet->data[3] = 0x40 + command; in xpad_send_led_command()
1689 packet->data[4] = 0x00; in xpad_send_led_command()
1690 packet->data[5] = 0x00; in xpad_send_led_command()
1691 packet->data[6] = 0x00; in xpad_send_led_command()
1692 packet->data[7] = 0x00; in xpad_send_led_command()
1693 packet->data[8] = 0x00; in xpad_send_led_command()
1694 packet->data[9] = 0x00; in xpad_send_led_command()
1695 packet->data[10] = 0x00; in xpad_send_led_command()
1696 packet->data[11] = 0x00; in xpad_send_led_command()
1697 packet->len = 12; in xpad_send_led_command()
1698 packet->pending = true; in xpad_send_led_command()
1704 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpad_send_led_command()
1713 led_set_brightness(&xpad->led->led_cdev, (xpad->pad_nr % 4) + 2); in xpad_identify_controller()
1722 xpad_send_led_command(xpad_led->xpad, value); in xpad_led_set()
1731 if (xpad->xtype != XTYPE_XBOX360 && xpad->xtype != XTYPE_XBOX360W) in xpad_led_probe()
1734 xpad->led = led = kzalloc(sizeof(struct xpad_led), GFP_KERNEL); in xpad_led_probe()
1736 return -ENOMEM; in xpad_led_probe()
1738 xpad->pad_nr = ida_simple_get(&xpad_pad_seq, 0, 0, GFP_KERNEL); in xpad_led_probe()
1739 if (xpad->pad_nr < 0) { in xpad_led_probe()
1740 error = xpad->pad_nr; in xpad_led_probe()
1744 snprintf(led->name, sizeof(led->name), "xpad%d", xpad->pad_nr); in xpad_led_probe()
1745 led->xpad = xpad; in xpad_led_probe()
1747 led_cdev = &led->led_cdev; in xpad_led_probe()
1748 led_cdev->name = led->name; in xpad_led_probe()
1749 led_cdev->brightness_set = xpad_led_set; in xpad_led_probe()
1750 led_cdev->flags = LED_CORE_SUSPENDRESUME; in xpad_led_probe()
1752 error = led_classdev_register(&xpad->udev->dev, led_cdev); in xpad_led_probe()
1761 ida_simple_remove(&xpad_pad_seq, xpad->pad_nr); in xpad_led_probe()
1764 xpad->led = NULL; in xpad_led_probe()
1770 struct xpad_led *xpad_led = xpad->led; in xpad_led_disconnect()
1773 led_classdev_unregister(&xpad_led->led_cdev); in xpad_led_disconnect()
1774 ida_simple_remove(&xpad_pad_seq, xpad->pad_nr); in xpad_led_disconnect()
1787 if (usb_submit_urb(xpad->irq_in, GFP_KERNEL)) in xpad_start_input()
1788 return -EIO; in xpad_start_input()
1790 if (xpad->xtype == XTYPE_XBOXONE) { in xpad_start_input()
1793 usb_kill_urb(xpad->irq_in); in xpad_start_input()
1797 if (xpad->xtype == XTYPE_XBOX360) { in xpad_start_input()
1799 * Some third-party controllers Xbox 360-style controllers in xpad_start_input()
1804 error = usb_control_msg_recv(xpad->udev, 0, in xpad_start_input()
1814 dev_warn(&xpad->dev->dev, in xpad_start_input()
1824 usb_kill_urb(xpad->irq_in); in xpad_stop_input()
1831 &xpad->out_packets[XPAD_OUT_CMD_IDX]; in xpad360w_poweroff_controller()
1833 spin_lock_irqsave(&xpad->odata_lock, flags); in xpad360w_poweroff_controller()
1835 packet->data[0] = 0x00; in xpad360w_poweroff_controller()
1836 packet->data[1] = 0x00; in xpad360w_poweroff_controller()
1837 packet->data[2] = 0x08; in xpad360w_poweroff_controller()
1838 packet->data[3] = 0xC0; in xpad360w_poweroff_controller()
1839 packet->data[4] = 0x00; in xpad360w_poweroff_controller()
1840 packet->data[5] = 0x00; in xpad360w_poweroff_controller()
1841 packet->data[6] = 0x00; in xpad360w_poweroff_controller()
1842 packet->data[7] = 0x00; in xpad360w_poweroff_controller()
1843 packet->data[8] = 0x00; in xpad360w_poweroff_controller()
1844 packet->data[9] = 0x00; in xpad360w_poweroff_controller()
1845 packet->data[10] = 0x00; in xpad360w_poweroff_controller()
1846 packet->data[11] = 0x00; in xpad360w_poweroff_controller()
1847 packet->len = 12; in xpad360w_poweroff_controller()
1848 packet->pending = true; in xpad360w_poweroff_controller()
1851 xpad->last_out_packet = -1; in xpad360w_poweroff_controller()
1854 spin_unlock_irqrestore(&xpad->odata_lock, flags); in xpad360w_poweroff_controller()
1861 error = usb_submit_urb(xpad->irq_in, GFP_KERNEL); in xpad360w_start_input()
1863 return -EIO; in xpad360w_start_input()
1867 * This will force the controller to resend connection packets. in xpad360w_start_input()
1874 usb_kill_urb(xpad->irq_in); in xpad360w_start_input()
1883 usb_kill_urb(xpad->irq_in); in xpad360w_stop_input()
1886 flush_work(&xpad->work); in xpad360w_stop_input()
1912 input_set_abs_params(input_dev, abs, -32768, 32767, 16, 128); in xpad_set_up_abs()
1916 if (xpad->xtype == XTYPE_XBOXONE) in xpad_set_up_abs()
1922 case ABS_HAT0Y: /* the d-pad (only if dpad is mapped to axes */ in xpad_set_up_abs()
1923 input_set_abs_params(input_dev, abs, -1, 1, 0, 0); in xpad_set_up_abs()
1936 if (xpad->input_created) { in xpad_deinit_input()
1937 xpad->input_created = false; in xpad_deinit_input()
1939 input_unregister_device(xpad->dev); in xpad_deinit_input()
1950 return -ENOMEM; in xpad_init_input()
1952 xpad->dev = input_dev; in xpad_init_input()
1953 input_dev->name = xpad->name; in xpad_init_input()
1954 input_dev->phys = xpad->phys; in xpad_init_input()
1955 usb_to_input_id(xpad->udev, &input_dev->id); in xpad_init_input()
1957 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_init_input()
1959 input_dev->id.product = 0x02a1; in xpad_init_input()
1962 input_dev->dev.parent = &xpad->intf->dev; in xpad_init_input()
1966 if (xpad->xtype != XTYPE_XBOX360W) { in xpad_init_input()
1967 input_dev->open = xpad_open; in xpad_init_input()
1968 input_dev->close = xpad_close; in xpad_init_input()
1971 if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { in xpad_init_input()
1981 /* set up model-specific ones */ in xpad_init_input()
1982 if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W || in xpad_init_input()
1983 xpad->xtype == XTYPE_XBOXONE) { in xpad_init_input()
1986 if (xpad->mapping & MAP_SHARE_BUTTON) in xpad_init_input()
1993 if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { in xpad_init_input()
1999 /* set up paddles if the controller has them */ in xpad_init_input()
2000 if (xpad->mapping & MAP_PADDLES) { in xpad_init_input()
2011 if (!(xpad->mapping & MAP_DPAD_TO_BUTTONS) || in xpad_init_input()
2012 xpad->xtype == XTYPE_XBOX360W) { in xpad_init_input()
2017 if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { in xpad_init_input()
2027 if (xpad->mapping & MAP_PROFILE_BUTTON) in xpad_init_input()
2038 error = input_register_device(xpad->dev); in xpad_init_input()
2042 xpad->input_created = true; in xpad_init_input()
2061 if (intf->cur_altsetting->desc.bNumEndpoints != 2) in xpad_probe()
2062 return -ENODEV; in xpad_probe()
2065 if ((le16_to_cpu(udev->descriptor.idVendor) == xpad_device[i].idVendor) && in xpad_probe()
2066 (le16_to_cpu(udev->descriptor.idProduct) == xpad_device[i].idProduct)) in xpad_probe()
2072 return -ENOMEM; in xpad_probe()
2074 usb_make_path(udev, xpad->phys, sizeof(xpad->phys)); in xpad_probe()
2075 strlcat(xpad->phys, "/input0", sizeof(xpad->phys)); in xpad_probe()
2077 xpad->idata = usb_alloc_coherent(udev, XPAD_PKT_LEN, in xpad_probe()
2078 GFP_KERNEL, &xpad->idata_dma); in xpad_probe()
2079 if (!xpad->idata) { in xpad_probe()
2080 error = -ENOMEM; in xpad_probe()
2084 xpad->irq_in = usb_alloc_urb(0, GFP_KERNEL); in xpad_probe()
2085 if (!xpad->irq_in) { in xpad_probe()
2086 error = -ENOMEM; in xpad_probe()
2090 xpad->udev = udev; in xpad_probe()
2091 xpad->intf = intf; in xpad_probe()
2092 xpad->mapping = xpad_device[i].mapping; in xpad_probe()
2093 xpad->xtype = xpad_device[i].xtype; in xpad_probe()
2094 xpad->name = xpad_device[i].name; in xpad_probe()
2095 xpad->packet_type = PKT_XB; in xpad_probe()
2096 INIT_WORK(&xpad->work, xpad_presence_work); in xpad_probe()
2098 if (xpad->xtype == XTYPE_UNKNOWN) { in xpad_probe()
2099 if (intf->cur_altsetting->desc.bInterfaceClass == USB_CLASS_VENDOR_SPEC) { in xpad_probe()
2100 if (intf->cur_altsetting->desc.bInterfaceProtocol == 129) in xpad_probe()
2101 xpad->xtype = XTYPE_XBOX360W; in xpad_probe()
2102 else if (intf->cur_altsetting->desc.bInterfaceProtocol == 208) in xpad_probe()
2103 xpad->xtype = XTYPE_XBOXONE; in xpad_probe()
2105 xpad->xtype = XTYPE_XBOX360; in xpad_probe()
2107 xpad->xtype = XTYPE_XBOX; in xpad_probe()
2111 xpad->mapping |= MAP_DPAD_TO_BUTTONS; in xpad_probe()
2113 xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS; in xpad_probe()
2115 xpad->mapping |= MAP_STICKS_TO_NULL; in xpad_probe()
2118 if (xpad->xtype == XTYPE_XBOXONE && in xpad_probe()
2119 intf->cur_altsetting->desc.bInterfaceNumber != GIP_WIRED_INTF_DATA) { in xpad_probe()
2121 * The Xbox One controller lists three interfaces all with the in xpad_probe()
2125 error = -ENODEV; in xpad_probe()
2133 &intf->cur_altsetting->endpoint[i].desc; in xpad_probe()
2144 error = -ENODEV; in xpad_probe()
2152 usb_fill_int_urb(xpad->irq_in, udev, in xpad_probe()
2153 usb_rcvintpipe(udev, ep_irq_in->bEndpointAddress), in xpad_probe()
2154 xpad->idata, XPAD_PKT_LEN, xpad_irq_in, in xpad_probe()
2155 xpad, ep_irq_in->bInterval); in xpad_probe()
2156 xpad->irq_in->transfer_dma = xpad->idata_dma; in xpad_probe()
2157 xpad->irq_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in xpad_probe()
2162 if (le16_to_cpu(udev->descriptor.idVendor) == 0x045e) { /* Microsoft controllers */ in xpad_probe()
2163 if (le16_to_cpu(udev->descriptor.idProduct) == 0x02e3) { in xpad_probe()
2164 /* The original elite controller always uses the oldest in xpad_probe()
2167 xpad->packet_type = PKT_XBE1; in xpad_probe()
2168 } else if (le16_to_cpu(udev->descriptor.idProduct) == 0x0b00) { in xpad_probe()
2169 /* The elite 2 controller has seen multiple packet in xpad_probe()
2173 if (le16_to_cpu(udev->descriptor.bcdDevice) < 0x0500) { in xpad_probe()
2177 xpad->packet_type = PKT_XBE2_FW_OLD; in xpad_probe()
2178 } else if (le16_to_cpu(udev->descriptor.bcdDevice) < in xpad_probe()
2183 xpad->packet_type = PKT_XBE2_FW_5_EARLY; in xpad_probe()
2188 xpad->packet_type = PKT_XBE2_FW_5_11; in xpad_probe()
2193 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_probe()
2198 * exactly the message that a controller has arrived that in xpad_probe()
2211 udev->quirks |= USB_QUIRK_RESET_RESUME; in xpad_probe()
2222 usb_free_urb(xpad->irq_in); in xpad_probe()
2224 usb_free_coherent(udev, XPAD_PKT_LEN, xpad->idata, xpad->idata_dma); in xpad_probe()
2234 if (xpad->xtype == XTYPE_XBOX360W) in xpad_disconnect()
2247 usb_free_urb(xpad->irq_in); in xpad_disconnect()
2248 usb_free_coherent(xpad->udev, XPAD_PKT_LEN, in xpad_disconnect()
2249 xpad->idata, xpad->idata_dma); in xpad_disconnect()
2259 struct input_dev *input = xpad->dev; in xpad_suspend()
2261 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_suspend()
2264 * they are notified when controller shows up in xpad_suspend()
2275 if (auto_poweroff && xpad->pad_present) in xpad_suspend()
2278 mutex_lock(&input->mutex); in xpad_suspend()
2281 mutex_unlock(&input->mutex); in xpad_suspend()
2292 struct input_dev *input = xpad->dev; in xpad_resume()
2295 if (xpad->xtype == XTYPE_XBOX360W) { in xpad_resume()
2298 mutex_lock(&input->mutex); in xpad_resume()
2301 } else if (xpad->xtype == XTYPE_XBOXONE) { in xpad_resume()
2309 mutex_unlock(&input->mutex); in xpad_resume()
2326 MODULE_AUTHOR("Marko Friedemann <mfr@bmx-chemnitz.de>");