How to implement Joystick Support

I was working on a flight simulator. Does anybody know hoe to implement joystick support? Is there anyway to do it through Direct Input or Windows Programming?

You asked 2 questions… here are the answers:

1: Yes, I know.
2: Yes, there is.


Gee, how helpful, rts.

Acer, look in the documentation for a function called joyGetPos. It’s probably the easiest way to quickly get joystick input from Windows.

If you’re doing it for a game or a demo you should probably use DirectInput. It’s faster than GDI and takes advantage of any hardward accelleration present.

Thanx for the posts. I know directX pretty well or at least Direct Audio and Direct3d. I just have to learn Direct Input. I don’t think I will be using windows for it. Anyway I have an awesome flight simulator I am working on. Your moving through the sky and you have a burst of flame coming out the back of the plane. As soon as I add a menu and joystick support, I’ll add it to my webpage and you guys( and girls) can check it out.

Wasn’t there a tutoriol on DirectInput at NeHe’s site?

I think rts’s answer length was partly due to the fact that Joystick support has NOTHING to do with OpenGL… There are game development discussion forums around there for that type of question !


I think rts’ answer was very apt and to the point. =)

Everything you need can be found at ( In particular, look at the third box of links labeled “DirectInput”. Jason Brooks has created three classes for DirectInput control … One for keyboard input, one for mouse input, and one for Joystick input.

Jason did a great job with these classes and I rely on them every day. Send him email if you like it.

Actually, if you are looking toward making your program platform independent, you might want to consider SDL ( It’s simple to use, and there are even examples to get you started.