应用层测试代码

#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. (面试题)html中创建模态窗口的方法有哪些?

    一.创建模态和非模态对话框除了alert(""); confirm(""); prompt("");之外还有创建模态对话框:vReturnV ...

  2. bash shell 合并多个文件内容到一个文件、查看多少行代码

    一.简单版: $ cat **/* > merge.fuck 二.结合find + xargs + cat版本: $ find ./ -iregex '.*\.\(js\|scss\|tpl\) ...

  3. jmeter 签名MD5生成

    请求接口需要同时发送签名,签名定义为: 可以看出签名就是把用户的密码 .用户名 和签名key生成一个md5串就可以了 刚好jmeter 有个md5 生成,生成前需要获取name ,password k ...

  4. 使用 Zipkin 和 Brave 实现分布式系统追踪(基础篇)

    一.Zipkin 1.1.简介 Zipkin 是一款开源的分布式实时数据追踪系统(Distributed Tracking System),基于 Google Dapper 的论文设计而来,由 Twi ...

  5. eclipse 运行 emulator时,PANIC:Could not open emulator 的解决办法

    使用eclipse启动emulator的时候,出现PANIC:Could not open emulator,模拟器无法正常的运行. 经过搜索得知,因为我的SDK的环境变量出问题,需要重新配置下环境变 ...

  6. shiro 自定义过滤器,拦截过期session的请求,并且以ajax形式返回

    自定义过滤器: public class CustomFormAuthenticationFilter extends FormAuthenticationFilter { @Override pro ...

  7. redis 指定IP访问

    配置IPTABLES -A INPUT -s 10.100.0.5 -p tcp --dport 6379 -j ACCEPT -A INPUT -s 10.100.0.219 -p tcp --dp ...

  8. 菜鸟学SSH(九)——Hibernate——Session之save()方法

    Session的save()方法用来将一个临时对象转变为持久化对象,也就是将一个新的实体保存到数据库中.通过save()将持久化对象保存到数据库需要经过以下步骤: 1,系统根据指定的ID生成策略,为临 ...

  9. 正确使用 Volatile 变量

    Java 语言中的 volatile 变量可以被看作是一种 “程度较轻的 synchronized”:与 synchronized 块相比,volatile 变量所需的编码较少,并且运行时开销也较少, ...

  10. AI 技术咖们说,进入未来世界首先需要一个“虚拟的我” | 科技生活节倒计时8天

    http://www.tmtpost.com/3367762.html 未来世界是什么样子? 斯皮尔伯格在<头号玩家>中构建了一个充满科技感.富有浓烈浪漫主义色彩的虚拟世界.戴上VR眼镜, ...