#include "tslib.h" int touch_position(int*px, int*py) { struct tsdev *ts; struct ts_sample samp; int flag; ts = ts_open("/dev/input/event0", 0) //opening touchscreen device if (!ts) { perror("ts_open"); return(1); } if (ts_config(ts)) { perror("ts_config"); return(2); } flag = ts_read(ts, &samp, 1); // reading position if (flag < 0) { perror("ts_read"); return(3); } *px= samp.x ; *py = samp.y ; ts_close(ts); return 0; }