...making Linux just a little more fun!
By Jim Dennis, Jason Creighton, Chris G, Karl-Heinz, and... (meet the Gang) ... the Editors of Linux Gazette... and You!
From Triyan W. Nugroho
Answered By: Peter Knaggs
Hello Gang,
Here in Indonesia we have very cheap joystick using DirectPad Pro driver (it's actually just a modified Playstation joystick).
[Peter] Does it connect to the parallel port of your Linux machine? If so, you might find the README and README-parport in the following are helpful to get an understanding: ftp://atrey.karlin.mff.cuni.cz/pub/linux/joystick/joystick-1.2.15.tar.gz
If on the other hand, it connects to the game port of your sound card, don't use the parallel port driver, of course :)
Yes, it does connect to parallel port.
I have use it for a long time in Windows, but still have no idea how to use it with Linux.
[Peter] Did you read these pages?
http://atrey.karlin.mff.cuni.cz/~vojtech/input
http://www.linuxgames.com/joystick
Yes. But the documentation in the Linux kernel says that the kernel has support for DirectPad joysticks, using gamecon module.
[Peter] Yes, "gamecon" is likely the right module to use.
So I think I don't have to compile the package provided in the abovementioned pages..
[Peter] True. Still, they're useful in that they combine the userland tools and the kernel drivers all in one place with some guides and FAQ and other such. It gives a good starting point, and from there you can work on the specific issues of the 2.6 kernel, once you know how to get the device to work correctly in a plain 2.4 kernel.
And I'm still confused, because the package in these pages use different filename.
[Peter] Yes, well filenames change over time, code hardly changes all that much.
For example, Linux kernel uses joydev.c, but in these pages it is joystick.c. And for DirectPad joysticks, Linux kernel uses gamecon.c, while in these pages it is joy-console.c.
[Peter] Those would have been the names during the 2.4 series kernel.
I have been Googling and found that the Linux kernel actually have support on it. And then I found several documentation in the Linux kernel, but I always fail :(
[Peter] What did you try, and how did it fail, specifically?
cd /dev rm js* mkdir input mknod input/js0 c 13 0 mknod input/js1 c 13 1 mknod input/js2 c 13 2 mknod input/js3 c 13 3 ln -s input/js0 js0 ln -s input/js1 js1 ln -s input/js2 js2 ln -s input/js3 js3
[Peter] Well, those entries would be created by udev if you were using a 2.6.12 or later kernel, once the module was loaded correctly.
It seems, though, that the module "gamecon" isn't loading for some reason. Perhaps because it isn't finding the parallel port device? Or because the parallel port is being used by another module (have you checked that "lp" module isn't loaded)?
Are you sure the parallel port is enabled in the BIOS? Do you happen to have a parallel port printer and test that printing works OK, or some other way to know if the parallel port is actually enabled? You mentioned the joystick worked in Microsoft but it wasn't clear if it was on the same machine.
But every reboot, my js* is always gone How can I fix it?
[Peter] Not sure about that, could be many reasons. It's no harm to create the devices manually, but unless the module is loaded successfully they will just give ENODEV when you try to use them.
root@devel:/home/i2c# modprobe joydev root@devel:/home/i2c# modprobe gamecon FATAL: Error inserting gamecon (/lib/modules/2.6.8-2-386/kernel/drivers/input/joystick/gamecon.ko): No such device
[Peter] Have a look in "dmesg" to see if there's any other messages. Also, can you see anything mentioning "parport" in your boot messages, if so can you send it, e.g.:
parport: PnPBIOS parport detected. parport0: PC-style at 0x378 (0x778), irq 7, using FIFO [PCSPP,TRISTATE,COMPAT,ECP]
That would tell you the IRQ line to look for in /proc/interrupts corresponding to the parallel port.
I've tested on 2.4 and 2.6 series, but no difference...
[Peter] Hmm, so it looks like more debugging will be needed. Have a look in the sources, you can add in some printk(KERN_INFO along the path from module_init(gc_init); so add in some tracing of gc_init and see why the gc_probe function isn't happy. You should see your debug additions come out in "dmesg" when you modprobe gamecon and you can keep adding more debug tracing and doing rmmod gamecon and modprobe gamecon to try again. Be careful though with your code, as you're likely to crash your kernel sometimes doing this sort of thing.
Can you explain step-by-step how to configure the kernel to work with this joystick? I use Debian 3.1 and kernel 2.6.18.
[Peter] I wouldn't have the same hardware as you, so I couldn't provide a step-by-step guide. My guess woiuld be that the joystick stuff might be easier to get to work using a 2.4 series kernel rather than 2.6 series. I haven't been following the development in the 2.6 series much on joysticks.
My sound card (Intel i810 onboard) doesn't work on 2.4, so I have to use the 2.6 series :(
[Peter] Well, it is still worthwhile to learn how (or even if) the device will work with the 2.4 kernel driver, even if you can't listen to music while you're doing the investigation :) But sounds like it doesn't work in 2.4 as you say, so easiest to debug what's going on using 2.6 for now.
[Peter] Could you try instead:
modprobe gamecon map=0,1
Looking in ./drivers/input/joystick/gamecon.c it seems it needs the parallel port number and the pad number. I'm guessing that would be counting from 1, but maybe it should be map=0,0
module_param_array_named(map, gc, int, &gc_nargs, 0); MODULE_PARM_DESC(map, "Describers first set of devices (<parport#>,<pad1>,<pad2>,..<pad5>)");
Solved!
First I had to remove lp module. I also stopped CUPS services because my printer is connected via parallel port.
[Peter] Thanks, I didn't think of stopping CUPS :)
In 2.4 kernel, I try:
#modprobe gamecon gc=0,7
where 0 means parallel port 0, and 7 means that it is a Playstation joystick.
[Peter] the "map=0,7" would be what to use for 2.6, judging from the sources they mention that the "gc=" parameter is deprecated.
When I tried to play xgalaga using my joystick, the ships did some strange movement.
[Peter] Instead of tying a game directly, could you try to build the "jstest" and "jcal" programs if you don't have them already. From the README in the download mentioned before:
............... 2.5 Verifying that it works For testing the joystick driver functionality, there is the jstest program. You run it by typing: jstest /dev/js0 And it should show a line with the joystick values, which update as you move the stick, and press its buttons. The axes should all be zero when the joystick is in the center position. They should not jitter by themselves to other close values, and they also should be steady in any other position of the stick. They should have the full range from -32767 to 32767. If all this is met, then it's all fine, and you can play the games. :) If it's not, then there might be a problem. Try to calibrate the joystick, and if it still doesn't work, read the drivers section of this file, the troubleshooting section, and the FAQ. 2.6. Calibration For most joysticks you won't need any manual calibration, since the joystick should be autocalibrated by the driver automagically. However, with some analog joysticks, that either do not use linear resistors, or if you want better precision, you can use the jscal program jscal -c /dev/js0 ............... |
Maybe it still need some configuration or it's a bug in the kernel (the documentation in 2.4 kernel says that support for Playstation joystick is still under development).
[Peter] Well, to debug we'd need a better description of the symptoms than "ships did some strange movement in xgalaga", I mean any kernel developer would probably find that quite insuffuicient :)
But I'm quite happy to see that my Linux box is now more fun with joystick support :)
I haven't had time to try this on 2.6 kernel. Anyway thanks very much for the help :)
[Peter] Could be that in 2.6 the driver would read more frequently from the parport than in 2.4, resulting in a more responsive joystick, so it could be worth a try. Especially to get sound to work at the same time, as you mentioned.