博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux Kernel input handler处理
阅读量:4152 次
发布时间:2019-05-25

本文共 2581 字,大约阅读时间需要 8 分钟。

/*
 * Pass values first through all filters and then, if event has not been * filtered out, through all open handles. This function is called with * dev->event_lock held and interrupts disabled. */static void input_pass_values(struct input_dev *dev,			      struct input_value *vals, unsigned int count){	struct input_handle *handle;	struct input_value *v;	if (!count)		return;	rcu_read_lock();	handle = rcu_dereference(dev->grab);	if (handle) {		count = input_to_handler(handle, vals, count);	} else {		list_for_each_entry_rcu(handle, &dev->h_list, d_node)			if (handle->open) {				count = input_to_handler(handle, vals, count);				if (!count)					break;			}	}	rcu_read_unlock();	/* trigger auto repeat for key events */	if (test_bit(EV_REP, dev->evbit) && test_bit(EV_KEY, dev->evbit)) {		for (v = vals; v != vals + count; v++) {			if (v->type == EV_KEY && v->value != 2) {				if (v->value)					input_start_autorepeat(dev, v->code);				else					input_stop_autorepeat(dev);			}		}	}}
 
 
/* * Pass event first through all filters and then, if event has not been * filtered out, through all open handles. This function is called with * dev->event_lock held and interrupts disabled. */static unsigned int input_to_handler(struct input_handle *handle,			struct input_value *vals, unsigned int count){	struct input_handler *handler = handle->handler;	struct input_value *end = vals;	struct input_value *v;	if (handler->filter) {		for (v = vals; v != vals + count; v++) {			if (handler->filter(handle, v->type, v->code, v->value))				continue;			if (end != v)				*end = *v;			end++;		}		count = end - vals;	}	if (!count)		return 0;	if (handler->events)		handler->events(handle, vals, count);	else if (handler->event)		for (v = vals; v != vals + count; v++)			handler->event(handle, v->type, v->code, v->value);	return count;}
 
 
static struct input_handler kbd_handler = {	.event		= kbd_event,	.match		= kbd_match,	.connect	= kbd_connect,	.disconnect	= kbd_disconnect,	.start		= kbd_start,	.name		= "kbd",	.id_table	= kbd_ids,};int __init kbd_init(void){	int i;	int error;	for (i = 0; i < MAX_NR_CONSOLES; i++) {		kbd_table[i].ledflagstate = kbd_defleds();		kbd_table[i].default_ledflagstate = kbd_defleds();		kbd_table[i].ledmode = LED_SHOW_FLAGS;		kbd_table[i].lockstate = KBD_DEFLOCK;		kbd_table[i].slockstate = 0;		kbd_table[i].modeflags = KBD_DEFMODE;		kbd_table[i].kbdmode = default_utf8 ? VC_UNICODE : VC_XLATE;	}	kbd_init_leds();	error = input_register_handler(&kbd_handler);	if (error)		return error;	tasklet_enable(&keyboard_tasklet);	tasklet_schedule(&keyboard_tasklet);	return 0;}

转载地址:http://mwhti.baihongyu.com/

你可能感兴趣的文章
linux tool objdump
查看>>
linux tool nm
查看>>
字节对齐
查看>>
Python-发邮件
查看>>
python写入csv文件的两种方法
查看>>
pandas学习笔记—dataframe与list相互转化
查看>>
Keras和TensorFlow设置GPU及其使用率
查看>>
python常见异常处理方法
查看>>
pandas学习笔记—merge()函数详解
查看>>
pandas学习笔记—agg()函数详解
查看>>
Canny边缘检测算法原理及其OpenCV实现
查看>>
JupyterLab on JupyterHub(JupyterLab+JupyterHub)(JupyterLab JupyterHub)
查看>>
Ubuntu查找文件或文件夹
查看>>
DIGITS安装及服务部署
查看>>
利用Python脚本开发Hadoop的MapReduce大数据分析应用
查看>>
python连接SQL数据库
查看>>
python创建mysql数据库中的表
查看>>
python操作mysql表格-插入数据
查看>>
python更新mysql表
查看>>
python删除mysql表中数据
查看>>