PDA

View Full Version : glut and gamepads under linux!



gunslinger
09-08-2005, 11:08 PM
Hi all gamedev-ers!

I am writing some OpenGl code,
using glut to "talk" with the X11 stuff.
Now i wanted to add support for an
USB gamepad, but... i dunno where to start:
I correctly installed the gamepad
(i know cause i see output cat-ing the
/dev/input/js0 file). But other than
that i can't see how to get the joy callback
running in the app...

thanks for the help!! :)

dvm
09-09-2005, 12:43 AM
Well, you might be in for a dissapointment here. I don't think that glut can handle joysticks. SDL might be a better solution here.
But just to make certain, check the glut manual here (http://www.xmission.org/~nate/glut.html)
and see what types of input it supports. I could be wrong.

Upon inspecting the manual myself, I'm not sure if you could register the spaceball callbacks and get joystick input from there. Maybe by piping the corresponding /dev/* entry? Just an idea though. Good luck ;)

SFRuckus
09-09-2005, 06:24 AM
An API for working with the joystick under linux is described here.

http://www.linuxhq.com/kernel/v2.4/10/Documentation/joystick-api.txt

I have used it under v2.6 and it works fine. There is an RPM that has the API description, header files and some programs for calibrating your device. I am not sure if it is being updated.

As dvm said, SDL or a similar framework is good solution that can save you from a lot of platform specific, graphics-unrelated and tedious work that many have implemented and debugged already.

- SFRuckus