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;

    }

  • 相关阅读:
    为什么要有handler机制
    安卓五种数据存储的方式
    Activity生命周期详解
    JS的一些简单实例用法
    JSP 中的EL表达式详细介绍
    JSP九大内置对象和四个作用域
    JS实现---图片轮播效果
    实现 鼠标移动到表格的某行 该行换背景 ---myEclipse编写
    JS 菜单收拉样式
    spring中aware接口的
  • 原文地址:https://www.cnblogs.com/zym0805/p/5983885.html
Copyright © 2011-2022 走看看