一 、 总体架构 图

  

上层是图形界面和应用程序,通过监听设备节点,获取用户相应的输入事件,根据输入事件来做出相应的反应;eventX (X从0开始)表示 按键事件,mice 表示鼠标事件

Input core  ---  input 核心

Input event drivers --- input事件驱动(mousedev 、 evdev、keyboard)

Input device drivers --- input设备驱动(触摸屏、键盘、鼠标)

三个重要的结构体:

代码路径: include\linux\input.h  (基于kernel4.0)

 struct input_dev {  ///代表 input 设备
const char *name; /// 设备名称
const char *phys; ////设备在系统结构中的物理路径
const char *uniq; ///设备的唯一标识符
struct input_id id; ///描述硬件设备属性的 ID unsigned long propbit[BITS_TO_LONGS(INPUT_PROP_CNT)];/// INPUT_PROP_CNT--0x20 ,一个long包含32bit,所以 propbit[1] unsigned long evbit[BITS_TO_LONGS(EV_CNT)]; ///设备支持的事件类型
unsigned long keybit[BITS_TO_LONGS(KEY_CNT)];
unsigned long relbit[BITS_TO_LONGS(REL_CNT)];
unsigned long absbit[BITS_TO_LONGS(ABS_CNT)];
unsigned long mscbit[BITS_TO_LONGS(MSC_CNT)];
unsigned long ledbit[BITS_TO_LONGS(LED_CNT)];
unsigned long sndbit[BITS_TO_LONGS(SND_CNT)];
unsigned long ffbit[BITS_TO_LONGS(FF_CNT)];
unsigned long swbit[BITS_TO_LONGS(SW_CNT)]; unsigned int hint_events_per_packet; unsigned int keycodemax;
unsigned int keycodesize;
void *keycode; int (*setkeycode)(struct input_dev *dev,
const struct input_keymap_entry *ke,
unsigned int *old_keycode);
int (*getkeycode)(struct input_dev *dev,
struct input_keymap_entry *ke); struct ff_device *ff; unsigned int repeat_key;
struct timer_list timer; int rep[REP_CNT]; struct input_mt *mt; struct input_absinfo *absinfo; unsigned long key[BITS_TO_LONGS(KEY_CNT)];
unsigned long led[BITS_TO_LONGS(LED_CNT)];
unsigned long snd[BITS_TO_LONGS(SND_CNT)];
unsigned long sw[BITS_TO_LONGS(SW_CNT)]; int (*open)(struct input_dev *dev);///打开设备
void (*close)(struct input_dev *dev);
int (*flush)(struct input_dev *dev, struct file *file);
int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value); struct input_handle __rcu *grab; spinlock_t event_lock;
struct mutex mutex; unsigned int users;
bool going_away; struct device dev;///每个设备的基类 struct list_head h_list;
struct list_head node; unsigned int num_vals;
unsigned int max_vals;
struct input_value *vals; bool devres_managed;
};
 struct input_handler {///代表输入设备的处理方法

     void *private;

     void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value);
void (*events)(struct input_handle *handle,
const struct input_value *vals, unsigned int count);
bool (*filter)(struct input_handle *handle, unsigned int type, unsigned int code, int value);///
bool (*match)(struct input_handler *handler, struct input_dev *dev);
int (*connect)(struct input_handler *handler, struct input_dev *dev, const struct input_device_id *id);
void (*disconnect)(struct input_handle *handle);
void (*start)(struct input_handle *handle); bool legacy_minors; ///是否遗留次设备号
int minor;///次设备号
const char *name;///名称 const struct input_device_id *id_table;/// input_device 和 input_handle 通过id_table 进行匹配 struct list_head h_list;
struct list_head node;
};

 

