Advertisement

using joysticks in GTK apps?

Started by December 08, 2002 09:52 PM
0 comments, last by tortoise 21 years, 9 months ago
This has proven to be a really obscure topic and I had even given up on it being possible until I saw http://wolfpack.twu.net/libjsw/ which is a joystick calibration program using gtk. Any idea on how to use a joystick as a gtk program''s main means of input? I''d like to navigate through widgets with the directional pad, select a widget with a button, etc. I''ve taken a look at jscalibrator''s source code, there''s quite a bit of it and it''s not very commented, so so far progress is very slow. If anyone has any suggestions, I''m all ears. Thanks.
Just to complete the thread I''ll throw the answer out to my own question.

It looks as though both gtk and qt offer rather nifty functions/classes which enable you to register a callback whenever a file descriptor changes.

For gtk it''s the function gtk_input_add (or gdk_input_add, not entirely sure of the difference) and for qt it''s the class QSocketNotifier.

They both work under the same idea. Invoke them with a file descriptor (say, from opening up /dev/js0), and pass them a function pointer to what you want to happen when something happens on the fd.

I''ve not implemented either yet, but from some searching it looks like they do the trick.

http://freshmeat.net/projects/gtkjoy/?topic_id=80

that''s a small, sample app that shows how to do it in gtk.

This topic is closed to new replies.

Advertisement