#include <stdio.h>
#include <unistd.h>
#include <linux/input.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define DEV_PATH0 "/dev/input/event0" //button1 button2对应的是event0
#define DEV_PATH3 "/dev/input/event3" //button3 button4对应的是event3
int main(int argc, char **argv)
{
int i = 0;
int but1 = 0;
int but2 = 0;
int but3 = 0;
int but4 = 0;
int times = 5; //缺省超时时间
int ret = 0;
char buffer[128] = {0};
int keys_fd = 0;
struct input_event t;
if (argc == 2) {
times = (int)strtoul(argv[1], NULL, 10); //传入的超时时间
}
keys_fd=open(DEV_PATH0, O_RDONLY | O_NDELAY); //非阻塞的方式打开
if(keys_fd <= 0)
{
printf("open /dev/input/event0 device error!\n");
return -1;
}
for(i=0;i<tim
button按键测试
最新推荐文章于 2021-10-07 01:15:06 发布