Android Linux input发送事件不成功
各位大师们,如下测试按键发送模块insmod后为什么Android上层未接受到Home按键。
插入模块后UI上只是选中了一个ICON,并没有起到HOME键的作用,求大牛解惑!
static int __init test_init(void)
{
int ret;
device = input_allocate_device();
if(IS_ERR(device))
{
printk("Allocate input device error\n");
return -1;
}
ret = input_register_device(device);
if(ret < 0){
printk("Register device error\n");
return ret;
}
input_set_capability(device, EV_KEY, KEY_HOME);
printk("========Module test=========\n");
input_event(device,EV_KEY,KEY_HOME,1);
input_sync(device);
input_event(device,EV_KEY,KEY_HOME,0);
input_sync(device);
return 0;
}
module_init(test_init);