Linux NetMag #3
Titel: Jslaunch -- steering a PC with joystick
URL: http://www.linuxnetmag.de/de/issue3/m3launch1.html

LinuxGames-Logo
With Linux, a joystick usually collects dust because few games use it. So why should there not be another use for your joystick?


Don't think that you have to use the joystick instead of the mouse from now on - we are not going that far. The program "jslaunch" makes it possible to execute special commands if you press a joystick button. The first question is: And this is good for . . . ?

The "very high stability" mentioned about Linux only really means that the kernel is stable. All programs (like the mouse and keyboard support or XFree86) are not free of crashes. Also, when using un-supported hardware (e.g. TV-cards), Linux is capable of crashing. But usually it just seems that the kernel is still running without any problems and just the program for mouse, keyboard or graphic support stopped. In this case it is possible to log in from another computer and halt the system correctly. This way you avoided a long hard disk check (especially if you have a very big partition) that would be necessary if you pressed the reset button. But what can you do if you do not have a local network or the network card does not respond? Jslaunch may help. This program is usually still running and you can reboot or halt the system via the joystick.
 
 

Configuration

Jslaunch does not use a kernel module to access the joystick. A new kernel (or a new module) is not necessary. The ports are read out directly by jslaunch. This could cause trouble if you included joystick support into the kernel and used it for games. If you pressed the fire button while playing this could also execute a restart. A very short game is guaranteed. 8)

For all of you who already use the joystick for games then, this program is not recommended. All others should read further.

Jslaunch offers two configuration choices. Either you manually submit all parameters (which program should be started for every button combination) or you save this configuration centrally in the file /etc/jslaunch.conf and start jslaunch without any options.

You get the program either as a RPM or as the source code at http://rpmfind.net/linux/RPM/contrib/libc6/i386/jslaunch-2.0-1.i386.html .

If you downloaded the source code you should extract it to /usr/local with

>> tar -zxvf /usr/local

and compile it there with make. The program has to be executed as root.

>> su

Now we test the program and type:

>>./jslaunch -r 1 "echo OK"

If you press the fire button the text "OK" should appear on the monitor.

The numbers behind "-r" describe which buttons have to be pressed simultaneously to execute the following command in quotes. If you own a joystick with 4 buttons you should configure jslaunch in a way that all buttons have to be pressed to reboot the system (-r 1234). Otherwise it could happen that you (or someone else) presses one button by accident and the system shuts down.

The program should be started with every system start so it is running in case of an emergency. You create (as for every other program started during booting) an init-script that is executed while booting.

If you did not like so much work, you could also add the following entry in the file /sbin/init.d/boot.local in the last line.
 

File /sbin/init.d/boot.local
 #Last line in boot.local
 /usr/local/jslaunch-2.0/jslaunch -r 1234 "reboot"

This configuration is not as "clean" as the init script approach, but it has the same effect.
At the next hang up of your system, you will know what all this work is worth.
 
 

For developers

With jslaunch you have many possibilities to make much easier use of your PCs. For example, you use an old Linux PC as a router or mail-server and you control the PC without any monitor or keyboard. If the PC hangs up and is not accessible via the net any longer you can restart it with the joystick.
Many old PC cases have a Turbo-button. This relic of old CPUs is not in use any longer. But if you connect the fire button on an old joystick with the Turbo button you will have a nice button for a software reset and the button is useable again.

Homepage: http://rpmfind.net/linux/RPM/contrib/libc6/i386/jslaunch-2.0-1.i386.html