兰州网站外包,综治暨平安建设网站,推广公司名字大全,如何建立公司网站域名检测指令#xff1a;cat /dev/input/event1 | hexdump
当键盘有输入时#xff0c;会有对应的一堆16进制输出。它其实对应着input_event结构体【24字节】。
struct input_event
{struct timeval time;__u16 type;__u16 code;__s32 value;
}; #include st…检测指令cat /dev/input/event1 | hexdump
当键盘有输入时会有对应的一堆16进制输出。它其实对应着input_event结构体【24字节】。
struct input_event
{struct timeval time;__u16 type;__u16 code;__s32 value;
}; #include stdio.h
#include sys/types.h
#include sys/stat.h
#include fcntl.h
#include linux/input.h
#include string.hint main(void)
{#define KEY_PATH /dev/input/event1int fd -1, ret -1;struct input_event ev;// 第1步打开设备文件fd open(KEY_PATH, O_RDONLY);if (fd 0){perror(open,error);return -1;}printf(welcome size%d.\n,sizeof(struct input_event));while (1){// 第2步读取event事件包memset(ev, 0, sizeof(struct input_event));ret read(fd, ev, sizeof(struct input_event));if (ret ! sizeof(struct input_event)){perror(read,error);close(fd);return -1;}// 第3步解析event包.printf(\n);printf([%11u] type: %3d, code: %3d, value: %3d \n,ev.time.tv_sec,ev.type,ev.code,ev.value);//type: 1:按键同步//code: 键码[a30]//value:0按键释放1按键按下,2:长按下}// 第4步关闭设备close(fd); return 0;
}