应用层测试代码

#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\n");

else                                                       //key1被释放

printf("key is released\n");

}

}

close(fd);

return 0;

}

键盘 Input子系统的更多相关文章

  1. input子系统

    input子系统:      像按键.键盘.鼠标.触摸屏.游戏摇杆等设备只有输入没有输出,而且在编程实现其对应的驱动程序时会有很多重复性的代码,内核的设计者将该部分代码抽象出来,驱动工程师只需要复用该 ...

  2. linux kernel input 子系统分析

    Linux 内核为了处理各种不同类型的的输入设备 , 比如说鼠标 , 键盘 , 操纵杆 , 触摸屏 , 设计并实现了一个对上层应用统一的试图的抽象层 , 即是Linux 输入子系统 . 输入子系统的层 ...

  3. input子系统详解

    一.初识linux输入子系统 linux输入子系统(linux input subsystem)从上到下由三层实现,分别为:输入子系统事件处理层(EventHandler).输入子系统核心层(Inpu ...

  4. input子系统分析

    ------------------------------------------ 本文系本站原创,欢迎转载! 转载请注明出处:http://ericxiao.cublog.cn/ -------- ...

  5. 基于input子系统的sensor驱动调试(二)

    继上一篇:http://www.cnblogs.com/linhaostudy/p/8303628.html#_label1_1 一.驱动流程解析: 1.模块加载: static struct of_ ...

  6. linux内核input子系统解析【转】

    转自:http://emb.hqyj.com/Column/Column289.htm 时间:2017-01-04作者:华清远见 Android.X windows.qt等众多应用对于linux系统中 ...

  7. Linux input子系统 io控制字段【转】

    转自:http://www.cnblogs.com/leaven/archive/2011/02/12/1952793.html http://blog.csdn.net/guoshaobei/arc ...

  8. input 子系统架构总结【转】

    Linux输入子系统(Input Subsystem) 转自:http://blog.csdn.net/lbmygf/article/details/7360084 Linux 的输入子系统不仅支持鼠 ...

  9. input子系统详解2

    上一节大概了解了输入子系统的流程 这一节认真追踪一下代码 input.c: input_init(void)函数 static int __init input_init(void) { int er ...

随机推荐

  1. mongodb及mongoclient在win7下的编译和使用

    1.导言 折腾mongodb几个小时最终有结果了.呃.如今就简单总结一下. 事实上我的需求非常easy,就是在C++代码中调用mongodb的库函数.也就是要得到mongoclient.lib.本来想 ...

  2. SharePoint 2013 Step by Step——使用自定义的List Template

    Overview 对于企业员工来说,"扁平结构"的LIST是日常操作中经常使用到的,LIST的好处是方便数据的录入以及数据的整理分析,尤其是Quick Edit功能,可以实现快速编 ...

  3. MPU6050陀螺仪和加速度计的校准

    加速度计和陀螺仪的校准: 在传感器静止不动水平放置时,测出陀螺仪和加速度计各轴的偏移值,保存.以后每次上电调用dmp_set_xx_bias()就行了. u8 run_self_test(void) ...

  4. HTML自定义对象与属性探究(谷歌,火狐,IE9浏览器没问题)

    1.自定义标签 <zqz>asdas</zqz> <style> zqz{ color:red; } </style> 页面变色 2.自定义标签的hov ...

  5. uiautomatorviewer 查看元素新思路

    用adb 命令把图片和uix获取出来,再导入uiautomatorviewer adb shell uiautomator dump /data/local/tmp/uidump.uixadb pul ...

  6. mysql数据导入遇到的timestamp类型问题

    今天准备把最新的表导入自己以前的机子上做临时开发,在数据库导入的时候遇到一个问题:Incorrect table definition; there can be only one TIMESTAMP ...

  7. C++ smart pointer智能指针

      在C++中,程序员可以直接操作内存,给编程增加了不少的灵活性.但是灵活性是有代价的,程序员必须负责自己负责释放自己申请的内存,否则就会出现内存泄露.智能指针就是为了解决这个问题而存在的.它和其他指 ...

  8. cygwin下安装c语言开发环境

    1.到官网cygwin.com下载安装程序. 2.添加清华的cygwin镜像:https://mirrors.tuna.tsinghua.edu.cn/cygwin/ 3.在安装:vim,git,gc ...

  9. jira 跟工时有关的配置文件

    ./atlassian-jira/WEB-INF/classes/jpm.xml 关建字:jira.timetracking.hours.per.day <property> <ke ...

  10. [Windows Azure] Windows Azure SQL Database library

    Microsoft Windows Azure SQL Database extends SQL Server capabilities to the cloud. SQL Database offe ...