I am trying to compare the last value from a joystick file driver located at
/dev/input/js0
Just for testing, in the linux shell I am using xxd to make the hex dump:
xxd -c1 -p /dev/input/js0
And I see the value I am looking for, until here everything is ok!
I want to make a c code that prints a message when the last byte of that file is 1. But i don't know how to assign that byte to a variable, since the file js0 changes it's value with every key pressed.
Here is my code,
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
int main(int argc, char **argv){
system("sudo chmod 777 /dev/input/js0");
system("xxd -c1 -p /dev/input/js0");
return 0;
}
but I don't know how to proceed. Should I save the xxd in another file and read at the same time it's being saved? How?