joystick-parport.rst 21 KB

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