键盘 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 ...
随机推荐
- process credentials(三)
主要内容包括: 1.进程描述符中Realtime Mutex相关数据结构的初始化 2.子进程如何复制父进程的credentials 3.per-task delay accounting的处理 4.子 ...
- 真正理解 git fetch, git pull 以及 FETCH_HEAD
真正理解 git fetch, git pull 要讲清楚git fetch,git pull,必须要附加讲清楚git remote,git merge .远程repo, branch . commi ...
- 并发测试 JavaDemo
https://github.com/oldratlee/fucking-java-concurrency /** * @author Jerry Lee */ public class Testee ...
- Knockout: 使用CSS绑定和event的blur失去焦点事件, 给未通过校验的输入框添加红色边框突出显示.
目的:使用knockout提供的机制实现输入框失去焦点后的校验工作,并使用CSS绑定给未通过校验的输入框添加红色边框突出显示. 步骤: 先在htm中添加.error的css样式, 并在输入框中的dat ...
- 图数据库titan 和 rexster安装手册
titan是图数据库, rexster是图显示服务 titan 安装 下载 titan 0.3.2 解压 titan-all-0.3.2.zip 到 /opt/hugedata/share/解压后得到 ...
- oracle PLSQL 多结果集嵌套循环处理优化
oracle多结果集嵌套循环处理优化 --性能差 begin for a in (select id,name,sex,idcard from people) loop for b in (selec ...
- js评价五星
js评价五星 1.图片(star.png): 2.图片和html文件在同级目录 <html> <head> <script src="http://libs.b ...
- java基础知识总结1
一. java开发工具 Editplus:Editplus与jdk的连接配置.如:javac(编译).java(运行).javap(查看字节码) a) 配置内容: i. javac(编译):參数为 - ...
- 【Unity】10.3 创建类人动画角色
分类:Unity.C#.VS2015 创建日期:2016-05-02 一.简介 Mecanim 动画系统 (Mecanim Animation System) 特别适合使用类人骨架动画.由于类人骨架非 ...
- 【Unity】第5章 3D坐标系和天空盒
分类:Unity.C#.VS2015 创建日期:2016-04-20 一.简介 这一张主要介绍3D坐标系的基础知识以及各种形状的天空盒. 二.示例 本章的示例都在ch05Demos工程下.