Back to the Vavoom Forum Archives


Forum

[Fixed] joystick using Linux Allegro

Sat, 24 Apr 2004 01:58:43

GregLee

I just bought a joystick and am trying to get it to work in Vavoom.  It does work, partly.  I added bind statements to a config.cfg file for "JOY1", "JOY2" for the trigger and left fire buttons, and they work fine.  Movements on the x- and y-axes work, but not correctly.  A movement on the y-axis once started, continues until I run into something -- it doesn't stop when the stick is released.  A lateral movement along the x-axis starts a slow drift, but the speed seems unrelated to how far the stick was moved, and here also, the movement continues even though the stick is released.<br><br>I've used the program jtest to check out whether the kernel driver and this stick get along, and it works ok.  When the stick is moved along either axis, the numbers output seem appropriate, and when the stick is released, the numbers shown for the x- and y-axes are 0.<br><br>I also used the test program that's part of the Allegro library setup program, and that works, too.  A white dot tracks the stick axis movements, and when the stick is released, the dot returns to the center of the screen, as it should.<br><br>As best I can tell from glancing over the Vavoom source code, joystick x- and y-axis movements are treated as equivalent to mouse movements.  Yet mouse movements work, and stick movements don't.  What could be going wrong?<br><br>My joystick has a z-axis control, too, which I'd like to use.  But one thing at a time.<br>
Sun, 25 Apr 2004 07:16:51

GregLee

When I said "jtest" above, I meant "jstest".<br><br>I've partly solved my difficulties with using my joystick.  There's a key configuration parameter "joy_yaw" which had the default value "1".  I changed that to "10", and now left and right movements of the joystick have a reasonable effect (they did nothing useful, before).<br><br>To tame the forward and back movements of the joystick, I changed the code in two cl_input.cpp lines, from "if (joyymove < 0) forward += cl_forwardspeed;" to "if (joyymove < 0) forward += cl_forwardspeed / 10;" and from "if (joyymove > 0) forward -= cl_backspeed;" to "if (joyymove > 0) forward -= cl_backspeed / 10;".
Mon, 26 Apr 2004 17:03:57

Janis Legzdinsh

Yep, the joystick support is a known problem, mostlybecause I don;t have a joystick myself. Once I will have it, I'll fix all problems with it.
Tue, 27 Apr 2004 09:38:36

GregLee

[quote author=Janis Legzdinsh link=board=Troubleshooting;num=1082735925;start=0#2 date=04/26/04 at 10:03:57]Yep, the joystick support is a known problem, mostlybecause I don;t have a joystick myself. Once I will have it, I'll fix all problems with it.<br><br>I've made some progress.  The principle difficulty, I think, is the Allegro driver.  The poll procedure reads one joystick event each time it's called, but many events arrive per frame.  So the position information reaching the player is often way behind.  I patched in a new poll procedure to in_alleg.cpp, derived from the jstest program, which reads all events available, and now it works much better.<br><br>I also patched in support for my mouse wheel and the joystick throttle. The mouse wheel works ok, but I don't know what to do with the throttle values.  What should they control?<br><br>A brief look at the SDL joystick code suggests to me that it does the right thing, so it would be nice to get the SDL support working.<br><br>I'll post my changes to the Vavoom code when I've worked on it a little more (now it works only for a joystick just like mine), in case that should be any use.<br>
Wed, 28 Apr 2004 12:04:28

GregLee

Here are diffs.<br><br>No, sorry, the forum software won't let me put them here.  I'll email them.
Wed, 28 Apr 2004 16:51:38

Janis Legzdinsh

Got them, will look into them soon.
Thu, 29 Apr 2004 01:27:55

GregLee

I modified the Allegro poll_joy() routine, tested it, and sent a patch to the bug-tracker.  So far as that change goes, then, you might just wait for a new version of Allegro, assuming my patch is accepted.<br><br>The code I put in to recognize hat movements is incorrect in at least one regard.  In ReadJoystick, the threshhold 8192 should be 32, instead.  My joystick doesn't have a hat, so I'm just guessing how hats work.  When you buy a joystick, perhaps you could try to find one with a hat.
Thu, 29 Apr 2004 16:51:26

Janis Legzdinsh

Let's see what Allegro guys will do. They have accepted some of my bug fixes, so let's hope they will accept yours too.

Back to the Vavoom Forum Archives