新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 關(guān)于Linux設(shè)備驅(qū)動中input子系統(tǒng)的介紹

        關(guān)于Linux設(shè)備驅(qū)動中input子系統(tǒng)的介紹

        作者: 時間:2016-10-08 來源:網(wǎng)絡(luò) 收藏

        測試程序:

        #include

        #include

        #include

        #include

        #include

        int main(void )

        {

        int fd;

        int key_value,i=0,count;

        struct input_event ev_key;

        fd=open(/dev/input/event0,0666);

        if(fd0){

        perror(open device);

        exit(1);

        }

        while(1){

        count=read(fd,ev_key,sizeof(struct input_event));

        for(i=0;i(int)count/sizeof(struct input_event);i++)

        {

        if(EV_KEY==ev_key.type)

        {

        int num=ev_key.code%10-1;

        printf(type:%d,code:%d ,value:%dn key%d pressed!n,ev_key.type,ev_key.code,ev_key.value,num);

        }

        if(EV_SYN==ev_key.type)

        printf(syn eventn);

        }

        }

        close(fd);

        return 0;

        }


        上一頁 1 2 下一頁

        關(guān)鍵詞:

        評論


        相關(guān)推薦

        技術(shù)專區(qū)

        關(guān)閉
        主站蜘蛛池模板: 泾阳县| 合山市| 霞浦县| 元阳县| 改则县| 来安县| 南澳县| 剑川县| 沙雅县| 大厂| 桃园市| 新平| 千阳县| 玉门市| 鄯善县| 镇沅| 铜川市| 习水县| 龙门县| 上饶市| 岱山县| 华池县| 治县。| 友谊县| 弥勒县| 南平市| 东乡族自治县| 涞水县| 梧州市| 凉城县| 宜春市| 葵青区| 滁州市| 武强县| 沂源县| 旺苍县| 云南省| 和田县| 青海省| 嫩江县| 镶黄旗|