#include
#include
#include
#include
#include
#include
#include
int main(void)
{
int fd_key,fd_ts, fd_led, fd_max;
struct input_event event_key,event_ts;
int dac_value;
struct timeval select_timeout;
fd_set readfds;
select_timeout.tv_sec= 20;
select_timeout.tv_usec = 0;
fd_key= open("/dev/input/event0", O_RDWR);
fd_ts = open("/dev/input/event1", O_RDWR);
if (fd_key>fd_ts)
fd_max = fd_key;
else
fd_max = fd_ts;
while(1)
{
FD_ZERO(&readfds);
FD_SET(fd_key, &readfds);
FD_SET(fd_ts, &readfds);
select_timeout.tv_sec= 2;
select_timeout.tv_usec = 0;
select(fd_max + 1, &readfds, NULL, NULL, &select_timeout);
if ( FD_ISSET(fd_key, &readfds))
{
printf("begin to read key\n");
read(fd_key, &event_key, sizeof(struct input_event));
printf("key value:type=%d, code=%d, value=%d\n",event_key.type, event_key.code, event_key.value);
}
else if(FD_ISSET(fd_ts, &readfds))
{
printf("begin to read touch screen\n");
read(fd_ts, &event_ts, sizeof(struct input_event));
printf("Touch screen value:type=%d, code=%d, value=%d\n",event_ts.type, event_ts.code, event_ts.value);
}
printf("select run again again\n");
}
}
阅读(1679) | 评论(0) | 转发(0) |