input 子系统开发
来源:互联网 发布:逆战混沌16连炮数据 编辑:程序博客网 时间:2024/06/05 07:15
一、linux input 子系统
二、android 按键事件提交基本过程
1、android 系统在frameworks/base/services/input/ 对input子系统进行监听处理。
2、在WindowManagerService 有input收集线程和input分发线程
3、当在linux input 的子系统当中所有的事件提交都会被收集线程收集到,然后有input分发线程发送到各个apk。
三、按键值查看
1、提交到上层的按键宏存在在kernel/include/ 目录下 uapi/linux/input.h 头文件#define KEY_BACK 158 /* AC Back */ //返回按键
#define KEY_VOLUMEDOWN 114 //音量减
#define KEY_VOLUMEUP 115 //音量加
#define KEY_HOME 102 //home 键
四、实现提交音量加事件给android 上层
1、驱动代码 event.c#include <linux/module.h>
#include <linux/fs.h>
#include <linux/input.h>
#include <linux/delay.h>
#define REPORT_KEY KEY_VOLUMEUP //提交音量加按键宏
static struct input_dev *input_device;
//提交按键函数
static void report_key(unsigned int keyvalue)
{
input_report_key(input_device, keyvalue, 1); //提交按下操作
input_sync(input_device);
input_report_key(input_device, keyvalue, 0); //提交弹起操作 (音量加减键为虚拟按键,需要同时提交按下和弹起操作)
input_sync(input_device); //同步提交完毕
}
static int input_device_open(struct input_dev *dev)
{
printk("input_device_open \n");
return 0;
}
static void input_device_close(struct input_dev *dev)
{
printk("input_device_close \n");
}
static int __init Input_init(void)
{
int err = 0;
input_device = input_allocate_device();
if (!input_device) {
printk("input_allocate_device failed \n");
return -1;
}
set_bit(EV_KEY, input_device->evbit); //设置文件按键事件
set_bit(REPORT_KEY, input_device->keybit); //设置可以重复提交多次
clear_bit(0, input_device->keybit);
input_device->open = input_device_open;
input_device->close = input_device_close;
/*注册到input 子系统当中*/
if(input_register_device(input_device))
{
printk(KERN_ERR " Failed to input_register_device\n");
return -1;
}
printk("Input system init ok ...... \n");
mdelay(10);
report_key(REPORT_KEY);
return 0;
}
static void __exit Input_exit(void)
{
input_unregister_device(input_device);
input_free_device(input_device);
printk("Input system exit ok ...... \n");
}
module_init(Input_init);
module_exit(Input_exit);
MODULE_LICENSE("Dual BSD/GPL");
2、Makefile 文件
CONFIG_CHARDEV ?=m
obj-$(CONFIG_CHARDEV) +=event.o
KERN_DIR =/home/rk3128/rk3128_v4/rk3128_4.4_tb01_new_v3/kernel/
modules:
$(MAKE) -C $(KERN_DIR) M=$(PWD) modules
clean:
rm -rf chartest *.o *~core .depend. *.cmd *.ko *.mod.c .tmp_versions
3、将驱动安装
insmod event.ko
可以看到android 界面当中弹出音量加操作,和我们按下手机音量加操作是一样的操作。
- input 子系统开发
- Linux驱动开发之input子系统
- linux驱动开发:input子系统二
- linux驱动开发:input子系统一
- linux驱动开发:input子系统三
- input子系统
- input子系统
- input子系统
- input子系统
- Input 子系统
- Input子系统
- input子系统
- Input子系统
- input子系统
- input子系统
- input子系统
- input 子系统
- input子系统
- 一对一对多关系与购物车、订单设计
- Hibernate与Mybatis对比(转)
- 面试小问题
- java 中的缓存的原理
- ASp.net
- input 子系统开发
- multipath 路径切换
- centos6 伪分布式模式安装hadoop
- C++第七次实验-素数和回文
- openstack m:CentOS 虚拟机动态IP
- 二叉树的层次遍历
- 配置Tomcat8
- 《并行计算》期末总结
- Mockito入门学习(3)–Partial Mock(部分模拟)