0001 .. include:: <isonum.txt>
0002
0003 .. _joystick-parport:
0004
0005 ==============================
0006 Parallel Port Joystick Drivers
0007 ==============================
0008
0009 :Copyright: |copy| 1998-2000 Vojtech Pavlik <vojtech@ucw.cz>
0010 :Copyright: |copy| 1998 Andree Borrmann <a.borrmann@tu-bs.de>
0011
0012
0013 Sponsored by SuSE
0014
0015 Disclaimer
0016 ==========
0017
0018 Any information in this file is provided as-is, without any guarantee that
0019 it will be true. So, use it at your own risk. The possible damages that can
0020 happen include burning your parallel port, and/or the sticks and joystick
0021 and maybe even more. Like when a lightning kills you it is not our problem.
0022
0023 Introduction
0024 ============
0025
0026 The joystick parport drivers are used for joysticks and gamepads not
0027 originally designed for PCs and other computers Linux runs on. Because of
0028 that, PCs usually lack the right ports to connect these devices to. Parallel
0029 port, because of its ability to change single bits at will, and providing
0030 both output and input bits is the most suitable port on the PC for
0031 connecting such devices.
0032
0033 Devices supported
0034 =================
0035
0036 Many console and 8-bit computer gamepads and joysticks are supported. The
0037 following subsections discuss usage of each.
0038
0039 NES and SNES
0040 ------------
0041
0042 The Nintendo Entertainment System and Super Nintendo Entertainment System
0043 gamepads are widely available, and easy to get. Also, they are quite easy to
0044 connect to a PC, and don't need much processing speed (108 us for NES and
0045 165 us for SNES, compared to about 1000 us for PC gamepads) to communicate
0046 with them.
0047
0048 All NES and SNES use the same synchronous serial protocol, clocked from
0049 the computer's side (and thus timing insensitive). To allow up to 5 NES
0050 and/or SNES gamepads and/or SNES mice connected to the parallel port at once,
0051 the output lines of the parallel port are shared, while one of 5 available
0052 input lines is assigned to each gamepad.
0053
0054 This protocol is handled by the gamecon.c driver, so that's the one
0055 you'll use for NES, SNES gamepads and SNES mice.
0056
0057 The main problem with PC parallel ports is that they don't have +5V power
0058 source on any of their pins. So, if you want a reliable source of power
0059 for your pads, use either keyboard or joystick port, and make a pass-through
0060 cable. You can also pull the power directly from the power supply (the red
0061 wire is +5V).
0062
0063 If you want to use the parallel port only, you can take the power is from
0064 some data pin. For most gamepad and parport implementations only one pin is
0065 needed, and I'd recommend pin 9 for that, the highest data bit. On the other
0066 hand, if you are not planning to use anything else than NES / SNES on the
0067 port, anything between and including pin 4 and pin 9 will work::
0068
0069 (pin 9) -----> Power
0070
0071 Unfortunately, there are pads that need a lot more of power, and parallel
0072 ports that can't give much current through the data pins. If this is your
0073 case, you'll need to use diodes (as a prevention of destroying your parallel
0074 port), and combine the currents of two or more data bits together::
0075
0076 Diodes
0077 (pin 9) ----|>|-------+------> Power
0078 |
0079 (pin 8) ----|>|-------+
0080 |
0081 (pin 7) ----|>|-------+
0082 |
0083 <and so on> :
0084 |
0085 (pin 4) ----|>|-------+
0086
0087 Ground is quite easy. On PC's parallel port the ground is on any of the
0088 pins from pin 18 to pin 25. So use any pin of these you like for the ground::
0089
0090 (pin 18) -----> Ground
0091
0092 NES and SNES pads have two input bits, Clock and Latch, which drive the
0093 serial transfer. These are connected to pins 2 and 3 of the parallel port,
0094 respectively::
0095
0096 (pin 2) -----> Clock
0097 (pin 3) -----> Latch
0098
0099 And the last thing is the NES / SNES data wire. Only that isn't shared and
0100 each pad needs its own data pin. The parallel port pins are::
0101
0102 (pin 10) -----> Pad 1 data
0103 (pin 11) -----> Pad 2 data
0104 (pin 12) -----> Pad 3 data
0105 (pin 13) -----> Pad 4 data
0106 (pin 15) -----> Pad 5 data
0107
0108 Note that pin 14 is not used, since it is not an input pin on the parallel
0109 port.
0110
0111 This is everything you need on the PC's side of the connection, now on to
0112 the gamepads side. The NES and SNES have different connectors. Also, there
0113 are quite a lot of NES clones, and because Nintendo used proprietary
0114 connectors for their machines, the cloners couldn't and used standard D-Cannon
0115 connectors. Anyway, if you've got a gamepad, and it has buttons A, B, Turbo
0116 A, Turbo B, Select and Start, and is connected through 5 wires, then it is
0117 either a NES or NES clone and will work with this connection. SNES gamepads
0118 also use 5 wires, but have more buttons. They will work as well, of course::
0119
0120 Pinout for NES gamepads Pinout for SNES gamepads and mice
0121
0122 +----> Power +-----------------------\
0123 | 7 | o o o o | x x o | 1
0124 5 +---------+ 7 +-----------------------/
0125 | x x o \ | | | | |
0126 | o o o o | | | | | +-> Ground
0127 4 +------------+ 1 | | | +------------> Data
0128 | | | | | | +---------------> Latch
0129 | | | +-> Ground | +------------------> Clock
0130 | | +----> Clock +---------------------> Power
0131 | +-------> Latch
0132 +----------> Data
0133
0134 Pinout for NES clone (db9) gamepads Pinout for NES clone (db15) gamepads
0135
0136 +---------> Clock +-----------------> Data
0137 | +-------> Latch | +---> Ground
0138 | | +-----> Data | |
0139 | | | ___________________
0140 _____________ 8 \ o x x x x x x o / 1
0141 5 \ x o o o x / 1 \ o x x o x x o /
0142 \ x o x o / 15 `~~~~~~~~~~~~~' 9
0143 9 `~~~~~~~' 6 | | |
0144 | | | | +----> Clock
0145 | +----> Power | +----------> Latch
0146 +--------> Ground +----------------> Power
0147
0148 Multisystem joysticks
0149 ---------------------
0150
0151 In the era of 8-bit machines, there was something like de-facto standard
0152 for joystick ports. They were all digital, and all used D-Cannon 9 pin
0153 connectors (db9). Because of that, a single joystick could be used without
0154 hassle on Atari (130, 800XE, 800XL, 2600, 7200), Amiga, Commodore C64,
0155 Amstrad CPC, Sinclair ZX Spectrum and many other machines. That's why these
0156 joysticks are called "Multisystem".
0157
0158 Now their pinout::
0159
0160 +---------> Right
0161 | +-------> Left
0162 | | +-----> Down
0163 | | | +---> Up
0164 | | | |
0165 _____________
0166 5 \ x o o o o / 1
0167 \ x o x o /
0168 9 `~~~~~~~' 6
0169 | |
0170 | +----> Button
0171 +--------> Ground
0172
0173 However, as time passed, extensions to this standard developed, and these
0174 were not compatible with each other::
0175
0176
0177 Atari 130, 800/XL/XE MSX
0178
0179 +-----------> Power
0180 +---------> Right | +---------> Right
0181 | +-------> Left | | +-------> Left
0182 | | +-----> Down | | | +-----> Down
0183 | | | +---> Up | | | | +---> Up
0184 | | | | | | | | |
0185 _____________ _____________
0186 5 \ x o o o o / 1 5 \ o o o o o / 1
0187 \ x o o o / \ o o o o /
0188 9 `~~~~~~~' 6 9 `~~~~~~~' 6
0189 | | | | | | |
0190 | | +----> Button | | | +----> Button 1
0191 | +------> Power | | +------> Button 2
0192 +--------> Ground | +--------> Output 3
0193 +----------> Ground
0194
0195 Amstrad CPC Commodore C64
0196
0197 +-----------> Analog Y
0198 +---------> Right | +---------> Right
0199 | +-------> Left | | +-------> Left
0200 | | +-----> Down | | | +-----> Down
0201 | | | +---> Up | | | | +---> Up
0202 | | | | | | | | |
0203 _____________ _____________
0204 5 \ x o o o o / 1 5 \ o o o o o / 1
0205 \ x o o o / \ o o o o /
0206 9 `~~~~~~~' 6 9 `~~~~~~~' 6
0207 | | | | | | |
0208 | | +----> Button 1 | | | +----> Button
0209 | +------> Button 2 | | +------> Power
0210 +--------> Ground | +--------> Ground
0211 +----------> Analog X
0212
0213 Sinclair Spectrum +2A/+3 Amiga 1200
0214
0215 +-----------> Up +-----------> Button 3
0216 | +---------> Fire | +---------> Right
0217 | | | | +-------> Left
0218 | | +-----> Ground | | | +-----> Down
0219 | | | | | | | +---> Up
0220 | | | | | | | |
0221 _____________ _____________
0222 5 \ o o x o x / 1 5 \ o o o o o / 1
0223 \ o o o o / \ o o o o /
0224 9 `~~~~~~~' 6 9 `~~~~~~~' 6
0225 | | | | | | | |
0226 | | | +----> Right | | | +----> Button 1
0227 | | +------> Left | | +------> Power
0228 | +--------> Ground | +--------> Ground
0229 +----------> Down +----------> Button 2
0230
0231 And there were many others.
0232
0233 Multisystem joysticks using db9.c
0234 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0235
0236 For the Multisystem joysticks, and their derivatives, the db9.c driver
0237 was written. It allows only one joystick / gamepad per parallel port, but
0238 the interface is easy to build and works with almost anything.
0239
0240 For the basic 1-button Multisystem joystick you connect its wires to the
0241 parallel port like this::
0242
0243 (pin 1) -----> Power
0244 (pin 18) -----> Ground
0245
0246 (pin 2) -----> Up
0247 (pin 3) -----> Down
0248 (pin 4) -----> Left
0249 (pin 5) -----> Right
0250 (pin 6) -----> Button 1
0251
0252 However, if the joystick is switch based (eg. clicks when you move it),
0253 you might or might not, depending on your parallel port, need 10 kOhm pullup
0254 resistors on each of the direction and button signals, like this::
0255
0256 (pin 2) ------------+------> Up
0257 Resistor |
0258 (pin 1) --[10kOhm]--+
0259
0260 Try without, and if it doesn't work, add them. For TTL based joysticks /
0261 gamepads the pullups are not needed.
0262
0263 For joysticks with two buttons you connect the second button to pin 7 on
0264 the parallel port::
0265
0266 (pin 7) -----> Button 2
0267
0268 And that's it.
0269
0270 On a side note, if you have already built a different adapter for use with
0271 the digital joystick driver 0.8.0.2, this is also supported by the db9.c
0272 driver, as device type 8. (See section 3.2)
0273
0274 Multisystem joysticks using gamecon.c
0275 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0276
0277 For some people just one joystick per parallel port is not enough, and/or
0278 want to use them on one parallel port together with NES/SNES/PSX pads. This is
0279 possible using the gamecon.c. It supports up to 5 devices of the above types,
0280 including 1 and 2 buttons Multisystem joysticks.
0281
0282 However, there is nothing for free. To allow more sticks to be used at
0283 once, you need the sticks to be purely switch based (that is non-TTL), and
0284 not to need power. Just a plain simple six switches inside. If your
0285 joystick can do more (eg. turbofire) you'll need to disable it totally first
0286 if you want to use gamecon.c.
0287
0288 Also, the connection is a bit more complex. You'll need a bunch of diodes,
0289 and one pullup resistor. First, you connect the Directions and the button
0290 the same as for db9, however with the diodes between::
0291
0292 Diodes
0293 (pin 2) -----|<|----> Up
0294 (pin 3) -----|<|----> Down
0295 (pin 4) -----|<|----> Left
0296 (pin 5) -----|<|----> Right
0297 (pin 6) -----|<|----> Button 1
0298
0299 For two button sticks you also connect the other button::
0300
0301 (pin 7) -----|<|----> Button 2
0302
0303 And finally, you connect the Ground wire of the joystick, like done in
0304 this little schematic to Power and Data on the parallel port, as described
0305 for the NES / SNES pads in section 2.1 of this file - that is, one data pin
0306 for each joystick. The power source is shared::
0307
0308 Data ------------+-----> Ground
0309 Resistor |
0310 Power --[10kOhm]--+
0311
0312 And that's all, here we go!
0313
0314 Multisystem joysticks using turbografx.c
0315 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0316
0317 The TurboGraFX interface, designed by
0318
0319 Steffen Schwenke <schwenke@burg-halle.de>
0320
0321 allows up to 7 Multisystem joysticks connected to the parallel port. In
0322 Steffen's version, there is support for up to 5 buttons per joystick. However,
0323 since this doesn't work reliably on all parallel ports, the turbografx.c driver
0324 supports only one button per joystick. For more information on how to build the
0325 interface, see:
0326
0327 http://www2.burg-halle.de/~schwenke/parport.html
0328
0329 Sony Playstation
0330 ----------------
0331
0332 The PSX controller is supported by the gamecon.c. Pinout of the PSX
0333 controller (compatible with DirectPadPro)::
0334
0335 +---------+---------+---------+
0336 9 | o o o | o o o | o o o | 1 parallel
0337 \________|_________|________/ port pins
0338 | | | | | |
0339 | | | | | +--------> Clock --- (4)
0340 | | | | +------------> Select --- (3)
0341 | | | +---------------> Power --- (5-9)
0342 | | +------------------> Ground --- (18-25)
0343 | +-------------------------> Command --- (2)
0344 +----------------------------> Data --- (one of 10,11,12,13,15)
0345
0346 The driver supports these controllers:
0347
0348 * Standard PSX Pad
0349 * NegCon PSX Pad
0350 * Analog PSX Pad (red mode)
0351 * Analog PSX Pad (green mode)
0352 * PSX Rumble Pad
0353 * PSX DDR Pad
0354
0355 Sega
0356 ----
0357
0358 All the Sega controllers are more or less based on the standard 2-button
0359 Multisystem joystick. However, since they don't use switches and use TTL
0360 logic, the only driver usable with them is the db9.c driver.
0361
0362 Sega Master System
0363 ~~~~~~~~~~~~~~~~~~
0364
0365 The SMS gamepads are almost exactly the same as normal 2-button
0366 Multisystem joysticks. Set the driver to Multi2 mode, use the corresponding
0367 parallel port pins, and the following schematic::
0368
0369 +-----------> Power
0370 | +---------> Right
0371 | | +-------> Left
0372 | | | +-----> Down
0373 | | | | +---> Up
0374 | | | | |
0375 _____________
0376 5 \ o o o o o / 1
0377 \ o o x o /
0378 9 `~~~~~~~' 6
0379 | | |
0380 | | +----> Button 1
0381 | +--------> Ground
0382 +----------> Button 2
0383
0384 Sega Genesis aka MegaDrive
0385 ~~~~~~~~~~~~~~~~~~~~~~~~~~
0386
0387 The Sega Genesis (in Europe sold as Sega MegaDrive) pads are an extension
0388 to the Sega Master System pads. They use more buttons (3+1, 5+1, 6+1). Use
0389 the following schematic::
0390
0391 +-----------> Power
0392 | +---------> Right
0393 | | +-------> Left
0394 | | | +-----> Down
0395 | | | | +---> Up
0396 | | | | |
0397 _____________
0398 5 \ o o o o o / 1
0399 \ o o o o /
0400 9 `~~~~~~~' 6
0401 | | | |
0402 | | | +----> Button 1
0403 | | +------> Select
0404 | +--------> Ground
0405 +----------> Button 2
0406
0407 The Select pin goes to pin 14 on the parallel port::
0408
0409 (pin 14) -----> Select
0410
0411 The rest is the same as for Multi2 joysticks using db9.c
0412
0413 Sega Saturn
0414 ~~~~~~~~~~~
0415
0416 Sega Saturn has eight buttons, and to transfer that, without hacks like
0417 Genesis 6 pads use, it needs one more select pin. Anyway, it is still
0418 handled by the db9.c driver. Its pinout is very different from anything
0419 else. Use this schematic::
0420
0421 +-----------> Select 1
0422 | +---------> Power
0423 | | +-------> Up
0424 | | | +-----> Down
0425 | | | | +---> Ground
0426 | | | | |
0427 _____________
0428 5 \ o o o o o / 1
0429 \ o o o o /
0430 9 `~~~~~~~' 6
0431 | | | |
0432 | | | +----> Select 2
0433 | | +------> Right
0434 | +--------> Left
0435 +----------> Power
0436
0437 Select 1 is pin 14 on the parallel port, Select 2 is pin 16 on the
0438 parallel port::
0439
0440 (pin 14) -----> Select 1
0441 (pin 16) -----> Select 2
0442
0443 The other pins (Up, Down, Right, Left, Power, Ground) are the same as for
0444 Multi joysticks using db9.c
0445
0446 Amiga CD32
0447 ----------
0448
0449 Amiga CD32 joypad uses the following pinout::
0450
0451 +-----------> Button 3
0452 | +---------> Right
0453 | | +-------> Left
0454 | | | +-----> Down
0455 | | | | +---> Up
0456 | | | | |
0457 _____________
0458 5 \ o o o o o / 1
0459 \ o o o o /
0460 9 `~~~~~~~' 6
0461 | | | |
0462 | | | +----> Button 1
0463 | | +------> Power
0464 | +--------> Ground
0465 +----------> Button 2
0466
0467 It can be connected to the parallel port and driven by db9.c driver. It needs the following wiring:
0468
0469 ============ =============
0470 CD32 pad Parallel port
0471 ============ =============
0472 1 (Up) 2 (D0)
0473 2 (Down) 3 (D1)
0474 3 (Left) 4 (D2)
0475 4 (Right) 5 (D3)
0476 5 (Button 3) 14 (AUTOFD)
0477 6 (Button 1) 17 (SELIN)
0478 7 (+5V) 1 (STROBE)
0479 8 (Gnd) 18 (Gnd)
0480 9 (Button 2) 7 (D5)
0481 ============ =============
0482
0483 The drivers
0484 ===========
0485
0486 There are three drivers for the parallel port interfaces. Each, as
0487 described above, allows to connect a different group of joysticks and pads.
0488 Here are described their command lines:
0489
0490 gamecon.c
0491 ---------
0492
0493 Using gamecon.c you can connect up to five devices to one parallel port. It
0494 uses the following kernel/module command line::
0495
0496 gamecon.map=port,pad1,pad2,pad3,pad4,pad5
0497
0498 Where ``port`` the number of the parport interface (eg. 0 for parport0).
0499
0500 And ``pad1`` to ``pad5`` are pad types connected to different data input pins
0501 (10,11,12,13,15), as described in section 2.1 of this file.
0502
0503 The types are:
0504
0505 ===== =============================
0506 Type Joystick/Pad
0507 ===== =============================
0508 0 None
0509 1 SNES pad
0510 2 NES pad
0511 4 Multisystem 1-button joystick
0512 5 Multisystem 2-button joystick
0513 6 N64 pad
0514 7 Sony PSX controller
0515 8 Sony PSX DDR controller
0516 9 SNES mouse
0517 ===== =============================
0518
0519 The exact type of the PSX controller type is autoprobed when used, so
0520 hot swapping should work (but is not recommended).
0521
0522 Should you want to use more than one of parallel ports at once, you can use
0523 gamecon.map2 and gamecon.map3 as additional command line parameters for two
0524 more parallel ports.
0525
0526 There are two options specific to PSX driver portion. gamecon.psx_delay sets
0527 the command delay when talking to the controllers. The default of 25 should
0528 work but you can try lowering it for better performance. If your pads don't
0529 respond try raising it until they work. Setting the type to 8 allows the
0530 driver to be used with Dance Dance Revolution or similar games. Arrow keys are
0531 registered as key presses instead of X and Y axes.
0532
0533 db9.c
0534 -----
0535
0536 Apart from making an interface, there is nothing difficult on using the
0537 db9.c driver. It uses the following kernel/module command line::
0538
0539 db9.dev=port,type
0540
0541 Where ``port`` is the number of the parport interface (eg. 0 for parport0).
0542
0543 Caveat here: This driver only works on bidirectional parallel ports. If
0544 your parallel port is recent enough, you should have no trouble with this.
0545 Old parallel ports may not have this feature.
0546
0547 ``Type`` is the type of joystick or pad attached:
0548
0549 ===== ======================================================
0550 Type Joystick/Pad
0551 ===== ======================================================
0552 0 None
0553 1 Multisystem 1-button joystick
0554 2 Multisystem 2-button joystick
0555 3 Genesis pad (3+1 buttons)
0556 5 Genesis pad (5+1 buttons)
0557 6 Genesis pad (6+2 buttons)
0558 7 Saturn pad (8 buttons)
0559 8 Multisystem 1-button joystick (v0.8.0.2 pin-out)
0560 9 Two Multisystem 1-button joysticks (v0.8.0.2 pin-out)
0561 10 Amiga CD32 pad
0562 ===== ======================================================
0563
0564 Should you want to use more than one of these joysticks/pads at once, you
0565 can use db9.dev2 and db9.dev3 as additional command line parameters for two
0566 more joysticks/pads.
0567
0568 turbografx.c
0569 ------------
0570
0571 The turbografx.c driver uses a very simple kernel/module command line::
0572
0573 turbografx.map=port,js1,js2,js3,js4,js5,js6,js7
0574
0575 Where ``port`` is the number of the parport interface (eg. 0 for parport0).
0576
0577 ``jsX`` is the number of buttons the Multisystem joysticks connected to the
0578 interface ports 1-7 have. For a standard multisystem joystick, this is 1.
0579
0580 Should you want to use more than one of these interfaces at once, you can
0581 use turbografx.map2 and turbografx.map3 as additional command line parameters
0582 for two more interfaces.
0583
0584 PC parallel port pinout
0585 =======================
0586
0587 ::
0588
0589 .----------------------------------------.
0590 At the PC: \ 13 12 11 10 9 8 7 6 5 4 3 2 1 /
0591 \ 25 24 23 22 21 20 19 18 17 16 15 14 /
0592 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0593
0594 ====== ======= =============
0595 Pin Name Description
0596 ====== ======= =============
0597 1 /STROBE Strobe
0598 2-9 D0-D7 Data Bit 0-7
0599 10 /ACK Acknowledge
0600 11 BUSY Busy
0601 12 PE Paper End
0602 13 SELIN Select In
0603 14 /AUTOFD Autofeed
0604 15 /ERROR Error
0605 16 /INIT Initialize
0606 17 /SEL Select
0607 18-25 GND Signal Ground
0608 ====== ======= =============
0609
0610
0611 That's all, folks! Have fun!