xref: /OK3568_Linux_fs/kernel/Documentation/input/devices/xpad.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun=======================================================
2*4882a593Smuzhiyunxpad - Linux USB driver for Xbox compatible controllers
3*4882a593Smuzhiyun=======================================================
4*4882a593Smuzhiyun
5*4882a593SmuzhiyunThis driver exposes all first-party and third-party Xbox compatible
6*4882a593Smuzhiyuncontrollers. It has a long history and has enjoyed considerable usage
7*4882a593Smuzhiyunas Window's xinput library caused most PC games to focus on Xbox
8*4882a593Smuzhiyuncontroller compatibility.
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunDue to backwards compatibility all buttons are reported as digital.
11*4882a593SmuzhiyunThis only effects Original Xbox controllers. All later controller models
12*4882a593Smuzhiyunhave only digital face buttons.
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunRumble is supported on some models of Xbox 360 controllers but not of
15*4882a593SmuzhiyunOriginal Xbox controllers nor on Xbox One controllers. As of writing
16*4882a593Smuzhiyunthe Xbox One's rumble protocol has not been reverse engineered but in
17*4882a593Smuzhiyunthe future could be supported.
18*4882a593Smuzhiyun
19*4882a593Smuzhiyun
20*4882a593SmuzhiyunNotes
21*4882a593Smuzhiyun=====
22*4882a593Smuzhiyun
23*4882a593SmuzhiyunThe number of buttons/axes reported varies based on 3 things:
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun- if you are using a known controller
26*4882a593Smuzhiyun- if you are using a known dance pad
27*4882a593Smuzhiyun- if using an unknown device (one not listed below), what you set in the
28*4882a593Smuzhiyun  module configuration for "Map D-PAD to buttons rather than axes for unknown
29*4882a593Smuzhiyun  pads" (module option dpad_to_buttons)
30*4882a593Smuzhiyun
31*4882a593SmuzhiyunIf you set dpad_to_buttons to N and you are using an unknown device
32*4882a593Smuzhiyunthe driver will map the directional pad to axes (X/Y).
33*4882a593SmuzhiyunIf you said Y it will map the d-pad to buttons, which is needed for dance
34*4882a593Smuzhiyunstyle games to function correctly. The default is Y.
35*4882a593Smuzhiyun
36*4882a593Smuzhiyundpad_to_buttons has no effect for known pads. A erroneous commit message
37*4882a593Smuzhiyunclaimed dpad_to_buttons could be used to force behavior on known devices.
38*4882a593SmuzhiyunThis is not true. Both dpad_to_buttons and triggers_to_buttons only affect
39*4882a593Smuzhiyununknown controllers.
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun
42*4882a593SmuzhiyunNormal Controllers
43*4882a593Smuzhiyun------------------
44*4882a593Smuzhiyun
45*4882a593SmuzhiyunWith a normal controller, the directional pad is mapped to its own X/Y axes.
46*4882a593SmuzhiyunThe jstest-program from joystick-1.2.15 (jstest-version 2.1.0) will report 8
47*4882a593Smuzhiyunaxes and 10 buttons.
48*4882a593Smuzhiyun
49*4882a593SmuzhiyunAll 8 axes work, though they all have the same range (-32768..32767)
50*4882a593Smuzhiyunand the zero-setting is not correct for the triggers (I don't know if that
51*4882a593Smuzhiyunis some limitation of jstest, since the input device setup should be fine. I
52*4882a593Smuzhiyundidn't have a look at jstest itself yet).
53*4882a593Smuzhiyun
54*4882a593SmuzhiyunAll of the 10 buttons work (in digital mode). The six buttons on the
55*4882a593Smuzhiyunright side (A, B, X, Y, black, white) are said to be "analog" and
56*4882a593Smuzhiyunreport their values as 8 bit unsigned, not sure what this is good for.
57*4882a593Smuzhiyun
58*4882a593SmuzhiyunI tested the controller with quake3, and configuration and
59*4882a593Smuzhiyunin game functionality were OK. However, I find it rather difficult to
60*4882a593Smuzhiyunplay first person shooters with a pad. Your mileage may vary.
61*4882a593Smuzhiyun
62*4882a593Smuzhiyun
63*4882a593SmuzhiyunXbox Dance Pads
64*4882a593Smuzhiyun---------------
65*4882a593Smuzhiyun
66*4882a593SmuzhiyunWhen using a known dance pad, jstest will report 6 axes and 14 buttons.
67*4882a593Smuzhiyun
68*4882a593SmuzhiyunFor dance style pads (like the redoctane pad) several changes
69*4882a593Smuzhiyunhave been made.  The old driver would map the d-pad to axes, resulting
70*4882a593Smuzhiyunin the driver being unable to report when the user was pressing both
71*4882a593Smuzhiyunleft+right or up+down, making DDR style games unplayable.
72*4882a593Smuzhiyun
73*4882a593SmuzhiyunKnown dance pads automatically map the d-pad to buttons and will work
74*4882a593Smuzhiyuncorrectly out of the box.
75*4882a593Smuzhiyun
76*4882a593SmuzhiyunIf your dance pad is recognized by the driver but is using axes instead
77*4882a593Smuzhiyunof buttons, see section 0.3 - Unknown Controllers
78*4882a593Smuzhiyun
79*4882a593SmuzhiyunI've tested this with Stepmania, and it works quite well.
80*4882a593Smuzhiyun
81*4882a593Smuzhiyun
82*4882a593SmuzhiyunUnknown Controllers
83*4882a593Smuzhiyun-------------------
84*4882a593Smuzhiyun
85*4882a593SmuzhiyunIf you have an unknown xbox controller, it should work just fine with
86*4882a593Smuzhiyunthe default settings.
87*4882a593Smuzhiyun
88*4882a593SmuzhiyunHOWEVER if you have an unknown dance pad not listed below, it will not
89*4882a593Smuzhiyunwork UNLESS you set "dpad_to_buttons" to 1 in the module configuration.
90*4882a593Smuzhiyun
91*4882a593Smuzhiyun
92*4882a593SmuzhiyunUSB adapters
93*4882a593Smuzhiyun============
94*4882a593Smuzhiyun
95*4882a593SmuzhiyunAll generations of Xbox controllers speak USB over the wire.
96*4882a593Smuzhiyun
97*4882a593Smuzhiyun- Original Xbox controllers use a proprietary connector and require adapters.
98*4882a593Smuzhiyun- Wireless Xbox 360 controllers require a 'Xbox 360 Wireless Gaming Receiver
99*4882a593Smuzhiyun  for Windows'
100*4882a593Smuzhiyun- Wired Xbox 360 controllers use standard USB connectors.
101*4882a593Smuzhiyun- Xbox One controllers can be wireless but speak Wi-Fi Direct and are not
102*4882a593Smuzhiyun  yet supported.
103*4882a593Smuzhiyun- Xbox One controllers can be wired and use standard Micro-USB connectors.
104*4882a593Smuzhiyun
105*4882a593Smuzhiyun
106*4882a593Smuzhiyun
107*4882a593SmuzhiyunOriginal Xbox USB adapters
108*4882a593Smuzhiyun--------------------------
109*4882a593Smuzhiyun
110*4882a593SmuzhiyunUsing this driver with an Original Xbox controller requires an
111*4882a593Smuzhiyunadapter cable to break out the proprietary connector's pins to USB.
112*4882a593SmuzhiyunYou can buy these online fairly cheap, or build your own.
113*4882a593Smuzhiyun
114*4882a593SmuzhiyunSuch a cable is pretty easy to build. The Controller itself is a USB
115*4882a593Smuzhiyuncompound device (a hub with three ports for two expansion slots and
116*4882a593Smuzhiyunthe controller device) with the only difference in a nonstandard connector
117*4882a593Smuzhiyun(5 pins vs. 4 on standard USB 1.0 connectors).
118*4882a593Smuzhiyun
119*4882a593SmuzhiyunYou just need to solder a USB connector onto the cable and keep the
120*4882a593Smuzhiyunyellow wire unconnected. The other pins have the same order on both
121*4882a593Smuzhiyunconnectors so there is no magic to it. Detailed info on these matters
122*4882a593Smuzhiyuncan be found on the net ([1]_, [2]_, [3]_).
123*4882a593Smuzhiyun
124*4882a593SmuzhiyunThanks to the trip splitter found on the cable you don't even need to cut the
125*4882a593Smuzhiyunoriginal one. You can buy an extension cable and cut that instead. That way,
126*4882a593Smuzhiyunyou can still use the controller with your X-Box, if you have one ;)
127*4882a593Smuzhiyun
128*4882a593Smuzhiyun
129*4882a593Smuzhiyun
130*4882a593SmuzhiyunDriver Installation
131*4882a593Smuzhiyun===================
132*4882a593Smuzhiyun
133*4882a593SmuzhiyunOnce you have the adapter cable, if needed, and the controller connected
134*4882a593Smuzhiyunthe xpad module should be auto loaded. To confirm you can cat
135*4882a593Smuzhiyun/sys/kernel/debug/usb/devices. There should be an entry like those:
136*4882a593Smuzhiyun
137*4882a593Smuzhiyun.. code-block:: none
138*4882a593Smuzhiyun   :caption: dump from InterAct PowerPad Pro (Germany)
139*4882a593Smuzhiyun
140*4882a593Smuzhiyun    T:  Bus=01 Lev=03 Prnt=04 Port=00 Cnt=01 Dev#=  5 Spd=12  MxCh= 0
141*4882a593Smuzhiyun    D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=32 #Cfgs=  1
142*4882a593Smuzhiyun    P:  Vendor=05fd ProdID=107a Rev= 1.00
143*4882a593Smuzhiyun    C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
144*4882a593Smuzhiyun    I:  If#= 0 Alt= 0 #EPs= 2 Cls=58(unk. ) Sub=42 Prot=00 Driver=(none)
145*4882a593Smuzhiyun    E:  Ad=81(I) Atr=03(Int.) MxPS=  32 Ivl= 10ms
146*4882a593Smuzhiyun    E:  Ad=02(O) Atr=03(Int.) MxPS=  32 Ivl= 10ms
147*4882a593Smuzhiyun
148*4882a593Smuzhiyun.. code-block:: none
149*4882a593Smuzhiyun   :caption: dump from Redoctane Xbox Dance Pad (US)
150*4882a593Smuzhiyun
151*4882a593Smuzhiyun    T:  Bus=01 Lev=02 Prnt=09 Port=00 Cnt=01 Dev#= 10 Spd=12  MxCh= 0
152*4882a593Smuzhiyun    D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
153*4882a593Smuzhiyun    P:  Vendor=0c12 ProdID=8809 Rev= 0.01
154*4882a593Smuzhiyun    S:  Product=XBOX DDR
155*4882a593Smuzhiyun    C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=100mA
156*4882a593Smuzhiyun    I:  If#= 0 Alt= 0 #EPs= 2 Cls=58(unk. ) Sub=42 Prot=00 Driver=xpad
157*4882a593Smuzhiyun    E:  Ad=82(I) Atr=03(Int.) MxPS=  32 Ivl=4ms
158*4882a593Smuzhiyun    E:  Ad=02(O) Atr=03(Int.) MxPS=  32 Ivl=4ms
159*4882a593Smuzhiyun
160*4882a593Smuzhiyun
161*4882a593SmuzhiyunSupported Controllers
162*4882a593Smuzhiyun=====================
163*4882a593Smuzhiyun
164*4882a593SmuzhiyunFor a full list of supported controllers and associated vendor and product
165*4882a593SmuzhiyunIDs see the xpad_device[] array\ [4]_.
166*4882a593Smuzhiyun
167*4882a593SmuzhiyunAs of the historic version 0.0.6 (2006-10-10) the following devices
168*4882a593Smuzhiyunwere supported::
169*4882a593Smuzhiyun
170*4882a593Smuzhiyun original Microsoft XBOX controller (US),    vendor=0x045e, product=0x0202
171*4882a593Smuzhiyun smaller  Microsoft XBOX controller (US),    vendor=0x045e, product=0x0289
172*4882a593Smuzhiyun original Microsoft XBOX controller (Japan), vendor=0x045e, product=0x0285
173*4882a593Smuzhiyun InterAct PowerPad Pro (Germany),            vendor=0x05fd, product=0x107a
174*4882a593Smuzhiyun RedOctane Xbox Dance Pad (US),              vendor=0x0c12, product=0x8809
175*4882a593Smuzhiyun
176*4882a593SmuzhiyunUnrecognized models of Xbox controllers should function as Generic
177*4882a593SmuzhiyunXbox controllers. Unrecognized Dance Pad controllers require setting
178*4882a593Smuzhiyunthe module option 'dpad_to_buttons'.
179*4882a593Smuzhiyun
180*4882a593SmuzhiyunIf you have an unrecognized controller please see 0.3 - Unknown Controllers
181*4882a593Smuzhiyun
182*4882a593Smuzhiyun
183*4882a593SmuzhiyunManual Testing
184*4882a593Smuzhiyun==============
185*4882a593Smuzhiyun
186*4882a593SmuzhiyunTo test this driver's functionality you may use 'jstest'.
187*4882a593Smuzhiyun
188*4882a593SmuzhiyunFor example::
189*4882a593Smuzhiyun
190*4882a593Smuzhiyun    > modprobe xpad
191*4882a593Smuzhiyun    > modprobe joydev
192*4882a593Smuzhiyun    > jstest /dev/js0
193*4882a593Smuzhiyun
194*4882a593SmuzhiyunIf you're using a normal controller, there should be a single line showing
195*4882a593Smuzhiyun18 inputs (8 axes, 10 buttons), and its values should change if you move
196*4882a593Smuzhiyunthe sticks and push the buttons.  If you're using a dance pad, it should
197*4882a593Smuzhiyunshow 20 inputs (6 axes, 14 buttons).
198*4882a593Smuzhiyun
199*4882a593SmuzhiyunIt works? Voila, you're done ;)
200*4882a593Smuzhiyun
201*4882a593Smuzhiyun
202*4882a593Smuzhiyun
203*4882a593SmuzhiyunThanks
204*4882a593Smuzhiyun======
205*4882a593Smuzhiyun
206*4882a593SmuzhiyunI have to thank ITO Takayuki for the detailed info on his site
207*4882a593Smuzhiyun    http://euc.jp/periphs/xbox-controller.ja.html.
208*4882a593Smuzhiyun
209*4882a593SmuzhiyunHis useful info and both the usb-skeleton as well as the iforce input driver
210*4882a593Smuzhiyun(Greg Kroah-Hartmann; Vojtech Pavlik) helped a lot in rapid prototyping
211*4882a593Smuzhiyunthe basic functionality.
212*4882a593Smuzhiyun
213*4882a593Smuzhiyun
214*4882a593Smuzhiyun
215*4882a593SmuzhiyunReferences
216*4882a593Smuzhiyun==========
217*4882a593Smuzhiyun
218*4882a593Smuzhiyun.. [1] http://euc.jp/periphs/xbox-controller.ja.html (ITO Takayuki)
219*4882a593Smuzhiyun.. [2] http://xpad.xbox-scene.com/
220*4882a593Smuzhiyun.. [3] http://www.markosweb.com/www/xboxhackz.com/
221*4882a593Smuzhiyun.. [4] https://elixir.bootlin.com/linux/latest/ident/xpad_device
222*4882a593Smuzhiyun
223*4882a593Smuzhiyun
224*4882a593SmuzhiyunHistoric Edits
225*4882a593Smuzhiyun==============
226*4882a593Smuzhiyun
227*4882a593Smuzhiyun2002-07-16 - Marko Friedemann <mfr@bmx-chemnitz.de>
228*4882a593Smuzhiyun - original doc
229*4882a593Smuzhiyun
230*4882a593Smuzhiyun2005-03-19 - Dominic Cerquetti <binary1230@yahoo.com>
231*4882a593Smuzhiyun - added stuff for dance pads, new d-pad->axes mappings
232*4882a593Smuzhiyun
233*4882a593SmuzhiyunLater changes may be viewed with
234*4882a593Smuzhiyun'git log --follow Documentation/input/devices/xpad.rst'
235