I am unsure if this is the correct place for this question. I am attempting to obtain the axis position values from a joystick /dev/input/js0
on my system. If I run jstest /dev/input/js0
it will give me live feedback on all buttons and axis positions.
I am trying to feed this information into my C program to control servos. Is there a function for doing this? I have not worked much with input devices in programming so this is all new to me.
This page: http://scaryreasoner.wordpress.com/2008/02/22/programming-joysticks-with-linux/ has a nice writeup on how to read the info from /dev/input/js0
The format of the events you read from the file are documented here: https://www.kernel.org/doc/Documentation/input/input.txt . It's a simple struct containing a timestamp, the event type and identifier and the value:
struct input_event {
struct timeval time;
unsigned short type;
unsigned short code;
unsigned int value;
};