關(guān)于Linux設(shè)備驅(qū)動中input子系統(tǒng)的介紹
測試程序:
#include
#include
#include
#include
#include
int main(void )
{
int fd;
int key_value,i=0,count;
struct input_event ev_key;
fd=open(/dev/input/event0,0666);
if(fd0){
perror(open device);
exit(1);
}
while(1){
count=read(fd,ev_key,sizeof(struct input_event));
for(i=0;i(int)count/sizeof(struct input_event);i++)
{
if(EV_KEY==ev_key.type)
{
int num=ev_key.code%10-1;
printf(type:%d,code:%d ,value:%dn key%d pressed!n,ev_key.type,ev_key.code,ev_key.value,num);
}
if(EV_SYN==ev_key.type)
printf(syn eventn);
}
}
close(fd);
return 0;
}
評論