test-buttons.c
来自「linux下按键的驱动」· C语言 代码 · 共 24 行
C
24 行
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include <errno.h>
main(void)
{
int buttons_fd;
int key_value;
int ret;
buttons_fd=open("/dev/buttons/1",0);
while(1)
{
ret=read(buttons_fd,&key_value,sizeof(key_value));
if(ret<0)
{
continue;
}
printf("buttons_value: %d\n",key_value);
}
close(buttons_fd);
return;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?