Programing help read USB Joystick using gcc

Matt Graham danceswithcrows at usa.net
Wed Feb 23 21:13:14 MST 2011


From: Mike Bushroe <mbushroe at gmail.com>
> I have been trying unsuccessfully for some time to figure out how to
> read the analog axes and digital buttons on one or more USB joysticks
> connected to a computer with an open source programming language like C
> compiled by gcc.

Please have a look at http://crow202.org/jstest.c.txt , which is part of the
confusingly-named "ruby" tarball.  The Linux kernel people who worked with the
input layer are responsible for that, and its stated purpose is to teach folks
how to write joystick-enabled stuff.  It only works with Linux though.  I'm
assuming that's what you want.  It's also pretty low-level.  There are
libraries like SDL that attempt to do a more abstract thing, and SDL is also
multi-platform, but jstest will get you going quickly....

> I am trying to write a program to send serial command data to a
> microcontroller to operate an underwater ROV using the joysticks to control
> movement and manipulator arms, and buttons to control lights, secondary
> cameras, ballast tanks, etc

Take a look at jstest and see if you can figure out how that all does its
thing.  Then modify the code so that instead of printing out stuff, it feeds
data to whatever's sending data over the microcontroller.  Hope That Helps.

-- 
Matt G / Dances With Crows
The Crow202 Blog:  http://crow202.org/wordpress/
There is no Darkness in Eternity/But only Light too dim for us to see







More information about the PLUG-discuss mailing list