KBStick Joystick Hack
KBStick is a little kludge I wrote in order to use my joystick in
Quake3 and other X Windows games with (at the point I write this) no support for the
Linux joystick interface. KBStick uses the XTest extension to XFree86 to
send keyboard messages to the X Server.
Unpacking the KBStick source archive (below) will create a kbstick/
subdirectory and the source and make files to build the KBStick
executable and the QStick shell script used to run it.
You can unpack the archive file with a command like:
gunzip -c kbstick.tar.gz | tar xvf -
You can build KBStick and the QStick shell script by changing to
the kbstick/ subdirectory created when you unpacked the archive and typing:
make
To run the program, copy the kbstick executable and the qstick
shell script created by running make in the kbstick/ subdirectory
to a directory in your PATH, then type:
qstick
Home Page
The KBStick home page is at:
http://www.ditch.org/kbstick/
Setup
Setting up a game like Quake3 to use KBStick is simplicity
itself; just run qstick in an X terminal, then run Quake3, go to
the controls configuration, use the mouse to pick which action you want to
configure, then press the joystick axis or button you want to perfom the
action. That's it!
Configuration
The qstick shell script sets up the environment variables that
KBStick reads to assign keyboard codes to presses of the joystick buttons
and movement of the stick itself. The default qstick shell script sets up
shell variables for the X KeyCodes corresponding to the numeric
keypad on the right side of most keyboards, exports the variables to the
environment, then runs kbstick in the background with the default joystick
/dev/js0.
If you wish to assign KeyCodes already set up in the default
qstick shell script to other joystick buttons/axes than thye already are,
just open the script in a text editor and change the what you want in the
assignment part of the shell script.
To change the default assignment of joystick button #0:
KBS_Button_0=$KP_Home # Sends Keypad Home/7 (KeyCode 79)
Just change it to...
KBS_Button_0=$KP_End # Now sends Keypad End/1 (KeyCode 87)
To assign KeyCodes other than those set up by default you
can learn the code for the desired key you want to send by running the
xev application in an X session, pressing the desired key and
reading the
KeyCode portion of the message that results (moving the mouse pointer
away from the xev window will prevent any mouse messages you might
get if you move the mouse.) You may then open qstick in a text editor and assign a shell
variable (hopefully with a descriptive name) to the KeyCode in the first
section, then assign the value of the shell variable to a button or axis:
Semicolon=47 # Assign shell variable the KeyCode of the semicolon key
...
KBS_Button_0=$Semicolon # Assign the value to button #0
You can of course simply assign a KeyCode number value to the KBS
variables as well, but I personally can't remember which of the 102+ KeyCodes
go with which keys, so pre-assigning KeyCode values to shell variables with
descriptive names lets me know with a glance into the qstick file which button
or axis corresponds to which keyboard key.
KBStick and the QStick shell script are the work of
David A. Fulgham
Mail to:daive@ditch.org