zoukankan      html  css  js  c++  java
  • 键盘 Input子系统

    应用层测试代码

    #include <stdio.h>

    #include <stdlib.h>

    #include <unistd.h>

    #include <linux/input.h>

    #include <sys/fcntl.h>

    int main(int argc, char *argv[])

    {

           int fd = -1;

           int num;

           size_t rb;

           int version;

           char name[20];

           struct input_event ev;

           int i=0;

           if ((fd = open("/dev/input/event1", O_RDONLY)) < 0)  //打开设备

           {

                  perror("open error");

                  exit(1);

           }

           while(1)

           {

                  rb = read(fd, &ev, sizeof(struct input_event));  //读取设备

                  if (rb < (int)sizeof(struct input_event))  //读取错误

                  {

                         perror("read error");

                         exit(1);

                  }

                  if (EV_KEY==ev.type)                     //读取的是否是按键内容

                  {

                         if (1 == ev.value)                   //key1被按下

                         printf("key is pressed ");

                         else                                                       //key1被释放

                         printf("key is released ");

                  }     

           }    

            close(fd);

           return 0;

    }

  • 相关阅读:
    db2缓冲池调优
    linux下安装rpm出现error: Failed dependencies
    linux下挂载磁盘
    db2 常见错误以及解决方案[ErrorCode SQLState]
    db2数据库表操作错误SQL0668N Operation not allowed for reason code "1" on table "表". SQLSTATE=57016的解决方法
    db2用户权限赋值
    db2查看当前用户模式及当前用户的权限
    loadrunner常用函数整理
    书上的脚本案例
    hdu 1711---KMP
  • 原文地址:https://www.cnblogs.com/zym0805/p/5983885.html
Copyright © 2011-2022 走看看