⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 joystick-parport.txt

📁 ARM 嵌入式 系统 设计与实例开发 实验教材 二源码
💻 TXT
📖 第 1 页 / 共 2 页
字号:
		    Linux Joystick parport drivers v2.0	       (c) 1998-2000 Vojtech Pavlik <vojtech@suse.cz>	       (c) 1998 Andree Borrmann <a.borrmann@tu-bs.de>			     Sponsored by SuSE	$Id: joystick-parport.txt,v 1.5 2001/05/15 06:41:00 vojtech Exp $----------------------------------------------------------------------------0. Disclaimer~~~~~~~~~~~~~  Any information in this file is provided as-is, without any guarantee thatit will be true. So, use it at your own risk. The possible damages that canhappen include burning your parallel port, and/or the sticks and joystickand maybe even more. Like when a lightning kills you it is not our problem.1. Intro~~~~~~~~  The joystick parport drivers are used for joysticks and gamepads notoriginally designed for PCs and other computers Linux runs on. Because ofthat, PCs usually lack the right ports to connect these devices to. Parallelport, because of its ability to change single bits at will, and providingboth output and input bits is the most suitable port on the PC forconnecting such devices.2. Devices supported~~~~~~~~~~~~~~~~~~~~  Many console and 8-bit computer gamepads and joysticks are supported. Thefollowing subsections discuss usage of each.2.1 NES and SNES~~~~~~~~~~~~~~~~  The Nintendo Entertainment System and Super Nintendo Entertainment Systemgamepads are widely available, and easy to get. Also, they are quite easy toconnect to a PC, and don't need much processing speed (108 us for NES and165 us for SNES, compared to about 1000 us for PC gamepads) to communicatewith them.  All NES and SNES use the same synchronous serial protocol, clocked fromthe computer's side (and thus timing insensitive). To allow up to 5 NESand/or SNES gamepads connected to the parallel port at once, the outputlines of the parallel port are shared, while one of 5 available input linesis assigned to each gamepad.  This protocol is handled by the gamecon.c driver, so that's the oneyou'll use for NES and SNES gamepads.  The main problem with PC parallel ports is that they don't have +5V powersource on any of their pins. So, if you want a reliable source of powerfor your pads, use either keyboard or joystick port, and make a pass-throughcable. You can also pull the power directly from the power supply (the redwire is +5V).  If you want to use the parallel port only, you can take the power is fromsome data pin. For most gamepad and parport implementations only one pin isneeded, and I'd recommend pin 9 for that, the highest data bit. On the otherhand, if you are not planning to use anything else than NES / SNES on theport, anything between and including pin 4 and pin 9 will work.(pin 9) -----> Power  Unfortunately, there are pads that need a lot more of power, and parallelports that can't give much current through the data pins. If this is yourcase, you'll need to use diodes (as a prevention of destroying your parallelport), and combine the currents of two or more data bits together.	   Diodes(pin 9) ----|>|-------+------> Power		      |(pin 8) ----|>|-------+		      |(pin 7) ----|>|-------+		      | <and so on>          :		      |(pin 4) ----|>|-------+  Ground is quite easy. On PC's parallel port the ground is on any of thepins from pin 18 to pin 25. So use any pin of these you like for the ground.(pin 18) -----> Ground  NES and SNES pads have two input bits, Clock and Latch, which drive theserial transfer. These are connected to pins 2 and 3 of the parallel port,respectively.(pin 2) -----> Clock(pin 3) -----> Latch  And the last thing is the NES / SNES data wire. Only that isn't shared andeach pad needs its own data pin. The parallel port pins are:(pin 10) -----> Pad 1 data(pin 11) -----> Pad 2 data(pin 12) -----> Pad 3 data(pin 13) -----> Pad 4 data(pin 15) -----> Pad 5 data  Note that pin 14 is not used, since it is not an input pin on the parallelport.  This is everything you need on the PC's side of the connection, now on tothe gamepads side. The NES and SNES have different connectors. Also, thereare quite a lot of NES clones, and because Nintendo used proprietaryconnectors for their machines, the cloners couldn't and used standard D-Cannonconnectors. Anyway, if you've got a gamepad, and it has buttons A, B, TurboA, Turbo B, Select and Start, and is connected through 5 wires, then it iseither a NES or NES clone and will work with this connection. SNES gamepadsalso use 5 wires, but have more buttons. They will work as well, of course.Pinout for NES gamepads                 Pinout for SNES gamepads	   +----> Power                   +-----------------------\	   |                            7 | o  o  o  o |  x  x  o  | 1 5 +---------+  7                         +-----------------------/   | x  x  o   \                            |  |  |  |          |   | o  o  o  o |                           |  |  |  |          +-> Ground 4 +------------+ 1                         |  |  |  +------------> Data     |  |  |  |                             |  |  +---------------> Latch     |  |  |  +-> Ground                    |  +------------------> Clock     |  |  +----> Clock                     +---------------------> Power     |  +-------> Latch     +----------> DataPinout for NES clone (db9) gamepads     Pinout for NES clone (db15) gamepads	+---------> Clock                    +-----------------> Data	| +-------> Latch                    |             +---> Ground	| | +-----> Data                     |             |	| | |                              ___________________    _____________                        8 \ o x x x x x x o / 1  5 \ x o o o x / 1                         \ o x x o x x o /     \ x o x o /                          15 `~~~~~~~~~~~~~' 9    9 `~~~~~~~' 6                             |     |     |	 |   |                                |     |     +----> Clock	 |   +----> Power                     |     +----------> Latch	 +--------> Ground                    +----------------> Power2.2 Multisystem joysticks~~~~~~~~~~~~~~~~~~~~~~~~~  In the era of 8-bit machines, there was something like de-facto standardfor joystick ports. They were all digital, and all used D-Cannon 9 pinconnectors (db9). Because of that, a single joystick could be used withouthassle on Atari (130, 800XE, 800XL, 2600, 7200), Amiga, Commodore C64,Amstrad CPC, Sinclair ZX Spectrum and many other machines. That's why thesejoysticks are called "Multisystem".  Now their pinout:      +---------> Right      | +-------> Left      | | +-----> Down      | | | +---> Up      | | | |  _____________5 \ x o o o o / 1   \ x o x o /  9 `~~~~~~~' 6       |   |       |   +----> Button       +--------> Ground  However, as time passed, extensions to this standard developed, and thesewere not compatible with each other:	Atari 130, 800/XL/XE		   MSX					 +-----------> Power      +---------> Right                  | +---------> Right      | +-------> Left                   | | +-------> Left      | | +-----> Down                   | | | +-----> Down      | | | +---> Up                     | | | | +---> Up      | | | |                            | | | | |  _____________                        _____________5 \ x o o o o / 1                    5 \ o o o o o / 1   \ x o o o /                          \ o o o o /  9 `~~~~~~~' 6                        9 `~~~~~~~' 6       | | |                              | | | |       | | +----> Button                  | | | +----> Button 1       | +------> Power                   | | +------> Button 2       +--------> Ground                  | +--------> Output 3					  +----------> Ground	Amstrad CPC			   Commodore C64					 +-----------> Analog Y      +---------> Right                  | +---------> Right      | +-------> Left                   | | +-------> Left      | | +-----> Down                   | | | +-----> Down      | | | +---> Up                     | | | | +---> Up      | | | |                            | | | | |  _____________                        _____________5 \ x o o o o / 1                    5 \ o o o o o / 1   \ x o o o /                          \ o o o o /  9 `~~~~~~~' 6                        9 `~~~~~~~' 6       | | |                              | | | |       | | +----> Button 1                | | | +----> Button       | +------> Button 2                | | +------> Power       +--------> Ground                  | +--------> Ground					  +----------> Analog X	Sinclair Spectrum +2A/+3           Amiga 1200                                         +-----------> Up                     +-----------> Button 3    | +---------> Fire                   | +---------> Right    | |                                  | | +-------> Left    | |   +-----> Ground                 | | | +-----> Down    | |   |                              | | | | +---> Up    | |   |                              | | | | |  _____________                        _____________5 \ o o x o x / 1                    5 \ o o o o o / 1   \ o o o o /                          \ o o o o /  9 `~~~~~~~' 6                        9 `~~~~~~~' 6     | | | |                              | | | |     | | | +----> Right                   | | | +----> Button 1     | | +------> Left                    | | +------> Power     | +--------> Ground                  | +--------> Ground     +----------> Down                    +----------> Button 2  And there were many others.2.2.1 Multisystem joysticks using db9.c~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  For the Multisystem joysticks, and their derivatives, the db9.c driverwas written. It allows only one joystick / gamepad per parallel port, butthe interface is easy to build and works with almost anything.  For the basic 1-button Multisystem joystick you connect its wires to theparallel port like this:(pin  1) -----> Power(pin 18) -----> Ground(pin  2) -----> Up(pin  3) -----> Down(pin  4) -----> Left(pin  5) -----> Right(pin  6) -----> Button 1  However, if the joystick is switch based (eg. clicks when you move it),you might or might not, depending on your parallel port, need 10 kOhm pullupresistors on each of the direction and button signals, like this:(pin 2) ------------+------> Up	  Resistor  |(pin 1) --[10kOhm]--+  Try without, and if it doesn't work, add them. For TTL based joysticks /gamepads the pullups are not needed.  For joysticks with two buttons you connect the second button to pin 7 onthe parallel port.(pin 7) -----> Button 2  And that's it.  On a side note, if you have already built a different adapter for use withthe digital joystick driver 0.8.0.2, this is also supported by the db9.cdriver, as device type 8. (See section 3.2)2.2.2 Multisystem joysticks using gamecon.c~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  For some people just one joystick per parallel port is not enough, and/orwant to use them on one parallel port together with NES/SNES/PSX pads. This ispossible using the gamecon.c. It supports up to 5 devices of the above types,including 1 and 2 buttons Multisystem joysticks.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -