首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

uClinux停应用程序获取USB键值

2013-04-05 
uClinux下应用程序获取USB键值[ 注:内核代码中Documentation/input/input.txt,有输入设备的介绍。]系统检测

uClinux下应用程序获取USB键值

[ 注:内核代码中Documentation/input/input.txt,有输入设备的介绍。]

系统检测到USB键盘后,一般会将其映射到/dev/input/event0,可能使用cat命令进行确认:

      #cat /dev/input/event0

操作USB键盘时会有乱码出现。

也可以用以下命令查看设备与节点的关联:

      #cat /proc/bus/input/devices

我的系统接入一块罗技的USB键盘,输出以下信息:

#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <stdio.h>#include <linux/input.h>struct input_event buf;int main(int argc, char **argv){    int fd;    int nread;    fd = open("/dev/input/event0", O_RDONLY);    if (fd < 0)    {        printf("fail to open usbdev.\n");        exit(1);    }    printf("--fd = %d--\n", fd);    while (1)    {        nread = read(fd, &buf, sizeof(buf));        if (nread != 0)        {            printf("type : %d, code = %d, value = %d\n",                    buf.type, buf.code, buf.value);        }    }    return 0;}


热点排行