测试写好的输入设备模块,比如遥控器,交叉编译后bin档放到rootfs/bin,直接运行
/* test remote.ko
* you should insmod remote.ko and config it before
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/input.h>
struct input_event buff;
int main(int argc, char **argv)
{
int fd;
printf("%s: entered/n", argv[0]);
fd = open("/dev/input/event0", O_RDONLY);
if(fd == -1) {
printf("open failed");
exit(-1);
}
printf("%s: open successful: %d/n", argv[0], fd);
while(1) {
if(read(fd,&buff,sizeof(struct input_event))!=0)
printf("type:%d code:%d value:%d/n",buff.type,buff.code,buff.value);
}
close(fd);
}