键盘 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\n");
else //key1被释放
printf("key is released\n");
}
}
close(fd);
return 0;
}
键盘 Input子系统的更多相关文章
- input子系统
input子系统: 像按键.键盘.鼠标.触摸屏.游戏摇杆等设备只有输入没有输出,而且在编程实现其对应的驱动程序时会有很多重复性的代码,内核的设计者将该部分代码抽象出来,驱动工程师只需要复用该 ...
- linux kernel input 子系统分析
Linux 内核为了处理各种不同类型的的输入设备 , 比如说鼠标 , 键盘 , 操纵杆 , 触摸屏 , 设计并实现了一个对上层应用统一的试图的抽象层 , 即是Linux 输入子系统 . 输入子系统的层 ...
- input子系统详解
一.初识linux输入子系统 linux输入子系统(linux input subsystem)从上到下由三层实现,分别为:输入子系统事件处理层(EventHandler).输入子系统核心层(Inpu ...
- input子系统分析
------------------------------------------ 本文系本站原创,欢迎转载! 转载请注明出处:http://ericxiao.cublog.cn/ -------- ...
- 基于input子系统的sensor驱动调试(二)
继上一篇:http://www.cnblogs.com/linhaostudy/p/8303628.html#_label1_1 一.驱动流程解析: 1.模块加载: static struct of_ ...
- linux内核input子系统解析【转】
转自:http://emb.hqyj.com/Column/Column289.htm 时间:2017-01-04作者:华清远见 Android.X windows.qt等众多应用对于linux系统中 ...
- Linux input子系统 io控制字段【转】
转自:http://www.cnblogs.com/leaven/archive/2011/02/12/1952793.html http://blog.csdn.net/guoshaobei/arc ...
- input 子系统架构总结【转】
Linux输入子系统(Input Subsystem) 转自:http://blog.csdn.net/lbmygf/article/details/7360084 Linux 的输入子系统不仅支持鼠 ...
- input子系统详解2
上一节大概了解了输入子系统的流程 这一节认真追踪一下代码 input.c: input_init(void)函数 static int __init input_init(void) { int er ...
随机推荐
- pthread编译时报错的解决方法
最近在学习POSIX thread编程,今天编译一个程序报如下错误: /tmp/ccXH8mJy.o:在函数‘main’中:deadlock.c:(.text+0xbb):对‘pthread_crea ...
- 转 MySQL问题排查工具介绍
原文链接: http://mrchenatu.com/2017/03/24/mysql-tool/ 本总结来自美团内部分享,屏蔽了内部数据与工具 知识准备 索引 索引是存储引擎用于快速找到记录的一种数 ...
- Java获取请求客户端的真实IP地址
整理网友的材料,最后有源码,亲测能解决所有java获取IP真实地址的问题 整理的这里: 1.链接1 2.链接2 JSP里,获取客户端的IP地址的方法是: request.getRemoteAddr() ...
- elasticsearch 性能监控基础
一.Elasticsearch 是什么 Elasticsearch是一款用Java编写的开源分布式文档存储和搜索引擎,可以用于near real-time存储和数据检索. 1.Elasticsearc ...
- js两个日期相减
function dateHanle(d1,d2){ if(Date.parse(d1) - Date.parse(d2)==0) { console.log("d1等于d2"); ...
- Vivado神器之DocNav
Vivado2014安装完成以后会有2个文件出现在桌面上,具体如下图: 上一个是vivado的软件,是主要的工具,但是一定不要忽略下面一个DocNav,今天我要讲的就是这个工具,打开一个会看到这样一个 ...
- 【Unity】3.5 导入音频文件
分类:Unity.C#.VS2015 创建日期:2016-04-05 一.简介 音频文件 (Audio File) 资源的选择原则应该以无故障地流畅运行为宗旨.下面列出了常用的音频文件. .AIFF ...
- 深入浅出HTTPS基本原理
基础知识准备:在了解HTTPS的基本原理之前,需要先了解如下的基本知识. 一.什么是HTTPS,TLS,SSL HTTPS,也称作HTTP over TLS.TLS的前身是SSL,TLS 1.0通常被 ...
- django rest_framework入门二-序列化
在前一节中,我们已经粗略地介绍了rest_framework的作用之一序列化,下面我们将详细探究序列化的使用. 1.新建一个app snippets python manage.py startapp ...
- 【ActiveMQ】Spring Jms集成ActiveMQ学习记录
Spring Jms集成ActiveMQ学习记录. 引入依赖包 无论生产者还是消费者均引入这些包: <properties> <spring.version>3.0.5.REL ...