Created
February 7, 2016 11:18
-
-
Save sh4869/c1aeaca686cf1fea3eb3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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