PDA

View Full Version : Joystick help needed



bsperlin
06-15-2001, 04:26 AM
Good morning,
I just got a Microsoft Sidewinder joystick and I'm having some problems with it. It centers and measures extreme values ok but:
1) There is no output when the stick is not moving. This means that when the stick is held in an extreme position I can't continue using input values to do something ( such as continue moving in the same direction ). Also, no button press registers since the button values only input when the stick has been moved.
2) A rotating knob on the base sends output to the z parameter, but the twist function in the stick doesn't send anything to x,y or z ( or a button value ). How can I change this so that the twist function is read?
I currently am using Glut which inputs x, y, z and the buttons to the joystick function. I know that there are some free libraries out there that handle the joystick. 1) Do any of them solve the problems listed above? 2) Which is your vote for the best of them?
Thanks,
Barry

hpsolo
06-15-2001, 10:06 PM
I think you might want to try out SDL. However, a better approach to joystick motion detection is NOT by directly reading the current joystick info. What you probably want to do is something like this:

1. check to see if joystick motion is detected

2. if so, then store the motion (e.g. user presses the up button ==> joy_up_yaxis = 1; if the motion is a release, then joy_up_yaxis = 0 http://www.opengl.org/discussion_boards/ubb/wink.gif and only alter these when a NEW joystick axis motion is detected. so your program would only check joy_up_yaxis; the key handling would be through a separate function which alters joy_up_yaxis

more info on www.libsdl.org (http://www.libsdl.org)

bsperlin
06-19-2001, 06:18 AM
Good morning,
An update with some partial answers:
1) The problem with getting a continuous reading of the joystick was solved by a co-worker who pointed out that using the function glutForceJoystickFunc in the idle function, with the poll rate set to 0 would cause a "continuous" polling ( at least when idle is called ). So now, when the stick isn't moving the values do flow in and can be used for continuous motion.
2) I haven't solved the second problem of changing the reading of the twist-function from being the rudder to being the "z" value, but I haven't downloaded the SDL libraries yet and maybe they have a solution.
Thanks for the suggestion!
Barry

jono_123
05-15-2002, 10:23 PM
could someone please email me(jono_123_2000@hotmail.com) the glut joystick files becuase i am in need of them too
thanks
http://www.opengl.org/discussion_boards/ubb/smile.gif