网站上地图是怎样做的,网络宣传渠道有哪些,安徽龙山建设有限公司网站,代理网络阅卷测试内核input 事件测试程序。
getevent -lt 命令查看注册的是是event0/1/2/3/4 中的哪一个。 gcc input_test.c -o input_test 编译成可执行程序。将编译的input_test#xff0c;U盘或ADB push到系统里面#xff0c;chmod 777 input_test 在 ./input_test
input_test.c
#…测试内核input 事件测试程序。
getevent -lt 命令查看注册的是是event0/1/2/3/4 中的哪一个。 gcc input_test.c -o input_test 编译成可执行程序。将编译的input_testU盘或ADB push到系统里面chmod 777 input_test 在 ./input_test
input_test.c
#include stdlib.h
#include poll.h
#include unistd.h
#include stddef.h
#include stdio.h
#include fcntl.h
#include sys/ioctl.h
#include hcuapi/input.h
#include kernel/lib/console.h#define BUF_SIZE 1024static void print_help(void) {printf(***********************************\n);printf(input test cmds help\n);printf(\tfor example : input_test -i 1\n);printf(\ti 1 means event1\n);printf(***********************************\n);
}static int input_test(int argc, char *argv[])
{int fd;struct input_event t;struct pollfd pfd;char input_buf[BUF_SIZE];char *s /dev/input/event;long tmp;int x 0, y 0, z0;int event_num -1;char ch;opterr 0;optind 0;while((ch getopt(argc, argv, hi:)) ! EOF){switch (ch) {case h:print_help();return 0;case i:tmp strtoll(optarg, NULL,10);event_num tmp;break;default:printf(Invalid parameter %c\r\n, ch);print_help();return -1;}}if(event_num -1){print_help();return -1;}sprintf(input_buf,/dev/input/event%d,event_num);fd open(input_buf, O_RDONLY);pfd.fd fd;pfd.events POLLIN | POLLRDNORM;if(fd 0){printf(cant open %s\n,input_buf);return -1;}while (1) {if (poll(pfd, 1, -1) 0)continue;if (read(fd, t, sizeof(t)) ! sizeof(t))continue;printf(type:%d, code:%d, value:%ld\n, t.type, t.code, t.value);if (t.type EV_KEY) {printf(key %d %s\n, t.code,(t.value) ? Pressed : Released);if (t.code KEY_POWER !t.value) {while (read(fd, t, sizeof(t)) sizeof(t));break;}}else{if (t.type EV_ABS){if (t.type EV_ABS t.code ABS_X) {x t.value;}if (t.type EV_ABS t.code ABS_Y) {y t.value;}if (t.type EV_ABS t.code ABS_Z) {z t.value;}}if (t.type EV_SYN) {printf((%4d %4d %4d)\n,x,y,z);}}}close(fd);return 0;
}CONSOLE_CMD(input, NULL, input_test, CONSOLE_CMD_MODE_SELF, input test, press power to exit test)