mykey_test(测试程序).c
来自「这个是Linux下的按键驱动程序」· C语言 代码 · 共 35 行
C
35 行
#include <stdio.h>#include <stdlib.h>#include <asm/ioctl.h>#include <asm/errno.h>#include <linux/slab.h>#include <fcntl.h>#include <pthread.h>#include <string.h>#include <unistd.h>int fb;unsigned short value;int main(){ fb = open("/dev/my_key",O_RDWR); if(!fb) { printf("open device is fail !!! \n"); return 0; } while(1) { getchar(); read(fb,&value,sizeof(short)); printf("the key value is 0x%04x \n",value); getchar(); } close(fb); return 0;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?