#include #include #include #include #include #include void dump_event(struct timespec* start, struct input_event* event); int stream_events(char* device_path); static inline void timespec_diff(struct timespec* a, struct timespec* b, struct timespec* result) { result->tv_sec = a->tv_sec - b->tv_sec; result->tv_nsec = a->tv_nsec - b->tv_nsec; if (result->tv_nsec < 0) { --result->tv_sec; result->tv_nsec += 1000000000L; } } void dump_event(struct timespec* start, struct input_event* event) { unsigned char button, bLeft, bMiddle, bRight; unsigned char *ptr = (unsigned char*)event; int i; char x, y; struct timespec now; struct timespec diff; clock_gettime(CLOCK_MONOTONIC, &now); timespec_diff(&now, start, &diff); button = ptr[0]; bLeft = button & 0x1; bMiddle = ( button & 0x4 ) > 0; bRight = ( button & 0x2 ) > 0; x=(char) ptr[1];y=(char) ptr[2]; printf("%ld.%ld,m,l%d,m%d,r%d,x%d,y%d\n", diff.tv_sec, diff.tv_nsec, bLeft, bMiddle, bRight, x, y); // // comment to disable the display of raw event structure datas // // for(i=0; i