QStick and the KBStick Joystick Hack



This tool hasn't been updated in 6 years, so I'd think that there would be something better out there by now. However, I see that the Frugalware Linux distribution includes a package for KBStick, so in the Frugalware authors' capable judgement it still has some value.

KBStick needs X Windows extension and test libraries in order to build, so you'll need to be sure they're installed. If you get build errors you can try searching for packages with names like libxext-dev(el) and libxtst-dev(el) and installing them to get the needed files.

DAF 7/27/09



  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

Requirements

  KBStick does not provide the interface Linux needs to communicate with your joystick; i.e. the joystick driver. A large number of joysticks are supported by the Linux kernel, a list of which can be found at:

   Vojtech Pavlik's Linux Joystick Driver page.

  You must either rebuild your Linux kernel to include support for your joystick internally or build the support into a kernel module.

Version/Updates



Download QStick

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.

Preconfigured Scripts



  KBStick and the QStick shell script are the work of David A. Fulgham
  Mail to: ( kbstick a#t ditch p#o#i#n#t org )