Android Linux input发送事件不成功

lichujing lichujing 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
各位大师们,如下测试按键发送模块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);

...全文
评论
收藏 已收藏
分享
返回顶部