Thanks for the reply!
Actually, I just missed to type "struct" before "js_event", that solved it all.
I didn't have to pass anything to gcc since linux/joystick.h lives at
/usr/include, and gcc always looks there,
so
Now the code looks like
Code:
// for printf
#include <stdio.h>
// for usleep
#include <unistd.h>
// for open()
#include <fcntl.h>
// for js_event
#include <linux/joystick.h>
int main() {
struct js_event msg;
char* device = "/dev/input/js0";
int fd = open(device, O_RDONLY);
while(1) {
if(read(fd, &msg, sizeof(struct js_event)) != sizeof(struct js_event)) {
printf("Error when reading from joystick\n");
exit(1);
} else {
printf("wee\n");
if(msg.type == JS_EVENT_BUTTON)
printf("button press\n");
if(msg.type == JS_EVENT_AXIS)
printf("axis pressed\n");
usleep(10000);
}
}
return 0;
}
As you can see when you run the program, "wee" is printed many times even though
you don't press any keys, that's probably some info stuff or something.
Well, now I know what I need to. Thanks!