Jump to content
IGNORED

hackerb9's blog - Ugliest kludge ever?


RSS Bot

Recommended Posts

The Amiga 4-player Adaptor

I found an Amiga 4-player Adaptor and decided to make it work with GNU/Linux. It was designed to add two more joystick ports to an Amiga by plugging into the printer port, but I figured I could use it to plug my Atari joysticks directly into my PC. It turns out that the Amiga 4-player Adaptor doesn't have
any
components inside of it, not even a pullup resistor. (A pullup resistor is used to keep an input line at +5V when a joystick switch isn't grounding the line.)

 

blogentry-23928-1250322232.png

 

Since Atari joysticks are just passive switches, not actively driving the line with voltage, that means it's impossible for this thing to work, right? Well, sort of. I came up with a kludge which allows an Atari joystick to be plugged into a PC's parallel port without any resistors or diodes or anything. I call it a "kludge" because it works, but not only is it not the right way, it's not even the wrong way, it's a way that nobody should ever, ever do.

 

I modified the Linux kernel module "db9" to switch rapidly between writing and reading the data lines on the parallel port. So, now it briefly sets the voltage high on all lines, then tristates the lines (lets them "float" so they're neither grounded nor connected to voltage) and reads back the values. Since it takes a non-infinitesimal amount of time for the voltage to dissipate, the voltage will be read back as high unless a joystick switch is being pressed, which grounds the line.

 

parport_data_forward(port);
parport_write_data(port, 0xFF);
parport_data_reverse(port);
data = parport_read_data(port);

 

Now, you don't have to be an electrical engineer to see the potential problem with this. When I set the voltage high on all lines, if a button is pressed on the joystick, it will cause a direct short to ground, with no resistor in between! That means some component is going to be taking an awful lot of current and might heat up and burn out. I believe that component would be the chip inside the PC that controls the parallel port, which means, my hack could destroy my parallel port, and possibly any other components on the motherboard that are on the same chip. On the other hand, it is only shorted out
extremely
briefly, with a comparatively long rest time.

 

So far, my PC has been able to handle the stress, but I've only been using it for about an hour. If it does blow out the parallel port, I'm not too worried since, who uses a parallel printer port these days?

 

My Changes

Here are the changes, if you'd like to use it on your own machine.

  • Here is the patch which includes my changes to the source code in /usr/src/linux-source-2.6.26/drivers/input/joystick/db9.c.
    txt.gif
    ( 2.35K )

    Number of downloads: 2

     

  • Here is an archive of my work directory including a prebuilt kernel module, db9.ko, for Linux 2.6.26.
    zip.gif
    ( 33.93K )

    Number of downloads: 5

 

Usage

The db9 kernel module must be loaded with a parameter that specifies what type of joysticks are connected to the parallel port. The type I added for the Amiga 4 Player Adapator is number 13. It can be loaded like this:

 

insmod db9.ko dev=0,13

 

If it fails to load, check dmesg. It's most likely a version problem. You can force it to load using modprobe or you can do the "right thing" and recompile the module for your particular machine.

 

Module recompilation

Probably the easiest way for most people to recompile the db9 module is just recompile the whole Linux kernel after applying my patch to db9.c. However, you don't need to do that. One can compile a single module using something like the following:

 

apt-get install linux-headers-`uname -r`
wget -O joystick.tar.gz 'http://www.atariage.com/forums/index.php?act=attach&type=blogentry&id=137255'
tar -zxvf joystick.tar.gz
cd joystick
make -C /usr/src/linux-headers-`uname -r` M=`pwd` modules

 

http://www.atariage.com/forums/index.php?a...;showentry=6345

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...