View Single Post
Community Council | Posts: 4,920 | Thanked: 12,867 times | Joined on May 2012 @ Southerrn Finland
#7
OK, so I did some tinkering and now I am able to read off coordinates from the touch screen. It turned out to be fairly easy after I found out the correct device to use, each touch will generate a burst of events, out of which I am filtering out all except absolute X and Y coordinate events. The following snippet shows how I am doing it.

Code:
  struct input_event ievent;
  int fd, xaxis, yaxis, flag=0, ret;

  if ((fdev = open("/dev/input/event3",  O_RDONLY)) < 0) {
    perror("cannot open input device");
    return -1;
  }

  while(1) {
    if((ret = read(fdev ,&ev ,sizeof(ievent))) < sizeof(ievent)) {
      printf("\nreceived only %d bytes on read", ret);
      return -1;
    }
    if(ievent.type == EV_ABS && ievent.code == ABS_X) {
      xaxis = ievent.value;
    }
    if(ievent.type == EV_ABS && ievent.code == ABS_Y) {
      yaxis = ievent.value;
      flag = 1;
    }
    if(flag) {
      flag = 0;
      printf("\ntouch = %d, %d", xaxis, yaxis);
    }
  }
Now, does anybody remember off the top of head how can I easily generate a short vibration effect for tactile feedback? I would assume it can be done by writing some structure to an output device, but what device and what kind of data?
 

The Following 2 Users Say Thank You to juiceme For This Useful Post: