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