3.6. Command-line use and scripting

Although QJoyPad only works in XWindows, it supports changing axes on the fly from the command line. If you want to load up the layout named "Tetris", all you have to do is run:

qjoypad "Tetris"

and one of two things will happen. If QJoyPad isn't currently open, it will start running and load the "Tetris" layout (this is case sensitive! see Chapter 4). If QJoyPad is already running, it will just silently switch to the requested layout.

What's so great about this is it lets you forget about QJoyPad once you've made all your layouts, and just worry about your games! It's very easy to write short little shell scripts to automatically load the layout you need when you start up a game. For instance, if you wanted to run the game xgalaga++, using QJoyPad for joystick support, you could create a text file called run-xgalaga with the following lines in it:

#!/bin/sh

qjoypad "XGalaga" &		
xgalaga++

Then with the command "chmod a+x run-xgalaga" you could make that text file an executable shell script; once that's done, all you need to to do is execute run-xgalaga and QJoyPad will load the appropriate layout and your game will start. To use this script for any other program, just change "XGalaga" to a different layout name and "xgalaga++" to the name of some other program and you're done.