应用层测试代码

#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. SharePoint 2013 实现多级审批工作流

    上一篇介绍了安装和配置SharePoint 2013 Workflow,这一篇将用SharePoint 2013 Designer Workflow来实现一个多级审批工作流. 审批工作流介绍 这个De ...

  2. SQL SERVER数据库维护与重建索引

    第一步:查看是否需要维护,查看扫描密度/Scan Density是否为100% declare @table_id int set @table_id=object_id('表名') dbcc sho ...

  3. Android帧布局<TabHost>标签

    先贴上一段代码: main.xml: <p><?xml version="1.0" encoding="utf-8"?> <Tab ...

  4. github 仓库共享上传权限

    https://blog.csdn.net/qq_33210042/article/details/79717497 打开仓库 -> Settings -> Collaborators 然 ...

  5. Android app启动activity并调用onCreate()方法时都默默地干了什么?

    Android app启动activity并调用onCreate() 方法时都默默地干了什么?   在AndroidManifest.xml文件中的<intent-filter>元素中有这 ...

  6. sysbench压力测试工具安装和参数介绍

    一.sysbench压力测试工具简介: sysbench是一个开源的.模块化的.跨平台的多线程性能测试工具,可以用来进行CPU.内存.磁盘I/O.线程.数据库的性能测试.目前支持的数据库有MySQL. ...

  7. ITOO高校云平台V3.1--项目总结(二)

    自身责任要明白 心态要明白 布置任务要有反馈 总结 今天下午.举办了一场ITOO高校云平台3.1总结大会,针对3.1开发的过程中统计上来的问题进行讨论. 通过讨论统计上来的问题,映射到自身,看看自己还 ...

  8. mybatis自己学习的一些总结

    曾经一直在使用spring的JDBCTEMPLATE和hibernate做项目.两个都还不错,spring的jdbctemplate用起来比較麻烦,尽管非常easy.而hibernate呢,用起来非常 ...

  9. 彻底删除Cygwin

    cygwin是一个好软件,凝聚了大家很多的心血,在win10下运行的很流畅,远比微软自己搞得那个ubuntu顺手,但它有个小问题,重装系统后,如果原来的cgywin文件夹没有删除的话,你会发现你无法删 ...

  10. pyenv管理多python版本

    手动安装 cd ~ git clone git://github.com/yyuu/pyenv.git .pyenv echo 'export PYENV_ROOT="$HOME/.pyen ...