brintos

brintos / linux-shallow public Read only

0
0
Text · 21.1 KiB · e8ce16e Raw
612 lines · plain
1.. include:: <isonum.txt>2 3.. _joystick-parport:4 5==============================6Parallel Port Joystick Drivers7==============================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 SuSE14 15Disclaimer16==========17 18Any information in this file is provided as-is, without any guarantee that19it will be true. So, use it at your own risk. The possible damages that can20happen include burning your parallel port, and/or the sticks and joystick21and maybe even more. Like when a lightning kills you it is not our problem.22 23Introduction24============25 26The joystick parport drivers are used for joysticks and gamepads not27originally designed for PCs and other computers Linux runs on. Because of28that, PCs usually lack the right ports to connect these devices to. Parallel29port, because of its ability to change single bits at will, and providing30both output and input bits is the most suitable port on the PC for31connecting such devices.32 33Devices supported34=================35 36Many console and 8-bit computer gamepads and joysticks are supported. The37following subsections discuss usage of each.38 39NES and SNES40------------41 42The Nintendo Entertainment System and Super Nintendo Entertainment System43gamepads are widely available, and easy to get. Also, they are quite easy to44connect to a PC, and don't need much processing speed (108 us for NES and45165 us for SNES, compared to about 1000 us for PC gamepads) to communicate46with them.47 48All NES and SNES use the same synchronous serial protocol, clocked from49the computer's side (and thus timing insensitive). To allow up to 5 NES50and/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 available52input lines is assigned to each gamepad.53 54This protocol is handled by the gamecon.c driver, so that's the one55you'll use for NES, SNES gamepads and SNES mice.56 57The main problem with PC parallel ports is that they don't have +5V power58source on any of their pins. So, if you want a reliable source of power59for your pads, use either keyboard or joystick port, and make a pass-through60cable. You can also pull the power directly from the power supply (the red61wire is +5V).62 63If you want to use the parallel port only, you can take the power is from64some data pin. For most gamepad and parport implementations only one pin is65needed, and I'd recommend pin 9 for that, the highest data bit. On the other66hand, if you are not planning to use anything else than NES / SNES on the67port, anything between and including pin 4 and pin 9 will work::68 69    (pin 9) -----> Power70 71Unfortunately, there are pads that need a lot more of power, and parallel72ports that can't give much current through the data pins. If this is your73case, you'll need to use diodes (as a prevention of destroying your parallel74port), and combine the currents of two or more data bits together::75 76	      Diodes77    (pin 9) ----|>|-------+------> Power78			|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 the88pins from pin 18 to pin 25. So use any pin of these you like for the ground::89 90    (pin 18) -----> Ground91 92NES and SNES pads have two input bits, Clock and Latch, which drive the93serial transfer. These are connected to pins 2 and 3 of the parallel port,94respectively::95 96    (pin 2) -----> Clock97    (pin 3) -----> Latch98 99And the last thing is the NES / SNES data wire. Only that isn't shared and100each pad needs its own data pin. The parallel port pins are::101 102    (pin 10) -----> Pad 1 data103    (pin 11) -----> Pad 2 data104    (pin 12) -----> Pad 3 data105    (pin 13) -----> Pad 4 data106    (pin 15) -----> Pad 5 data107 108Note that pin 14 is not used, since it is not an input pin on the parallel109port.110 111This is everything you need on the PC's side of the connection, now on to112the gamepads side. The NES and SNES have different connectors. Also, there113are quite a lot of NES clones, and because Nintendo used proprietary114connectors for their machines, the cloners couldn't and used standard D-Cannon115connectors. Anyway, if you've got a gamepad, and it has buttons A, B, Turbo116A, Turbo B, Select and Start, and is connected through 5 wires, then it is117either a NES or NES clone and will work with this connection. SNES gamepads118also 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 mice121 122             +----> Power                   +-----------------------\123             |                            7 | o  o  o  o |  x  x  o  | 1124   5 +---------+  7                         +-----------------------/125     | x  x  o   \                            |  |  |  |          |126     | o  o  o  o |                           |  |  |  |          +-> Ground127   4 +------------+ 1                         |  |  |  +------------> Data128       |  |  |  |                             |  |  +---------------> Latch129       |  |  |  +-> Ground                    |  +------------------> Clock130       |  |  +----> Clock                     +---------------------> Power131       |  +-------> Latch132       +----------> Data133 134  Pinout for NES clone (db9) gamepads     Pinout for NES clone (db15) gamepads135 136        +---------> Clock                    +-----------------> Data137        | +-------> Latch                    |             +---> Ground138        | | +-----> Data                     |             |139        | | |                              ___________________140    _____________                        8 \ o x x x x x x o / 1141  5 \ x o o o x / 1                         \ o x x o x x o /142     \ x o x o /                          15 `~~~~~~~~~~~~~' 9143    9 `~~~~~~~' 6                             |     |     |144         |   |                                |     |     +----> Clock145         |   +----> Power                     |     +----------> Latch146         +--------> Ground                    +----------------> Power147 148Multisystem joysticks149---------------------150 151In the era of 8-bit machines, there was something like de-facto standard152for joystick ports. They were all digital, and all used D-Cannon 9 pin153connectors (db9). Because of that, a single joystick could be used without154hassle on Atari (130, 800XE, 800XL, 2600, 7200), Amiga, Commodore C64,155Amstrad CPC, Sinclair ZX Spectrum and many other machines. That's why these156joysticks are called "Multisystem".157 158Now their pinout::159 160        +---------> Right161        | +-------> Left162        | | +-----> Down163        | | | +---> Up164        | | | |165    _____________166  5 \ x o o o o / 1167     \ x o x o /168    9 `~~~~~~~' 6169         |   |170         |   +----> Button171         +--------> Ground172 173However, as time passed, extensions to this standard developed, and these174were not compatible with each other::175 176 177          Atari 130, 800/XL/XE                   MSX178 179                                           +-----------> Power180        +---------> Right                  | +---------> Right181        | +-------> Left                   | | +-------> Left182        | | +-----> Down                   | | | +-----> Down183        | | | +---> Up                     | | | | +---> Up184        | | | |                            | | | | |185    _____________                        _____________186  5 \ x o o o o / 1                    5 \ o o o o o / 1187     \ x o o o /                          \ o o o o /188    9 `~~~~~~~' 6                        9 `~~~~~~~' 6189         | | |                              | | | |190         | | +----> Button                  | | | +----> Button 1191         | +------> Power                   | | +------> Button 2192         +--------> Ground                  | +--------> Output 3193                                            +----------> Ground194 195          Amstrad CPC                           Commodore C64196 197                                           +-----------> Analog Y198        +---------> Right                  | +---------> Right199        | +-------> Left                   | | +-------> Left200        | | +-----> Down                   | | | +-----> Down201        | | | +---> Up                     | | | | +---> Up202        | | | |                            | | | | |203    _____________                        _____________204  5 \ x o o o o / 1                    5 \ o o o o o / 1205     \ x o o o /                          \ o o o o /206    9 `~~~~~~~' 6                        9 `~~~~~~~' 6207         | | |                              | | | |208         | | +----> Button 1                | | | +----> Button209         | +------> Button 2                | | +------> Power210         +--------> Ground                  | +--------> Ground211                                            +----------> Analog X212 213          Sinclair Spectrum +2A/+3           Amiga 1200214 215      +-----------> Up                     +-----------> Button 3216      | +---------> Fire                   | +---------> Right217      | |                                  | | +-------> Left218      | |   +-----> Ground                 | | | +-----> Down219      | |   |                              | | | | +---> Up220      | |   |                              | | | | |221    _____________                        _____________222  5 \ o o x o x / 1                    5 \ o o o o o / 1223     \ o o o o /                          \ o o o o /224    9 `~~~~~~~' 6                        9 `~~~~~~~' 6225       | | | |                              | | | |226       | | | +----> Right                   | | | +----> Button 1227       | | +------> Left                    | | +------> Power228       | +--------> Ground                  | +--------> Ground229       +----------> Down                    +----------> Button 2230 231  And there were many others.232 233Multisystem joysticks using db9.c234~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~235 236For the Multisystem joysticks, and their derivatives, the db9.c driver237was written. It allows only one joystick / gamepad per parallel port, but238the interface is easy to build and works with almost anything.239 240For the basic 1-button Multisystem joystick you connect its wires to the241parallel port like this::242 243    (pin  1) -----> Power244    (pin 18) -----> Ground245 246    (pin  2) -----> Up247    (pin  3) -----> Down248    (pin  4) -----> Left249    (pin  5) -----> Right250    (pin  6) -----> Button 1251 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 pullup254resistors on each of the direction and button signals, like this::255 256    (pin 2) ------------+------> Up257              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 on264the parallel port::265 266    (pin 7) -----> Button 2267 268And that's it.269 270On a side note, if you have already built a different adapter for use with271the digital joystick driver 0.8.0.2, this is also supported by the db9.c272driver, as device type 8. (See section 3.2)273 274Multisystem joysticks using gamecon.c275~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~276 277For some people just one joystick per parallel port is not enough, and/or278want to use them on one parallel port together with NES/SNES/PSX pads. This is279possible 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 at283once, you need the sticks to be purely switch based (that is non-TTL), and284not to need power. Just a plain simple six switches inside. If your285joystick can do more (eg. turbofire) you'll need to disable it totally first286if 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 button290the same as for db9, however with the diodes between::291 292                Diodes293    (pin 2) -----|<|----> Up294    (pin 3) -----|<|----> Down295    (pin 4) -----|<|----> Left296    (pin 5) -----|<|----> Right297    (pin 6) -----|<|----> Button 1298 299For two button sticks you also connect the other button::300 301    (pin 7) -----|<|----> Button 2302 303And finally, you connect the Ground wire of the joystick, like done in304this little schematic to Power and Data on the parallel port, as described305for the NES / SNES pads in section 2.1 of this file - that is, one data pin306for each joystick. The power source is shared::307 308    Data    ------------+-----> Ground309              Resistor  |310    Power   --[10kOhm]--+311 312And that's all, here we go!313 314Multisystem joysticks using turbografx.c315~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~316 317The TurboGraFX interface, designed by318 319	Steffen Schwenke <schwenke@burg-halle.de>320 321allows up to 7 Multisystem joysticks connected to the parallel port. In322Steffen'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 driver324supports only one button per joystick. For more information on how to build the325interface, see:326 327	http://www2.burg-halle.de/~schwenke/parport.html328 329Sony Playstation330----------------331 332The PSX controller is supported by the gamecon.c. Pinout of the PSX333controller (compatible with DirectPadPro)::334 335    +---------+---------+---------+336  9 | o  o  o | o  o  o | o  o  o | 1               parallel337     \________|_________|________/                  port pins338      |  |      |  |  |   |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 Pad349 * NegCon PSX Pad350 * Analog PSX Pad (red mode)351 * Analog PSX Pad (green mode)352 * PSX Rumble Pad353 * PSX DDR Pad354 355Sega356----357 358All the Sega controllers are more or less based on the standard 2-button359Multisystem joystick. However, since they don't use switches and use TTL360logic, the only driver usable with them is the db9.c driver.361 362Sega Master System363~~~~~~~~~~~~~~~~~~364 365The SMS gamepads are almost exactly the same as normal 2-button366Multisystem joysticks. Set the driver to Multi2 mode, use the corresponding367parallel port pins, and the following schematic::368 369      +-----------> Power370      | +---------> Right371      | | +-------> Left372      | | | +-----> Down373      | | | | +---> Up374      | | | | |375    _____________376  5 \ o o o o o / 1377     \ o o x o /378    9 `~~~~~~~' 6379       | |   |380       | |   +----> Button 1381       | +--------> Ground382       +----------> Button 2383 384Sega Genesis aka MegaDrive385~~~~~~~~~~~~~~~~~~~~~~~~~~386 387The Sega Genesis (in Europe sold as Sega MegaDrive) pads are an extension388to the Sega Master System pads. They use more buttons (3+1, 5+1, 6+1).  Use389the following schematic::390 391        +-----------> Power392        | +---------> Right393        | | +-------> Left394        | | | +-----> Down395        | | | | +---> Up396        | | | | |397      _____________398    5 \ o o o o o / 1399       \ o o o o /400      9 `~~~~~~~' 6401        | | | |402        | | | +----> Button 1403        | | +------> Select404        | +--------> Ground405        +----------> Button 2406 407The Select pin goes to pin 14 on the parallel port::408 409    (pin 14) -----> Select410 411The rest is the same as for Multi2 joysticks using db9.c412 413Sega Saturn414~~~~~~~~~~~415 416Sega Saturn has eight buttons, and to transfer that, without hacks like417Genesis 6 pads use, it needs one more select pin. Anyway, it is still418handled by the db9.c driver. Its pinout is very different from anything419else.  Use this schematic::420 421      +-----------> Select 1422      | +---------> Power423      | | +-------> Up424      | | | +-----> Down425      | | | | +---> Ground426      | | | | |427    _____________428  5 \ o o o o o / 1429     \ o o o o /430    9 `~~~~~~~' 6431       | | | |432       | | | +----> Select 2433       | | +------> Right434       | +--------> Left435       +----------> Power436 437Select 1 is pin 14 on the parallel port, Select 2 is pin 16 on the438parallel port::439 440    (pin 14) -----> Select 1441    (pin 16) -----> Select 2442 443The other pins (Up, Down, Right, Left, Power, Ground) are the same as for444Multi joysticks using db9.c445 446Amiga CD32447----------448 449Amiga CD32 joypad uses the following pinout::450 451        +-----------> Button 3452        | +---------> Right453        | | +-------> Left454        | | | +-----> Down455        | | | | +---> Up456        | | | | |457      _____________458    5 \ o o o o o / 1459       \ o o o o /460      9 `~~~~~~~' 6461        | | | |462        | | | +----> Button 1463        | | +------> Power464        | +--------> Ground465        +----------> Button 2466 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 port471	============    =============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 drivers484===========485 486There are three drivers for the parallel port interfaces. Each, as487described above, allows to connect a different group of joysticks and pads.488Here are described their command lines:489 490gamecon.c491---------492 493Using gamecon.c you can connect up to five devices to one parallel port. It494uses the following kernel/module command line::495 496	gamecon.map=port,pad1,pad2,pad3,pad4,pad5497 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 pins501(10,11,12,13,15), as described in section 2.1 of this file.502 503The types are:504 505	===== =============================506	Type  Joystick/Pad507	===== =============================508	  0   None509	  1   SNES pad510	  2   NES pad511	  4   Multisystem 1-button joystick512	  5   Multisystem 2-button joystick513	  6   N64 pad514	  7   Sony PSX controller515	  8   Sony PSX DDR controller516	  9   SNES mouse517	===== =============================518 519The exact type of the PSX controller type is autoprobed when used, so520hot swapping should work (but is not recommended).521 522Should you want to use more than one of parallel ports at once, you can use523gamecon.map2 and gamecon.map3 as additional command line parameters for two524more parallel ports.525 526There are two options specific to PSX driver portion.  gamecon.psx_delay sets527the command delay when talking to the controllers. The default of 25 should528work but you can try lowering it for better performance. If your pads don't529respond try raising it until they work. Setting the type to 8 allows the530driver to be used with Dance Dance Revolution or similar games. Arrow keys are531registered as key presses instead of X and Y axes.532 533db9.c534-----535 536Apart from making an interface, there is nothing difficult on using the537db9.c driver. It uses the following kernel/module command line::538 539	db9.dev=port,type540 541Where ``port`` is the number of the parport interface (eg. 0 for parport0).542 543Caveat here: This driver only works on bidirectional parallel ports. If544your 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/Pad551	===== ======================================================552	  0   None553	  1   Multisystem 1-button joystick554	  2   Multisystem 2-button joystick555	  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 pad562	===== ======================================================563 564Should you want to use more than one of these joysticks/pads at once, you565can use db9.dev2 and db9.dev3 as additional command line parameters for two566more joysticks/pads.567 568turbografx.c569------------570 571The turbografx.c driver uses a very simple kernel/module command line::572 573	turbografx.map=port,js1,js2,js3,js4,js5,js6,js7574 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 the578interface 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 can581use turbografx.map2 and turbografx.map3 as additional command line parameters582for two more interfaces.583 584PC parallel port pinout585=======================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     Description596======  =======  =============597     1  /STROBE  Strobe598   2-9  D0-D7    Data Bit 0-7599    10  /ACK     Acknowledge600    11  BUSY     Busy601    12  PE       Paper End602    13  SELIN    Select In603    14  /AUTOFD  Autofeed604    15  /ERROR   Error605    16  /INIT    Initialize606    17  /SEL     Select607 18-25  GND      Signal Ground608======  =======  =============609 610 611That's all, folks! Have fun!612