Linux输入子系统模型

Linux输入子系统模型:


Input Device Driver:输入设备驱动,需要用户自己实现

Input Core:输入子系统核心部分,Linux内核已经做好

Input Event Driver:输入时间驱动,Linux内核已经做好

Hardware:输入设备


任何一次输入事件,如鼠标移动, 按键按下,都需要通过InputDeviceDriver- >InputCore- >EventDrive才能到达用 户 空间的应用程序。

设备驱动层:将底层的硬件输入转化为统一事件型式, 向输入核心( InputCore)汇报。

输入核心层:为设备驱动层提供输入设备注册与操作接口,如:为设备驱动层提供输入设备注册与操作接口 , 如:input_register_device;通知事件处理层对事件进行处理。

事件驱动层:主要作用是和用户空间交互, 如提供read, open等设备方法, 创建设备文件等。

Linux输入子系统驱动设计流程:


Linux输入子系统事件类型:
EV_RST: Reset
EV_REL: 相对坐标
EV_MSC: 其他
EV_SND: 声音
EV_REP: Repeat
EV_FF: 力反馈
EV_KEY: 绝对坐标
EV_ABS: 绝对坐标
EV_LED: LED
......


Linux输入子系统---应用程序示例:
Controlling the playback of effects
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 Control of playing is done with write(). Below is an example:
#include <linux/input.h> 
#include <unistd.h>
	struct input_event play;
	struct input_event stop;
	struct ff_effect effect;
	int fd;
 ... 
fd = open("/dev/input/eventXX", O_RDWR);
... 
/* Play three times */
	play.type = EV_FF;
	play.code = effect.id;
	play.value = 3;
	write(fd, (const void*) &play, sizeof(play));
 ... 
/* Stop an effect */
	stop.type = EV_FF;
	stop.code = effect.id;
	stop.value = 0;
	write(fd, (const void*) &play, sizeof(stop));
Information about the status of effects 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
Every time the status of an effect is changed, an event is sent. The values and meanings of the fields of the event are as follows:
struct input_event 
{ /* When the status of the effect changed */ 
    truct timeval time;
/* Set to EV_FF_STATUS */ 
    nsigned short type;
/* Contains the id of the effect */ 
    unsigned short code;
/* Indicates the status */ 
    unsigned int value; 
};
FF_STATUS_STOPPED	The effect stopped playing FF_STATUS_PLAYING	The effect started to play


 
 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值