joystick-parport.txt 20 KB

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