//-------------------------------------------测试程序----------------------------------------------------
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
main()
{
int fd;
char key=0;
fd = open("/dev/button_scan", O_RDWR);//打开设备
if (fd == -1)
{
printf("open device button errr!\n");
return 0;
}
ioctl(fd,0,0); //清空键盘缓冲区, 后面两个参数没有意义,
while(key != 16)
{
if (read(fd, &key, 1) > 0)//读键盘设备,得到相应的键值
{
printf("*********************Key Value = %d*****************************\n", key);
}
}
close(fd);// //关闭设备
return 0;
}