Dear Experts, I am developing a simple touch screen based application in Linux C on fc12 platform, where I have some trouble while reading the device driver for touch screen /dev/input/event0. My code is as follows, #include<stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include<stdlib.h> main() { int fileno = open("/dev/input/event0",O_RDONLY),num_bytes; char ev[50]; num_bytes = read(fileno,ev,50); if(num_bytes<=0) { perror("Cannot access"); exit(FAILURE); } printf("%d\n",fileno); printf("\nNumber of bytes read is %d\n string is %s\n",num_bytes,ev); close(fileno); } 1> Opening the port successfully 2> Reading the port successfully 3> Closing the port successfully But, the values read are garbage. How can I read the touch co-ordinates of the touch screen successfully. The debug information sent as an attachment. With Regards.
reading touch screen device (/dev/input/event0)
struct input_event ev; num_bytes=read(fileno,&ev,sizeof(struct input_event)); Depending on ev.type and ev.code you will get either X, Y coordinate or other information.
Dear Sir, Can I know in which header file this struct input_event is declared, so that i can define it with ev variable. Thank You. With Regards, Be Embedded.
Simply do a look into this tool: http://enialis.net/~jrd/salix/evtest/1.25-i486-1cp/evtest-1.25.tar.bz2
Dear Experts, How to calculate the touch screen co-ordinates from the members of struct input_event ev; ie (ev.code & ev.type). With Regards.
You should use the tslib (refer git://github.com/kergoth/tslib.git)
ok i can read the ABS_X and ABS_Y under the event ABS for the mini2440 (240 X 320 pixel size). However, the coordinates I am getting are unexpected. for the upper left corner i am getting (929,111), for upper right (111,111), lower left (929,929) and lower right (110, 929). do i need to do any conversion to get the right coordinates. I suppose the upper left corner is (0,0)
anyways i solved it............... if anyone is interested then have a look at it here......... http://www.ti.com/lit/an/slyt277/slyt277.pdf http://www.embedded.com/design/configurable-systems/4023968/How-To-Calib...