Skip to content

Instantly share code, notes, and snippets.

@sh4869
Created February 7, 2016 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sh4869/c1aeaca686cf1fea3eb3 to your computer and use it in GitHub Desktop.
Save sh4869/c1aeaca686cf1fea3eb3 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <linux/input.h>
#include <unistd.h>
int main(void)
{
for (;;) {
struct input_event event;
if (read(0, &event, sizeof(event)) != sizeof(event)) {
exit(EXIT_FAILURE);
}
switch(event.type) {
case EV_ABS:
switch(event.code){
case ABS_MT_POSITION_X:
printf("X: %d\n",event.value);
break;
case ABS_MT_POSITION_Y:
printf("Y: %d\n",event.value);
break;
case ABS_MT_PRESSURE:
printf("Touch Pressure: %d\n",event.value);
break;
default:
printf("Event Code: %x, Event Value: %d\n",event.code,event.value);
break;
}
break;
default:
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment