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

USB hid 键盘驱动的设备节点?该如何解决

2012-02-26 
USB hid 键盘驱动的设备节点?我的嵌入式开发板上用的linux,我用的是USB hid的驱动,键盘能够正常使用了,键

USB hid 键盘驱动的设备节点?
我的嵌入式开发板上用的linux,我用的是USB hid的驱动,键盘能够正常使用了,键盘插上后也能够正常识别,但是键盘输入的键值怎么读出来啊!HID设备的键盘驱动是没有设备节点的!好像键盘的输入都打到/dev/tty设备中去了!可是/dev下有好多tty设备啊!究竟是哪一个啊??折磨死我了!!高手帮帮小弟吧!!

[解决办法]
/dev/eventX.

你可以cat读一下.

[解决办法]
在/dev/input/目录下有对应节点:
你写个应用程序读对应节点即可,把我的程序编译一下,然后运行读键值:

C/C++ code
#include <stdio.h>#include <stdlib.h>#include <linux/input.h>#include <asm/fcntl.h>int main(void){    int ret;    int fp    = 0;    struct input_event    key_event;    fp=open("/dev/input/event0", O_RDONLY);    if(fp<0){        printf("Error: cannot open ir keypad device.\n");        return -1;    }    while(1){        ret = read(fp, &key_event, sizeof(struct input_event));        if(ret != sizeof(struct input_event)) {            printf("read is error. \n");            return -1;        }        switch(key_event.value) {        case 0:            printf("release %d.\n", key_event.code);            break;        case 1:            printf("press %d.\n", key_event.code);            break;        default:            printf("value is error.\n");            break;        }    }    close(fp);    return 0;    } 

热点排行