uinput是linux 2.6用来实现用户空间输入设备的内核接口,用它可以在用户空间实现输入设备,向系统中注入输入事件,而不需要通过GUI去实现。使用时要确保内核编译时支持uinput模块,可能还要手工创建设备文件/dev/uinput(mknod /dev/uinput c 10 223)。
o 创建user input device
UInput* uinput_create(const char* dev, int xmax, int ymax);
android平台用xmax和ymax对触摸屏做简单的校准,如果不设置为实际的值,事件先会被丢掉。
o 上报mouse按键事件
void uinput_report_lbutton_event(UInput* thiz, int press);
void uinput_report_mbutton_event(UInput* thiz, int press);
void uinput_report_rbutton_event(UInput* thiz, int press);
o 上报mouse移动事件
void uinput_report_move_event(UInput* thiz, int x, int y);
o 上报按键事件
void uinput_report_key_event(UInput* thiz, unsigned short key, int press);
o 上报触摸屏事件
void uinput_report_touch_event(UInput* thiz, int x, int y, int press/*1(down) 0(up) -1(move)*/);
o 销毁设备
void uinput_destroy(UInput* thiz);
有需要的朋友请到这里下载。
void uinput_report_key_event(UInput* thiz, unsigned short key, int press);我怎样用这个函数注入组合键的事件,如Ctrl-X?
我也遇到点问题,怎么样实现手机的返回,打电话,等按钮呢。
李sir,遥控器设备如何添加呢