Merge tag 'drm-msm-fixes-2022-06-20' of https://gitlab.freedesktop.org/drm/msm into...
[linux-block.git] / Documentation / input / devices / joystick-parport.rst
CommitLineData
c8ae270e
MCC
1.. include:: <isonum.txt>
2
3.. _joystick-parport:
4
4c79e98b 5==============================
b08c118c 6Parallel Port Joystick Drivers
4c79e98b 7==============================
c8ae270e
MCC
8
9:Copyright: |copy| 1998-2000 Vojtech Pavlik <vojtech@ucw.cz>
10:Copyright: |copy| 1998 Andree Borrmann <a.borrmann@tu-bs.de>
11
12
13Sponsored by SuSE
14
15Disclaimer
16==========
17
18Any information in this file is provided as-is, without any guarantee that
1da177e4
LT
19it will be true. So, use it at your own risk. The possible damages that can
20happen include burning your parallel port, and/or the sticks and joystick
21and maybe even more. Like when a lightning kills you it is not our problem.
22
4c79e98b
DT
23Introduction
24============
c8ae270e
MCC
25
26The joystick parport drivers are used for joysticks and gamepads not
1da177e4
LT
27originally designed for PCs and other computers Linux runs on. Because of
28that, PCs usually lack the right ports to connect these devices to. Parallel
29port, because of its ability to change single bits at will, and providing
30both output and input bits is the most suitable port on the PC for
31connecting such devices.
32
c8ae270e
MCC
33Devices supported
34=================
35
36Many console and 8-bit computer gamepads and joysticks are supported. The
1da177e4
LT
37following subsections discuss usage of each.
38
c8ae270e
MCC
39NES and SNES
40------------
41
42The Nintendo Entertainment System and Super Nintendo Entertainment System
1da177e4
LT
43gamepads are widely available, and easy to get. Also, they are quite easy to
44connect to a PC, and don't need much processing speed (108 us for NES and
45165 us for SNES, compared to about 1000 us for PC gamepads) to communicate
46with them.
47
c8ae270e 48All NES and SNES use the same synchronous serial protocol, clocked from
1da177e4 49the computer's side (and thus timing insensitive). To allow up to 5 NES
b157d55e
RA
50and/or SNES gamepads and/or SNES mice connected to the parallel port at once,
51the output lines of the parallel port are shared, while one of 5 available
52input lines is assigned to each gamepad.
1da177e4 53
c8ae270e 54This protocol is handled by the gamecon.c driver, so that's the one
b157d55e 55you'll use for NES, SNES gamepads and SNES mice.
1da177e4 56
c8ae270e 57The main problem with PC parallel ports is that they don't have +5V power
1da177e4
LT
58source on any of their pins. So, if you want a reliable source of power
59for your pads, use either keyboard or joystick port, and make a pass-through
60cable. You can also pull the power directly from the power supply (the red
61wire is +5V).
62
c8ae270e 63If you want to use the parallel port only, you can take the power is from
1da177e4
LT
64some data pin. For most gamepad and parport implementations only one pin is
65needed, and I'd recommend pin 9 for that, the highest data bit. On the other
66hand, if you are not planning to use anything else than NES / SNES on the
c8ae270e 67port, anything between and including pin 4 and pin 9 will work::
1da177e4 68
c8ae270e 69 (pin 9) -----> Power
1da177e4 70
c8ae270e 71Unfortunately, there are pads that need a lot more of power, and parallel
1da177e4
LT
72ports that can't give much current through the data pins. If this is your
73case, you'll need to use diodes (as a prevention of destroying your parallel
c8ae270e 74port), and combine the currents of two or more data bits together::
1da177e4 75
c8ae270e
MCC
76 Diodes
77 (pin 9) ----|>|-------+------> Power
78 |
79 (pin 8) ----|>|-------+
80 |
81 (pin 7) ----|>|-------+
82 |
83 <and so on> :
84 |
85 (pin 4) ----|>|-------+
1da177e4 86
c8ae270e
MCC
87Ground is quite easy. On PC's parallel port the ground is on any of the
88pins from pin 18 to pin 25. So use any pin of these you like for the ground::
1da177e4 89
c8ae270e 90 (pin 18) -----> Ground
1da177e4 91
c8ae270e 92NES and SNES pads have two input bits, Clock and Latch, which drive the
1da177e4 93serial transfer. These are connected to pins 2 and 3 of the parallel port,
c8ae270e 94respectively::
1da177e4 95
c8ae270e
MCC
96 (pin 2) -----> Clock
97 (pin 3) -----> Latch
1da177e4 98
c8ae270e
MCC
99And the last thing is the NES / SNES data wire. Only that isn't shared and
100each pad needs its own data pin. The parallel port pins are::
1da177e4 101
c8ae270e
MCC
102 (pin 10) -----> Pad 1 data
103 (pin 11) -----> Pad 2 data
104 (pin 12) -----> Pad 3 data
105 (pin 13) -----> Pad 4 data
106 (pin 15) -----> Pad 5 data
1da177e4 107
c8ae270e 108Note that pin 14 is not used, since it is not an input pin on the parallel
1da177e4
LT
109port.
110
c8ae270e 111This is everything you need on the PC's side of the connection, now on to
1da177e4
LT
112the gamepads side. The NES and SNES have different connectors. Also, there
113are quite a lot of NES clones, and because Nintendo used proprietary
114connectors for their machines, the cloners couldn't and used standard D-Cannon
115connectors. Anyway, if you've got a gamepad, and it has buttons A, B, Turbo
116A, Turbo B, Select and Start, and is connected through 5 wires, then it is
117either a NES or NES clone and will work with this connection. SNES gamepads
c8ae270e
MCC
118also use 5 wires, but have more buttons. They will work as well, of course::
119
120 Pinout for NES gamepads Pinout for SNES gamepads and mice
121
122 +----> Power +-----------------------\
123 | 7 | o o o o | x x o | 1
124 5 +---------+ 7 +-----------------------/
125 | x x o \ | | | | |
126 | o o o o | | | | | +-> Ground
127 4 +------------+ 1 | | | +------------> Data
128 | | | | | | +---------------> Latch
129 | | | +-> Ground | +------------------> Clock
130 | | +----> Clock +---------------------> Power
131 | +-------> Latch
132 +----------> Data
133
134 Pinout for NES clone (db9) gamepads Pinout for NES clone (db15) gamepads
135
136 +---------> Clock +-----------------> Data
137 | +-------> Latch | +---> Ground
138 | | +-----> Data | |
139 | | | ___________________
1da177e4
LT
140 _____________ 8 \ o x x x x x x o / 1
141 5 \ x o o o x / 1 \ o x x o x x o /
142 \ x o x o / 15 `~~~~~~~~~~~~~' 9
143 9 `~~~~~~~' 6 | | |
c8ae270e
MCC
144 | | | | +----> Clock
145 | +----> Power | +----------> Latch
146 +--------> Ground +----------------> Power
147
148Multisystem joysticks
149---------------------
1da177e4 150
c8ae270e 151In the era of 8-bit machines, there was something like de-facto standard
1da177e4
LT
152for joystick ports. They were all digital, and all used D-Cannon 9 pin
153connectors (db9). Because of that, a single joystick could be used without
154hassle on Atari (130, 800XE, 800XL, 2600, 7200), Amiga, Commodore C64,
155Amstrad CPC, Sinclair ZX Spectrum and many other machines. That's why these
156joysticks are called "Multisystem".
157
c8ae270e
MCC
158Now their pinout::
159
160 +---------> Right
161 | +-------> Left
162 | | +-----> Down
163 | | | +---> Up
164 | | | |
165 _____________
166 5 \ x o o o o / 1
167 \ x o x o /
168 9 `~~~~~~~' 6
169 | |
170 | +----> Button
171 +--------> Ground
172
173However, as time passed, extensions to this standard developed, and these
174were not compatible with each other::
175
176
177 Atari 130, 800/XL/XE MSX
178
179 +-----------> Power
180 +---------> Right | +---------> Right
181 | +-------> Left | | +-------> Left
182 | | +-----> Down | | | +-----> Down
183 | | | +---> Up | | | | +---> Up
184 | | | | | | | | |
185 _____________ _____________
186 5 \ x o o o o / 1 5 \ o o o o o / 1
187 \ x o o o / \ o o o o /
188 9 `~~~~~~~' 6 9 `~~~~~~~' 6
189 | | | | | | |
190 | | +----> Button | | | +----> Button 1
191 | +------> Power | | +------> Button 2
192 +--------> Ground | +--------> Output 3
193 +----------> Ground
194
195 Amstrad CPC Commodore C64
196
197 +-----------> Analog Y
198 +---------> Right | +---------> Right
199 | +-------> Left | | +-------> Left
200 | | +-----> Down | | | +-----> Down
201 | | | +---> Up | | | | +---> Up
202 | | | | | | | | |
203 _____________ _____________
204 5 \ x o o o o / 1 5 \ o o o o o / 1
205 \ x o o o / \ o o o o /
206 9 `~~~~~~~' 6 9 `~~~~~~~' 6
207 | | | | | | |
208 | | +----> Button 1 | | | +----> Button
209 | +------> Button 2 | | +------> Power
210 +--------> Ground | +--------> Ground
211 +----------> Analog X
212
213 Sinclair Spectrum +2A/+3 Amiga 1200
214
215 +-----------> Up +-----------> Button 3
216 | +---------> Fire | +---------> Right
217 | | | | +-------> Left
218 | | +-----> Ground | | | +-----> Down
219 | | | | | | | +---> Up
220 | | | | | | | |
221 _____________ _____________
222 5 \ o o x o x / 1 5 \ o o o o o / 1
223 \ o o o o / \ o o o o /
224 9 `~~~~~~~' 6 9 `~~~~~~~' 6
225 | | | | | | | |
226 | | | +----> Right | | | +----> Button 1
227 | | +------> Left | | +------> Power
228 | +--------> Ground | +--------> Ground
229 +----------> Down +----------> Button 2
1da177e4
LT
230
231 And there were many others.
232
c8ae270e
MCC
233Multisystem joysticks using db9.c
234~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
235
236For the Multisystem joysticks, and their derivatives, the db9.c driver
1da177e4
LT
237was written. It allows only one joystick / gamepad per parallel port, but
238the interface is easy to build and works with almost anything.
239
c8ae270e
MCC
240For the basic 1-button Multisystem joystick you connect its wires to the
241parallel port like this::
1da177e4 242
c8ae270e
MCC
243 (pin 1) -----> Power
244 (pin 18) -----> Ground
1da177e4 245
c8ae270e
MCC
246 (pin 2) -----> Up
247 (pin 3) -----> Down
248 (pin 4) -----> Left
249 (pin 5) -----> Right
250 (pin 6) -----> Button 1
1da177e4 251
c8ae270e 252However, if the joystick is switch based (eg. clicks when you move it),
1da177e4 253you might or might not, depending on your parallel port, need 10 kOhm pullup
c8ae270e 254resistors on each of the direction and button signals, like this::
1da177e4 255
c8ae270e
MCC
256 (pin 2) ------------+------> Up
257 Resistor |
258 (pin 1) --[10kOhm]--+
1da177e4 259
c8ae270e 260Try without, and if it doesn't work, add them. For TTL based joysticks /
1da177e4
LT
261gamepads the pullups are not needed.
262
c8ae270e
MCC
263For joysticks with two buttons you connect the second button to pin 7 on
264the parallel port::
1da177e4 265
c8ae270e 266 (pin 7) -----> Button 2
1da177e4 267
c8ae270e 268And that's it.
1da177e4 269
c8ae270e 270On a side note, if you have already built a different adapter for use with
1da177e4
LT
271the digital joystick driver 0.8.0.2, this is also supported by the db9.c
272driver, as device type 8. (See section 3.2)
273
c8ae270e
MCC
274Multisystem joysticks using gamecon.c
275~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
276
277For some people just one joystick per parallel port is not enough, and/or
1da177e4
LT
278want to use them on one parallel port together with NES/SNES/PSX pads. This is
279possible using the gamecon.c. It supports up to 5 devices of the above types,
280including 1 and 2 buttons Multisystem joysticks.
281
c8ae270e 282However, there is nothing for free. To allow more sticks to be used at
1da177e4
LT
283once, you need the sticks to be purely switch based (that is non-TTL), and
284not to need power. Just a plain simple six switches inside. If your
285joystick can do more (eg. turbofire) you'll need to disable it totally first
286if you want to use gamecon.c.
287
c8ae270e 288Also, the connection is a bit more complex. You'll need a bunch of diodes,
1da177e4 289and one pullup resistor. First, you connect the Directions and the button
c8ae270e 290the same as for db9, however with the diodes between::
1da177e4 291
c8ae270e
MCC
292 Diodes
293 (pin 2) -----|<|----> Up
294 (pin 3) -----|<|----> Down
295 (pin 4) -----|<|----> Left
296 (pin 5) -----|<|----> Right
297 (pin 6) -----|<|----> Button 1
1da177e4 298
c8ae270e 299For two button sticks you also connect the other button::
1da177e4 300
c8ae270e 301 (pin 7) -----|<|----> Button 2
1da177e4 302
c8ae270e 303And finally, you connect the Ground wire of the joystick, like done in
1da177e4
LT
304this little schematic to Power and Data on the parallel port, as described
305for the NES / SNES pads in section 2.1 of this file - that is, one data pin
c8ae270e
MCC
306for each joystick. The power source is shared::
307
308 Data ------------+-----> Ground
309 Resistor |
310 Power --[10kOhm]--+
1da177e4 311
c8ae270e 312And that's all, here we go!
1da177e4 313
c8ae270e
MCC
314Multisystem joysticks using turbografx.c
315~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1da177e4 316
c8ae270e 317The TurboGraFX interface, designed by
1da177e4
LT
318
319 Steffen Schwenke <schwenke@burg-halle.de>
320
c8ae270e 321allows up to 7 Multisystem joysticks connected to the parallel port. In
1da177e4
LT
322Steffen's version, there is support for up to 5 buttons per joystick. However,
323since this doesn't work reliably on all parallel ports, the turbografx.c driver
324supports only one button per joystick. For more information on how to build the
c8ae270e 325interface, see:
1da177e4
LT
326
327 http://www2.burg-halle.de/~schwenke/parport.html
328
c8ae270e
MCC
329Sony Playstation
330----------------
1da177e4 331
c8ae270e
MCC
332The PSX controller is supported by the gamecon.c. Pinout of the PSX
333controller (compatible with DirectPadPro)::
1da177e4 334
c8ae270e
MCC
335 +---------+---------+---------+
336 9 | o o o | o o o | o o o | 1 parallel
337 \________|_________|________/ port pins
338 | | | | | |
339 | | | | | +--------> Clock --- (4)
340 | | | | +------------> Select --- (3)
341 | | | +---------------> Power --- (5-9)
342 | | +------------------> Ground --- (18-25)
343 | +-------------------------> Command --- (2)
344 +----------------------------> Data --- (one of 10,11,12,13,15)
1da177e4 345
c8ae270e 346The driver supports these controllers:
1da177e4
LT
347
348 * Standard PSX Pad
349 * NegCon PSX Pad
350 * Analog PSX Pad (red mode)
351 * Analog PSX Pad (green mode)
352 * PSX Rumble Pad
353 * PSX DDR Pad
354
c8ae270e
MCC
355Sega
356----
357
358All the Sega controllers are more or less based on the standard 2-button
1da177e4
LT
359Multisystem joystick. However, since they don't use switches and use TTL
360logic, the only driver usable with them is the db9.c driver.
361
c8ae270e
MCC
362Sega Master System
363~~~~~~~~~~~~~~~~~~
364
365The SMS gamepads are almost exactly the same as normal 2-button
1da177e4 366Multisystem joysticks. Set the driver to Multi2 mode, use the corresponding
c8ae270e
MCC
367parallel port pins, and the following schematic::
368
369 +-----------> Power
370 | +---------> Right
371 | | +-------> Left
372 | | | +-----> Down
373 | | | | +---> Up
374 | | | | |
375 _____________
376 5 \ o o o o o / 1
377 \ o o x o /
378 9 `~~~~~~~' 6
379 | | |
380 | | +----> Button 1
381 | +--------> Ground
382 +----------> Button 2
383
384Sega Genesis aka MegaDrive
385~~~~~~~~~~~~~~~~~~~~~~~~~~
386
387The Sega Genesis (in Europe sold as Sega MegaDrive) pads are an extension
1da177e4 388to the Sega Master System pads. They use more buttons (3+1, 5+1, 6+1). Use
c8ae270e
MCC
389the following schematic::
390
391 +-----------> Power
392 | +---------> Right
393 | | +-------> Left
394 | | | +-----> Down
395 | | | | +---> Up
396 | | | | |
397 _____________
398 5 \ o o o o o / 1
399 \ o o o o /
400 9 `~~~~~~~' 6
401 | | | |
402 | | | +----> Button 1
403 | | +------> Select
404 | +--------> Ground
405 +----------> Button 2
406
407The Select pin goes to pin 14 on the parallel port::
408
409 (pin 14) -----> Select
410
411The rest is the same as for Multi2 joysticks using db9.c
412
413Sega Saturn
414~~~~~~~~~~~
415
416Sega Saturn has eight buttons, and to transfer that, without hacks like
1da177e4
LT
417Genesis 6 pads use, it needs one more select pin. Anyway, it is still
418handled by the db9.c driver. Its pinout is very different from anything
c8ae270e
MCC
419else. Use this schematic::
420
421 +-----------> Select 1
422 | +---------> Power
423 | | +-------> Up
424 | | | +-----> Down
425 | | | | +---> Ground
426 | | | | |
427 _____________
428 5 \ o o o o o / 1
429 \ o o o o /
430 9 `~~~~~~~' 6
431 | | | |
432 | | | +----> Select 2
433 | | +------> Right
434 | +--------> Left
435 +----------> Power
436
437Select 1 is pin 14 on the parallel port, Select 2 is pin 16 on the
438parallel port::
439
440 (pin 14) -----> Select 1
441 (pin 16) -----> Select 2
442
443The other pins (Up, Down, Right, Left, Power, Ground) are the same as for
1da177e4
LT
444Multi joysticks using db9.c
445
b8a91560
DT
446Amiga CD32
447----------
448
449Amiga CD32 joypad uses the following pinout::
450
451 +-----------> Button 3
452 | +---------> Right
453 | | +-------> Left
454 | | | +-----> Down
455 | | | | +---> Up
456 | | | | |
457 _____________
458 5 \ o o o o o / 1
459 \ o o o o /
460 9 `~~~~~~~' 6
461 | | | |
462 | | | +----> Button 1
463 | | +------> Power
464 | +--------> Ground
465 +----------> Button 2
466
467It can be connected to the parallel port and driven by db9.c driver. It needs the following wiring:
468
469 ============ =============
470 CD32 pad Parallel port
471 ============ =============
472 1 (Up) 2 (D0)
473 2 (Down) 3 (D1)
474 3 (Left) 4 (D2)
475 4 (Right) 5 (D3)
476 5 (Button 3) 14 (AUTOFD)
477 6 (Button 1) 17 (SELIN)
478 7 (+5V) 1 (STROBE)
479 8 (Gnd) 18 (Gnd)
480 9 (Button 2) 7 (D5)
481 ============ =============
482
c8ae270e
MCC
483The drivers
484===========
485
486There are three drivers for the parallel port interfaces. Each, as
1da177e4
LT
487described above, allows to connect a different group of joysticks and pads.
488Here are described their command lines:
489
c8ae270e
MCC
490gamecon.c
491---------
492
493Using gamecon.c you can connect up to five devices to one parallel port. It
494uses the following kernel/module command line::
1da177e4
LT
495
496 gamecon.map=port,pad1,pad2,pad3,pad4,pad5
497
c8ae270e 498Where ``port`` the number of the parport interface (eg. 0 for parport0).
1da177e4 499
c8ae270e 500And ``pad1`` to ``pad5`` are pad types connected to different data input pins
1da177e4
LT
501(10,11,12,13,15), as described in section 2.1 of this file.
502
c8ae270e
MCC
503The types are:
504
505 ===== =============================
506 Type Joystick/Pad
507 ===== =============================
508 0 None
509 1 SNES pad
510 2 NES pad
511 4 Multisystem 1-button joystick
512 5 Multisystem 2-button joystick
513 6 N64 pad
514 7 Sony PSX controller
515 8 Sony PSX DDR controller
516 9 SNES mouse
517 ===== =============================
518
519The exact type of the PSX controller type is autoprobed when used, so
d6bc8ac9 520hot swapping should work (but is not recommended).
1da177e4 521
c8ae270e 522Should you want to use more than one of parallel ports at once, you can use
1da177e4
LT
523gamecon.map2 and gamecon.map3 as additional command line parameters for two
524more parallel ports.
525
c8ae270e 526There are two options specific to PSX driver portion. gamecon.psx_delay sets
1da177e4 527the command delay when talking to the controllers. The default of 25 should
992caacf
ML
528work but you can try lowering it for better performance. If your pads don't
529respond try raising it until they work. Setting the type to 8 allows the
1da177e4
LT
530driver to be used with Dance Dance Revolution or similar games. Arrow keys are
531registered as key presses instead of X and Y axes.
532
c8ae270e
MCC
533db9.c
534-----
535
536Apart from making an interface, there is nothing difficult on using the
537db9.c driver. It uses the following kernel/module command line::
1da177e4
LT
538
539 db9.dev=port,type
540
c8ae270e 541Where ``port`` is the number of the parport interface (eg. 0 for parport0).
1da177e4 542
c8ae270e 543Caveat here: This driver only works on bidirectional parallel ports. If
1da177e4
LT
544your parallel port is recent enough, you should have no trouble with this.
545Old parallel ports may not have this feature.
546
c8ae270e
MCC
547``Type`` is the type of joystick or pad attached:
548
549 ===== ======================================================
550 Type Joystick/Pad
551 ===== ======================================================
552 0 None
553 1 Multisystem 1-button joystick
554 2 Multisystem 2-button joystick
555 3 Genesis pad (3+1 buttons)
556 5 Genesis pad (5+1 buttons)
557 6 Genesis pad (6+2 buttons)
558 7 Saturn pad (8 buttons)
559 8 Multisystem 1-button joystick (v0.8.0.2 pin-out)
560 9 Two Multisystem 1-button joysticks (v0.8.0.2 pin-out)
561 10 Amiga CD32 pad
562 ===== ======================================================
563
564Should you want to use more than one of these joysticks/pads at once, you
1da177e4
LT
565can use db9.dev2 and db9.dev3 as additional command line parameters for two
566more joysticks/pads.
567
c8ae270e
MCC
568turbografx.c
569------------
570
571The turbografx.c driver uses a very simple kernel/module command line::
1da177e4
LT
572
573 turbografx.map=port,js1,js2,js3,js4,js5,js6,js7
574
c8ae270e 575Where ``port`` is the number of the parport interface (eg. 0 for parport0).
1da177e4 576
c8ae270e 577``jsX`` is the number of buttons the Multisystem joysticks connected to the
1da177e4
LT
578interface ports 1-7 have. For a standard multisystem joystick, this is 1.
579
c8ae270e 580Should you want to use more than one of these interfaces at once, you can
1da177e4
LT
581use turbografx.map2 and turbografx.map3 as additional command line parameters
582for two more interfaces.
583
c8ae270e 584PC parallel port pinout
4c79e98b 585=======================
c8ae270e
MCC
586
587::
588
1da177e4
LT
589 .----------------------------------------.
590 At the PC: \ 13 12 11 10 9 8 7 6 5 4 3 2 1 /
591 \ 25 24 23 22 21 20 19 18 17 16 15 14 /
592 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
593
c8ae270e
MCC
594====== ======= =============
595 Pin Name Description
596====== ======= =============
597 1 /STROBE Strobe
598 2-9 D0-D7 Data Bit 0-7
599 10 /ACK Acknowledge
600 11 BUSY Busy
601 12 PE Paper End
602 13 SELIN Select In
603 14 /AUTOFD Autofeed
604 15 /ERROR Error
605 16 /INIT Initialize
606 17 /SEL Select
607 18-25 GND Signal Ground
608====== ======= =============
609
610
611That's all, folks! Have fun!