xref: /linux/Documentation/input/devices/joystick-parport.rst (revision c532de5a67a70f8533d495f8f2aaa9a0491c3ad0)
1.. include:: <isonum.txt>
2
3.. _joystick-parport:
4
5==============================
6Parallel Port Joystick Drivers
7==============================
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
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
23Introduction
24============
25
26The joystick parport drivers are used for joysticks and gamepads not
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
33Devices supported
34=================
35
36Many console and 8-bit computer gamepads and joysticks are supported. The
37following subsections discuss usage of each.
38
39NES and SNES
40------------
41
42The Nintendo Entertainment System and Super Nintendo Entertainment System
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
48All NES and SNES use the same synchronous serial protocol, clocked from
49the computer's side (and thus timing insensitive). To allow up to 5 NES
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.
53
54This protocol is handled by the gamecon.c driver, so that's the one
55you'll use for NES, SNES gamepads and SNES mice.
56
57The main problem with PC parallel ports is that they don't have +5V power
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
63If you want to use the parallel port only, you can take the power is from
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
67port, anything between and including pin 4 and pin 9 will work::
68
69    (pin 9) -----> Power
70
71Unfortunately, there are pads that need a lot more of power, and parallel
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
74port), and combine the currents of two or more data bits together::
75
76	      Diodes
77    (pin 9) ----|>|-------+------> Power
78			|
79    (pin 8) ----|>|-------+
80			|
81    (pin 7) ----|>|-------+
82			|
83    <and so on>         :
84			|
85    (pin 4) ----|>|-------+
86
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::
89
90    (pin 18) -----> Ground
91
92NES and SNES pads have two input bits, Clock and Latch, which drive the
93serial transfer. These are connected to pins 2 and 3 of the parallel port,
94respectively::
95
96    (pin 2) -----> Clock
97    (pin 3) -----> Latch
98
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::
101
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
107
108Note that pin 14 is not used, since it is not an input pin on the parallel
109port.
110
111This is everything you need on the PC's side of the connection, now on to
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
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        | | |                              ___________________
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                             |     |     |
144         |   |                                |     |     +----> Clock
145         |   +----> Power                     |     +----------> Latch
146         +--------> Ground                    +----------------> Power
147
148Multisystem joysticks
149---------------------
150
151In the era of 8-bit machines, there was something like de-facto standard
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
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
230
231  And there were many others.
232
233Multisystem joysticks using db9.c
234~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
235
236For the Multisystem joysticks, and their derivatives, the db9.c driver
237was written. It allows only one joystick / gamepad per parallel port, but
238the interface is easy to build and works with almost anything.
239
240For the basic 1-button Multisystem joystick you connect its wires to the
241parallel port like this::
242
243    (pin  1) -----> Power
244    (pin 18) -----> Ground
245
246    (pin  2) -----> Up
247    (pin  3) -----> Down
248    (pin  4) -----> Left
249    (pin  5) -----> Right
250    (pin  6) -----> Button 1
251
252However, if the joystick is switch based (eg. clicks when you move it),
253you might or might not, depending on your parallel port, need 10 kOhm pullup
254resistors on each of the direction and button signals, like this::
255
256    (pin 2) ------------+------> Up
257              Resistor  |
258    (pin 1) --[10kOhm]--+
259
260Try without, and if it doesn't work, add them. For TTL based joysticks /
261gamepads the pullups are not needed.
262
263For joysticks with two buttons you connect the second button to pin 7 on
264the parallel port::
265
266    (pin 7) -----> Button 2
267
268And that's it.
269
270On a side note, if you have already built a different adapter for use with
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
274Multisystem joysticks using gamecon.c
275~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
276
277For some people just one joystick per parallel port is not enough, and/or
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
282However, there is nothing for free. To allow more sticks to be used at
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
288Also, the connection is a bit more complex. You'll need a bunch of diodes,
289and one pullup resistor. First, you connect the Directions and the button
290the same as for db9, however with the diodes between::
291
292                Diodes
293    (pin 2) -----|<|----> Up
294    (pin 3) -----|<|----> Down
295    (pin 4) -----|<|----> Left
296    (pin 5) -----|<|----> Right
297    (pin 6) -----|<|----> Button 1
298
299For two button sticks you also connect the other button::
300
301    (pin 7) -----|<|----> Button 2
302
303And finally, you connect the Ground wire of the joystick, like done in
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
306for each joystick. The power source is shared::
307
308    Data    ------------+-----> Ground
309              Resistor  |
310    Power   --[10kOhm]--+
311
312And that's all, here we go!
313
314Multisystem joysticks using turbografx.c
315~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
316
317The TurboGraFX interface, designed by
318
319	Steffen Schwenke <schwenke@burg-halle.de>
320
321allows up to 7 Multisystem joysticks connected to the parallel port. In
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
325interface, see:
326
327	http://www2.burg-halle.de/~schwenke/parport.html
328
329Sony Playstation
330----------------
331
332The PSX controller is supported by the gamecon.c. Pinout of the PSX
333controller (compatible with DirectPadPro)::
334
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)
345
346The driver supports these controllers:
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
355Sega
356----
357
358All the Sega controllers are more or less based on the standard 2-button
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
362Sega Master System
363~~~~~~~~~~~~~~~~~~
364
365The SMS gamepads are almost exactly the same as normal 2-button
366Multisystem joysticks. Set the driver to Multi2 mode, use the corresponding
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
388to the Sega Master System pads. They use more buttons (3+1, 5+1, 6+1).  Use
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
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
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
444Multi joysticks using db9.c
445
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
483The drivers
484===========
485
486There are three drivers for the parallel port interfaces. Each, as
487described above, allows to connect a different group of joysticks and pads.
488Here are described their command lines:
489
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::
495
496	gamecon.map=port,pad1,pad2,pad3,pad4,pad5
497
498Where ``port`` the number of the parport interface (eg. 0 for parport0).
499
500And ``pad1`` to ``pad5`` are pad types connected to different data input pins
501(10,11,12,13,15), as described in section 2.1 of this file.
502
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
520hot swapping should work (but is not recommended).
521
522Should you want to use more than one of parallel ports at once, you can use
523gamecon.map2 and gamecon.map3 as additional command line parameters for two
524more parallel ports.
525
526There are two options specific to PSX driver portion.  gamecon.psx_delay sets
527the command delay when talking to the controllers. The default of 25 should
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
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
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::
538
539	db9.dev=port,type
540
541Where ``port`` is the number of the parport interface (eg. 0 for parport0).
542
543Caveat here: This driver only works on bidirectional parallel ports. If
544your parallel port is recent enough, you should have no trouble with this.
545Old parallel ports may not have this feature.
546
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
565can use db9.dev2 and db9.dev3 as additional command line parameters for two
566more joysticks/pads.
567
568turbografx.c
569------------
570
571The turbografx.c driver uses a very simple kernel/module command line::
572
573	turbografx.map=port,js1,js2,js3,js4,js5,js6,js7
574
575Where ``port`` is the number of the parport interface (eg. 0 for parport0).
576
577``jsX`` is the number of buttons the Multisystem joysticks connected to the
578interface ports 1-7 have. For a standard multisystem joystick, this is 1.
579
580Should you want to use more than one of these interfaces at once, you can
581use turbografx.map2 and turbografx.map3 as additional command line parameters
582for two more interfaces.
583
584PC parallel port pinout
585=======================
586
587::
588
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
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!
612