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