Match :在设备id 和handler 的id_table 匹配成功的时候调用; (called after comparing device's id with handler's id_table  to perform fine-grained matching between device and handler

Connect 当一个handle 匹配到一个device 的时候执行(called when attaching a handler to an input device

Start :当input 核心执行完 connect 以后调用(called by input core right after connect() method

 

 struct input_handle { //// 用来关联input_dev 和 input_handler (links input device with an input handler)

     void *private;///私有成员变量

     int open;
const char *name; struct input_dev *dev;
struct input_handler *handler; struct list_head d_node;
struct list_head h_node;
};

 

如图,横轴表示一系列的input 设备,纵轴表示事件驱动event,中间的紫色圆点代表input_handle,通过input_handle来关联设备驱动和事件驱动

    

 

 

 

(注:以上图片均来自麦子学院 金鑫老师的课程,在此对其辛勤付出和无私分享表示真挚的感谢!)

 

 

Linux input子系统学习总结(一)---- 三个重要的结构体的更多相关文章

  1. Linux input子系统学习总结(三)----Input设备驱动

    Input 设备驱动 ---操作硬件获取硬件寄存器中设备输入的数据,并把数据交给核心层: 一 .设备驱动的注册步骤: 1.分配一个struct  input_dev :          struct ...

  2. Linux input子系统学习总结(二)----Input事件驱动

    Input 事件驱动:  (主要文件 :drivers/input/evdev.c  .  drivers/input/input.h)基于kernel 4.0  一. 关键函数调用顺序: 1.inp ...

  3. Linux input子系统分析

    输入输出是用户和产品交互的手段,因此输入驱动开发在Linux驱动开发中很常见.同时,input子系统的分层架构思想在Linux驱动设计中极具代表性和先进性,因此对Linux input子系统进行深入分 ...

  4. Linux防火墙iptables学习笔记(三)iptables命令详解和举例[转载]

     Linux防火墙iptables学习笔记(三)iptables命令详解和举例 2008-10-16 23:45:46 转载 网上看到这个配置讲解得还比较易懂,就转过来了,大家一起看下,希望对您工作能 ...

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

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

  6. input子系统学习笔记六 按键驱动实例分析下【转】

    转自:http://blog.chinaunix.net/uid-20776117-id-3212095.html 本文接着input子系统学习笔记五 按键驱动实例分析上接续分析这个按键驱动实例! i ...

  7. Linux Input子系统浅析(二)-- 模拟tp上报键值【转】

    转自:https://blog.csdn.net/xiaopangzi313/article/details/52383226 版权声明:本文为博主原创文章,未经博主允许不得转载. https://b ...

  8. Linux Input子系统

    先贴代码: //input.c int input_register_handler(struct input_handler *handler) { //此处省略很多代码 list_for_each ...

  9. Linux input子系统简介

    1.前言 本文主要对Linux下的input子系统进行介绍 2. 软件架构 图 input子系统结构图 input子系统主要包括三个部分:设备驱动层.核心层和事件层.我们可以分别理解为:具体的输入设备 ...

随机推荐

  1. BZOJ3601 一个人的数论 【数论 + 高斯消元】

    题目链接 BZOJ3601 题解 挺神的 首先有 \[ \begin{aligned} f(n) &= \sum\limits_{x = 1}^{n} x^{d} [(x,n) = 1] \\ ...

  2. 洛谷 P2751 [USACO4.2]工序安排Job Processing 解题报告

    P2751 [USACO4.2]工序安排Job Processing 题目描述 一家工厂的流水线正在生产一种产品,这需要两种操作:操作A和操作B.每个操作只有一些机器能够完成. 上图显示了按照下述方式 ...

  3. 【bzoj2002】 Hnoi2010—Bounce 弹飞绵羊

    http://www.lydsy.com/JudgeOnline/problem.php?id=2002 (题目链接) 题意 数轴上${n}$个点,每个点有一个权值${a_i}$,如果到达这个点,接下 ...

  4. loj6070【山东集训第一轮Day4】基因

    题解: 分块对每个块的起点$st[i]$到$n$做一次回文自动机; 由于子串的回文自动机是原串的子图,所以并不需要重新构图,在原来的图上做即可: 做的时候记录某个终点的本质不同的回文串和$sum[i] ...

  5. centos install python3 pip3

    yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-dev ...

  6. golang 安装一个项目下的所有依赖

    go get -v ./...

  7. 使用Hystrix实现自动降级与依赖隔离-微服务

    转载: https://www.jianshu.com/p/138f92aa83dc Hystrix出现的原因: hystrix是netflix开源的一个容灾框架,解决当外部依赖故障时拖垮业务系统.甚 ...

  8. qq接入

    「花与剑: https://blog.csdn.net/wbbott/article/details/53107009」—————————

  9. 服务器安全策略之《通过IP安全策略阻止某个IP访问的设置方法》

    现在我们在布署好了一个网站,发布到外网后就意味着将会接受来自四面八方的黑客攻击,这个情况很常见,我们的网站基本上每天都要接受成千上万次的攻击,有SQL注入的.有代码注入的.有CC攻击等等...而我作为 ...

  10. RACCommand

    RACCommand是ReactiveCocoa中用于表示UI操作的一个类.它包含一个代表了UI操作的结果的信号以及标识操作当前是否被执行的一个状态. 1.创建新的RACCommand self.ex ...